[Scons-users] Integration with other build system

Matthias-Christian Ott ott at mirix.org
Sun May 4 15:53:21 EDT 2014


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¹. 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? Is it safe to call Clean and SideEffect in the scanner
function? Adding the object files as a target in the emitter leads to
something similar. Is it safe to recursively add source files that are
required by source files declared in the project file? How could I add
the .obj files as side effects to be cleaned?

Another problem I have is that the compiler puts all object files,
executables and libraries (if not other specified in the project file)
in a directory out-side of the current project's directory. So SCons
won't clean or build them. 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)?

Thanks!

Matthias-Christian

¹ = Delphi 5 project files


More information about the Scons-users mailing list