Search code examples
pythonoperating-systemscons

How scons tell different OS adn build different SConscript accordingly?


I've got several directories of source code, some for linux, some for mac, etc. How can I specify inside my SConstruct, that under linux, please execute:

SConscript(dirs=['linux'],     variant_dir='linux/build',     duplicate=0);

And under other operating system, execute other SConscript command?

Is there a convenient way to specify this?


Solution

  • @jszakmeiter's comment it good.

    Another way might be to match the directory name of the code with the value for sys.platform and then use:

    SConscript(dirs=[sys.platform],     variant_dir='%s/build'%sys.platform,     duplicate=0);
    

    As a side note, I usually advise having the variant dirs as siblings to and not children of the source directories.

    SConscript(dirs=[sys.platform],     variant_dir='build/%s'%sys.platform,     duplicate=0);