Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-05

Packages and file loading

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Lord Satan

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 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. 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?

tia
Satan

A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

Mattias Gaertner
to Lord Satan
Show quoted text 5 lines
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)

Show quoted text 6 lines
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.

Show quoted text 8 lines
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

Reply by email

Lord Satan
to Mattias Gaertner
There is one: $PkgDir(asmodaypkg)

Since when?

I will test which of your proposed solutions is the best for me. Thanks for having pity with me and answering my question.

Iblis

A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email