[Scons-users] Integration with other build system

Dirk Bächle tshortik at gmx.de
Sun May 4 17:56:04 EDT 2014


Hi Matthias,

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/

, it's '*.pas' and '*.dcu'?
Please be as specific as you can when describing your problem.


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


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

I would write single Builders, MyCompile and MyLink. Then I'd add
pseudo-Builders MyProjectExe and MyProjectLib, which accept a
project file as input. Within this pseudo-Builder (see
http://www.scons.org/wiki/ToolsForFools ) you can parse the project file,
and call the MyCompile and MyLink builders as often as required for the
single build steps. In this way, your intermediate
targets get known to SCons automatically, and should get cleaned without
any further ado.

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


And where exactly is that output directory, relative to the project
directory? Again, try to be specific please.


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

Best regards,

Dirk



More information about the Scons-users mailing list