Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force the SConscript builder to change directory?

Tags:

scons

delphi

currently I'm trying to port a million-sloc legacy project from dull .cmd scripts to SCons. Parts of it are VC++, others are Delphi. Creating SConscripts for the C++ pieces was a breeze.

To build the delphi part I've written a very simple builder which detects whether it is a program or library project. Calling the builder after chaining via SConscript makes scons to call dcc32 $subdir/project.dpr what misleads dcc32 to look for units in the current directory instead of the $subdir.

Is there a way to tell scons to enter the $subdir before executing commands residing in the sconscript or should I fix it within the builder?

Thank you in advance

like image 709
Damg Avatar asked Jun 07 '10 08:06

Damg


People also ask

What is SCons command?

DESCRIPTION. The scons utility builds software (or other files) by determining which component pieces must be rebuilt and executing the necessary commands to rebuild them.

What is SCons in linux?

SCons is a computer software build tool that automatically analyzes source code file dependencies and operating system adaptation requirements from a software project description and generates final binary executables for installation on the target operating system platform.


1 Answers

SCons already changes to the directory of sub-directory SConscripts when reading them, so it looks like the problem is going to have to be fixed in the actual builder.

Once the scripts are parsed, and SCons is running the build commands, it stays in the top-level directory. Commands are then issued using path names relative to that top-level directory. The way to change this behavior is to use the chdir keyword in your Builder.

The example from the scons man page is as follows:

b = Builder(action='build < ${SOURCE.file} > ${TARGET.file}',
            chdir=1)
env = Environment(BUILDERS = {'MyBuild' : b})
env.MyBuild('sub/dir/foo.out', 'sub/dir/foo.in')

You need to specify the .file component as the use of chdir does not change the names passed to the builder, i.e. they are still relative to the top-level directory.

like image 153
richq Avatar answered Sep 28 '22 05:09

richq