[Scons-users] caching build parameters

Jason Kenny dragon512 at live.com
Fri Jun 10 10:34:38 EDT 2016


Hi,

You should look at the Variables object in SCons. There is an ability to
have it write out options to a file that you can then read back in on the
next run. There is not really a need to have configure stage, as that is
about generating a build files. SCons has a different solution for that.
FYI, One of the older devs that I have not heard from for years was trying
to make a AutoScons project thing which would be more like what you are
suggesting... as a 1:1 mapping between SCons and Make based tools. 

Here is text from the Man page to get you started. You should be able to
find various examples of how to do this online

...
Command-Line Construction Variables

Often when building software, some variables must be specified at build
time. For example, libraries needed for the build may be in non-standard
locations, or site-specific compiler options may need to be passed to the
compiler. scons provides a Variables object to support overriding
construction variables on the command line:
$ scons VARIABLE=foo


The variable values can also be specified in a text-based SConscript file.
To create a Variables object, call the Variables() function:


Variables([files], [args])


This creates a Variables object that will read construction variables from
the file or list of filenames specified in files. If no files are specified,
or the files argument is None, then no files will be read. The optional
argument args is a dictionary of values that will override anything read
from the specified files; it is primarily intended to be passed the
ARGUMENTS dictionary that holds variables specified on the command line.
Example:
vars = Variables('custom.py')
vars = Variables('overrides.py', ARGUMENTS)
vars = Variables(None, {FOO:'expansion', BAR:7})


Variables objects have the following methods:
...


Jason

-----Original Message-----
From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of Stefan
Seefeld
Sent: Friday, June 10, 2016 8:58 AM
To: SCons users mailing list <scons-users at scons.org>
Subject: [Scons-users] caching build parameters

Hello,


I'm working on a project whose build process is highly configurable.
Having used the GNU autotools a lot in the past, I'm very used to a process
where all the build parameters are captured during a 'configure'
step, so any subsequent `make` invocation would pick them up from generated
makefiles and headers.


Now I'm trying to get that functionality with SCons. My command-line
contains a mix of variables and options:

    scons --python=... --boost-prefix=... variant=release arch=x86_64


and I would like to separate the 'configure' step from subsequent 'build',
'test', etc. targets, so I could run


    scons config --python=... --boost-prefix=... variant=release arch=x86_64

    scons

    scons check

    scons install


Some of the above appears to be supported using


    vars = Variables('config.py', ARGUMENTS)

    ...

    vars.Save('config.py', env)


but not all: this only remembers "variables", not "options". In addition,
for variables to be remembered, I need to explicitly 'Add'
them, which makes them public (i.e., `scons -h` will report them).

This raises two questions:

1) is there a way to cache both variables as well as options ?

2) is there a way to distinguish 'public' variables from those that are
computed as part of the configure process, so `scons -h` doesn't advertise
them ?


Thanks,

        Stefan


-- 

      ...ich hab' noch einen Koffer in Berlin...

_______________________________________________
Scons-users mailing list
Scons-users at scons.org
https://pairlist4.pair.net/mailman/listinfo/scons-users


More information about the Scons-users mailing list