Recent

Author Topic: Creating a package for Lazarus  (Read 429 times)

MISV

  • Hero Member
  • *****
  • Posts: 711
Creating a package for Lazarus
« on: November 19, 2020, 10:42:43 am »
I am using OmniXML
https://github.com/mremec/omnixml

It has no LPK file for Lazarus. I woould like to have (even though it is purely nonvisual) so I can include it in "required packages" in my own projects (without having to add file paths which may not not translate well to other windows/mac machines)

So I have tried to create this:
In "D:\installed components\omnixml\dpk" I create "OmniXML_Lazarus.lpk"

It looks like this at present:
Code: Pascal  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <CONFIG>
  3.   <Package Version="5">
  4.     <PathDelim Value="\"/>
  5.     <Name Value="OmniXML_Lazarus"/>
  6.     <Type Value="RunAndDesignTime"/>
  7.     <CompilerOptions>
  8.       <Version Value="11"/>
  9.       <PathDelim Value="\"/>
  10.       <SearchPaths>
  11.         <IncludeFiles Value=".."/>
  12.         <OtherUnitFiles Value=".."/>
  13.         <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
  14.       </SearchPaths>
  15.       <Parsing>
  16.         <SyntaxOptions>
  17.           <IncludeAssertionCode Value="True"/>
  18.         </SyntaxOptions>
  19.       </Parsing>
  20.       <CodeGeneration>
  21.         <Checks>
  22.           <IOChecks Value="True"/>
  23.           <RangeChecks Value="True"/>
  24.           <OverflowChecks Value="True"/>
  25.           <StackChecks Value="True"/>
  26.         </Checks>
  27.         <VerifyObjMethodCallValidity Value="True"/>
  28.         <Optimizations>
  29.           <OptimizationLevel Value="3"/>
  30.         </Optimizations>
  31.       </CodeGeneration>
  32.       <Linking>
  33.         <Debugging>
  34.           <DebugInfoType Value="dsDwarf2Set"/>
  35.           <UseExternalDbgSyms Value="True"/>
  36.         </Debugging>
  37.       </Linking>
  38.       <Other>
  39.         <Verbosity>
  40.           <ShowUsedFiles Value="True"/>
  41.           <ShowTriedFiles Value="True"/>
  42.         </Verbosity>
  43.         <CustomOptions Value="-Ur"/>
  44.       </Other>
  45.     </CompilerOptions>
  46.     <Files Count="2">
  47.       <Item1>
  48.         <Filename Value="..\OmniXML.pas"/>
  49.         <UnitName Value="OmniXML"/>
  50.       </Item1>
  51.       <Item2>
  52.         <Filename Value="..\OmniXMLXPath.pas"/>
  53.         <UnitName Value="OmniXMLXPath"/>
  54.       </Item2>
  55.     </Files>
  56.     <CompatibilityMode Value="True"/>
  57.     <RequiredPkgs Count="1">
  58.       <Item1>
  59.         <PackageName Value="LCLBase"/>
  60.       </Item1>
  61.     </RequiredPkgs>
  62.     <UsageOptions>
  63.       <CustomOptions Value="-Ur"/>
  64.       <UnitPath Value="$(PkgOutDir)"/>
  65.     </UsageOptions>
  66.     <PublishOptions>
  67.       <Version Value="2"/>
  68.     </PublishOptions>
  69.   </Package>
  70. </CONFIG>
  71.  

It installs ok, but if I try compile something using the packing (havinvg added it to "Required" list) I still get error where I reference "OmniXML" in my use clause. And compile gives error

Quote
Messages, Warnings: 1
Warning: other unit files search path (aka unit path) of "MyOwnExampleProgram" contains "W:\data\shared-code\MyOwnExampleLibraryPath", which belongs to package "MyOwnExampleLibraryPackage"
Compile package MyOwnExampleLibraryPackage 0.0: Exit code 1, Errors: 1
MyOwnLibraryUnit.pas(145,3) Fatal: Cannot find OmniXML used by MyOwnLibraryUnit. Make sure all ppu files of a package are in its output directory. ppu in wrong directory=D:\installed components\omnixml\dpk\lib\x86_64-win64\OmniXML.ppu. Clean up package "OmniXML_Lazarus"..

I am unsure what exactly is wrong in "OmniXML_Lazarus.lpk" ... Ideally I would like to be able to reference all the units in "D:\installed components\omnixml\" where al the source files are placed
« Last Edit: November 19, 2020, 10:51:20 am by MISV »

wp

  • Hero Member
  • *****
  • Posts: 7951
Re: Creating a package for Lazarus
« Reply #1 on: November 19, 2020, 12:47:01 pm »
Are you sure that this package did compile? I tried a runtime package on my own but got lots of compiation errors.

Can't you try to use the xml units which come with fpc?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

MISV

  • Hero Member
  • *****
  • Posts: 711
Re: Creating a package for Lazarus
« Reply #2 on: November 19, 2020, 01:32:43 pm »
Are you sure that this package did compile? I tried a runtime package on my own but got lots of compiation errors.

I have omnixml working... Are you getting errors? I will try check if I made any changes.

Nontheless I would like to understand have to make packages that Lazarus accept since it seems to the best way for flexibility.


Can't you try to use the xml units which come with fpc?

I have trying to have my entire project (almost including forms... I need to make a few tweaks everything I switch, but solved 95%) cross compilable in Lazarus and Delphi. I may some day switch entirely to Lazarus, but... well...

wp

  • Hero Member
  • *****
  • Posts: 7951
Re: Creating a package for Lazarus
« Reply #3 on: November 19, 2020, 02:37:16 pm »
Here's what I did to create a finally working stripped-down" Lazarus package:
  • Click "Package" > "New package". Specify the package name and find a place where it should be stored (here: (omnixmlfolder)\dpk\omnxml_laz.lpk -- using lower-case names saves you a lot of trouble when you work on Linux.
  • Since the OmniXML package contains only runtime code the package should be marked as "Runtime package" so that it cannot be installed in the IDE: Package options > "IDE Integration" > "Package type" "Runtime" or "Runtime only".
  • In the treeview of the package editor, right-click on "Files" > "Add Files From File System". Navigate to the source directory of the package and add all the files required, usually all. Your version seems to add only two of them - I do the same and add only OmniXML.pas and OmniXMLXPath.pas.
  • Click "Compile". There is "unit not found error" for LazUTF8 which is not convered by the package requirements of the new package. LazUTF8 is in package LazUtils -- right-click on "Requirements" > "New Requirement".  Select "LazUtils". OK.
  • Compile again -- no more error. Fine. BUT: There are more units in the package - we only added two; the missing units cannot be "used" in a project...
  • So, let's add the other units by a right-click on "Files".more units...
  • As you will see, there are lots a compilation errors now. To get a working solution I usually remove everything which looks "difficult" or "not needed".
  • Restore the previous state of the package (with only OmniXML and OmniXMLPath added) and begin adding more and more units. Test compilation. When compilation aborts fix the offending code, or remove the unit again. For example I get stuck in MSXML2_TLB - type libraries are hard stuff, let's try if we can live without it: remove the unit again, and remove also OmniXML_MSXML (with needs the type lib).
  • Etc, etc...
I am attaching the "maximum" package that I could achieve witout seriously modifying sources. It contains all units except for the type-lib thing already mentioned and the OmniXMLPersistent and related units. I tried to run the XPath and XmlFormatter demo programs with this "stripped" package, and surprisingly they work, after removal of the unnecessary OmniMSXML unit from the project unit and the usual adaptions to Lazarus. There are probably other demos which work too, but I did not check out the others.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

MISV

  • Hero Member
  • *****
  • Posts: 711
Re: Creating a package for Lazarus
« Reply #4 on: November 25, 2020, 09:28:53 am »
Thank you. I am checking it out today and will report back soon :)

 

TinyPortal © 2005-2018