[Lazarus] Packages and file loading
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu May 7 23:09:01 CEST 2009
On Tue, 5 May 2009 15:35:13 +0200
Lord Satan <reimgrab at web.de> wrote:
> Hi everyone,
>
> I have a problem with the package I am writing. I have some
> non-pascal source code which my package must load at compile or run
> time into a TStringList. But as there is nothing like a $PkgDir macro
There is one:
$PkgDir(asmodaypkg)
> I don't know how to find the files at run time. Include files would
> be my only option at compile time which I don't like as they need at
> least a token, which means that every source line must be in quotes
> which makes it impossible to use syntax highlighting for the
> non-pascal code. Of course I could just put the source into my pascal
> code but that would be cumbersome, ugly and not easy to maintain.
You could create lrs files from arbitrary files:
compile tools/lazres.lpi to create tools/lazres
./tools/lazres your.lrs your1.something your2.something ...
You can update them manually or write a script/program and execute that
before package compile.
> So
> as a last option I wanted to copy my non-pascal source files after
> compilation of the package to a known directory (the plattforms
> config dir for example). So I wrote a little console app to do that
> just to realize that I cannot add a program to my package. At the
> moment I am at a loss what to do now. Is my only option to call fpc
> myself in the 'after compilation step' of the package compilation to
> compile my copy tool and after that call the tool to copy the files?
Maybe this works for you:
Create a package (e.g. yourtool), add the source of your program,
uncheck 'use unit'.
Then put the command to compile into the 'after compilation step':
fpc yourprogram.pas -FE$PkgOutDir(yourtool)/
and check 'Scan for FPC messages'.
Then add yourtool as requirement to your main package.
Whenever your main package is compiled, the yourtool package is
compiled too, which automatically compiles your tool.
Mattias
More information about the Lazarus
mailing list