开发者

Expressing an SConscript's Own Dependencies

开发者 https://www.devze.com 2022-12-14 17:02 出处:网络
I have an SCons project set up as follows: Project/ SConstruct# \"SConscript(\'stuff/SConscript\', variant_dir = \'build\')

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 SCons开发者_如何学Ccript is copied to the build directory, but the "configuration" module is not. Ordinarily, one would express a file dependency with the Depends() function (e.g. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消