[Scons-users] Integration with other build system
Matthias-Christian Ott
ott at mirix.org
Mon May 5 05:30:42 EDT 2014
On 2014-05-04 23:56, Dirk Bächle wrote:
> Hi Matthias,
Hi Dirk,
> On 04.05.2014 21:53, Matthias-Christian Ott wrote:
>> I'm about write the equivalent of “gcc -M” and use GNU Make to solve
>> this problem. Perhaps somebody can help me to avoid this.
>>
>> I need to compile software projects¹.
> ¹ = Delphi 5 project files
>
> are we talking about Pascal as basic programming language here? I'm a
> little confused, because in your examples you refer to extensions like
> '*.src' and '*.obj'. In this overview
>
> http://www.delphi-treff.de/ueber-delphi/entwicklungsumgebung-bis-delphi-7/compiler/
For international readers:
http://delphi.wikia.com/wiki/Delphi_File_Extensions
> , it's '*.pas' and '*.dcu'?
> Please be as specific as you can when describing your problem.
For example, I have Delphi 5 projects (.dpk) that reference source code
files (.pas). The compiler (dcc32) produces object files (.dcu) for each
source code file and the project file, moreover it produces a .dcp file
and the a library file (.bpl). I generically renamed the file extensions
in the first email to make the problem more understandable.
>> Software projects can either
>> produce executables or libraries. Software projects reference source
>> code files. There is a compiler that reads software project files,
>> determines the project type (executable or library), compiles the source
>> code and links the object files to produce an executable or a library.
>>
>> A project file would look like:
>>
>> example.proj:
>>
>> executable
>> [...]
>> includes 'a.src', 'b.src', ...
>> [...]
>>
>> I wrote a parser that parses the project files and extracts all
>> referenced source code files and the project type. So SCons can
>> determine that when a.src, b.src, ... or example.proj change,
>> example.exe needs to be recompiled and that during the compilation
>> a.obj, b.obj, ... are produced.
>>
>> I wrote a builder with src_suffix='.proj' and a source_factory that
>> creates SCons.Node.FS.File objects and monkey patches the nodes'
>> target_from_source method with SCons.Util.AddMethod to call the parser
>> on the file, determine whether the project produces an executable or
>> library and append the corresponding file extension.
>>
>> When call I Clean and SideEffect in the scanner I wrote for the .proj
>> files, I get a strange dependency tree with nodes in the root directory,
>> e.g.:
>>
>> +-.
>> +-example.proj
>> +-a.obj
>> +-b.obj
>> +-a.obj
>> +-b.obj
>>
>> Is this intended?
>
> This is normal when you call "scons --tree=derived" for example.
I executed “scons --tree=all”. I noticed that in a C++ project, a.obj
and b.obj are not listed under each directory.
>> Is it safe to call Clean and SideEffect in the scanner
>> function?
> No. It's the wrong place to do that.
>
> And in your case, as far as I understood the basic flow of the single
> build steps, it shouldn't be necessary at all.
> You seem to have a Compile step for each '*.src' -> '*.obj', and a Link
> step '*.obj' -> 'your_program.exe'.
No, I execute dcc32 on the .dpk file. dcc32 produces .dcu, .dcp and .bpl
or .exe files. Depending on the settings in the .dof file of the project
and settings from the Windows Registry, the files are placed in
directories outside of the current directory.
So I can't have a separate linking phase. I all I want is the following:
If I call DelphiProject('filename.dpk') or DelphiProject('filename.dpr')
in a SConstruct file, SCons reads filename.dpr/.dpk, extracts all
dependencies (source files, resources, forms etc.) from the project
files and recursively from the dependencies and also considers binaries
(.dcu, .dcp .bpl, .exe) as dependencies. It then checks if the MD5
hashes project files or their dependencies changed. If so, it executes
dcc32 on the project files.
However, I don't know where and how to properly insert the dependencies.
For .bpl and .exe I do this in the target_from_source method, but for
other files I'm not sure. I could for example scan the project file for
source files. But what if the source files depend on form files and so
on? Where should I declare that dcc32 produces object files for each
source file?
>> When I call
>> Default(ProjectBuilder('example.proj')) it only considers the first list
>> element returned by the emitter and ignores some files in the current
>> directory. Can SCons be used to build the object files, executables and
>> libraries outside of the current directory while considering all files
>> in the current directory as well (SCons' default behaviour)?
> Yes, you just have to specify them as explicit targets on the
> command-line...or via the Default() method.
My problem is that, I returned the .bpl/.exe, .dcu, .dcp files as
targets in the emitter of the builder. If I call
Default(DelphiProject('example.dpk')), the .dcu and .dcp don't appear in
the output of “scons --tree=all”.
I hope this more understandable now. If you need further explanations, I
can send a more detailed description in German.
Regards
Matthias-Christian
More information about the Scons-users
mailing list