| [Previous][Up] |
When compiling units and programs, the installer will by default compile all targets in the order that they were specified
However, if unita depends on unitb, and unita was specified before unitb, then unitb will be compiled twice: when compiling unita the compiler will compile it because it needs unitb. Then unitb2 will be compiled because it is in the list of targets. Clearly, this is not ideal or efficient.
There are 2 ways to solve this:
The latter is clearly the easier solution. When using a build unit, the installer will of course delete the unit sources and .ppu file after compiling, since they are not needed any more after compilation.
When running the installer, you can request that it tries to use a build-unit by giving the -bu or --buildunit command-line option. However, there are some cases when using a build unit is not an option. Therefore, the TPackage.SupportedBuildModes property can be used to indicate which build modes can be used for a package. if the bmBuildUnit build mode (TBuildMode) is not in the set of buildmodes, then the installer will compile one by one, even when a buildunit was requested.
To specify dependencies, you can use the Dependencies property of TTarget:
uses fpmkunit; var P: TPackage; T : TTarget; begin With Installer do begin P:=Packages.AddPackage('mypackage'); P.Dependencies.Clear; T:=P.Targets.AddUnit('src2/unita.pp'); T.Dependencies.AddUnit('unitb'); P.Targets.AddUnit('src2/unitb.pp'); Run; end; end.
You can add a unit to the dependencies using TDependencies.AddUnit, or a complete package using TDependencies.Add.
When compiling the above and running it, the following output can be seen
./fpmake4 compile -v
Start compiling package mypackage for target x86_64-linux.
Compiling target unitb
Executing command "/home/michael/bin/fpc \
-Tlinux -Px86_64 \
-FUunits/x86_64-linux/ \
src2/unitb.pp"
Compiling target unita
Executing command "/home/michael/bin/fpc \
-Tlinux -Px86_64 \
-FUunits/x86_64-linux/ \
src2/unita.pp"
Generating "mypackage-x86_64-linux.fpm"
[100%] Compiled package mypackage
As you can see, the installed compiled unitb first.
|
Commandline options |
|
|
Usage description |