简体   繁体   中英

Expressing an SConscript's Own Dependencies

I have an SCons project set up as follows:

Project/
    SConstruct  # "SConscript('stuff/SConscript', variant_dir = 'build')
    stuff/
        SConscript # "import configuration"
        configuration/
            __init__.py
            Thing.py

When building, the SConscript is copied to the build directory, but the "configuration" module is not. Ordinarily, one would express a file dependency with the Depends() function (eg Depends(program, object_files) ). In this case, though, the SConscript file is itself the "target" of the dependency.

How do I express this in my SConscript?

I have two workarounds for you. I call them workarounds because they don't express the dependency in the SConscript.

  1. Do the 'import configuration' from your SConstruct (you'll need to edit sys.path)

  2. In stuff/SConscript, add the source directory to sys.path:

    
    import sys
    sys.path += ['%s/stuff' % (Dir('#').abspath)]

    import configuration

Firstly, do you really need dependence on your SCons script source files? How often do they change, and if they change is it really so onerous to require that your user does a clean build if they muck with the SConscript.py configuration file(s).

If you do require this, are you currently not seeing this? I've found SCons to be rather good at knowing if and how the SConscript.py files have changed. Specifically, if you have any user defined builders with custom action python functions? For my EDA build flow which has scads of user-defined python functions which call the myriad of proprietary EDA tools, if I change any SConstruct.py file, all the results of my custom python builders are assumed to be invalid (must to my chagrin, often). FYI, I'm using release 1.2.0.d20090223.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM