[Scons-users] How to set disable duplicate=0 for all SCons build variants without repeating the option multiple times?

Ciro Santilli ciro.santilli at gmail.com
Fri Dec 7 07:21:38 EST 2018


https://stackoverflow.com/questions/53656787/how-to-set-disable-duplicate-0-for-all-scons-build-variants-without-repeating-th

I am dealing with a project that has many variant dirs created with
`SConscript(variant_dir=)`.

I want to make `scons` stop copying my `.c` files into the build directories.

I know that I can do that if I pass `duplicate=0` for each of those
calls as documented at:
https://scons.org/doc/2.4.1/HTML/scons-user.html#idp1378843980

But is there an easier way to make `duplicate=0` automatically take
effect for all variant dirs?

For example, in a simplified example:

    env = Environment()
    objects = [env.Object('main.c')]
    build_dir = 'build'
    objects.extend(env.SConscript(
        os.path.join('lib', 'SConscript'),
        variant_dir=os.path.join(build_dir, 'lib'),
    ))
    objects.extend(env.SConscript(
        os.path.join('lib2', 'SConscript'),
        variant_dir=os.path.join(build_dir, 'lib2'),
    ))
    env.Program('main.out', objects)

I would like to do something like:

    env = Environment(duplicate=0)

I would not however like to pass it as a variable everywhere, since
people will likely forget to pass it sooner or later:

    env = Environment()
    objects = [env.Object('main.c')]
    build_dir = 'build'
    duplicate = 0
    objects.extend(env.SConscript(
        os.path.join('lib', 'SConscript'),
        variant_dir=os.path.join(build_dir, 'lib'),
        duplicate=duplicate
    ))
    objects.extend(env.SConscript(
        os.path.join('lib2', 'SConscript'),
        variant_dir=os.path.join(build_dir, 'lib2'),
        duplicate=duplicate
    ))
    env.Program('main.out', objects)

This would be analogous to `--duplicate soft-copy`, which affects all
variant dirs in one go.

If only I had a `--duplicate none` I could also set it by default with
SetOption from my script and all would be fine.


More information about the Scons-users mailing list