[Scons-users] Custom build flags per FileNode using AddPreAction

Ivan Kravets me at ikravets.com
Wed Apr 17 07:14:32 EDT 2019


Hi,

This is Ivan from PlatformIO.Org. Sometimes our users ask if it is possible to customize build flags per a source file which was previously added to a build process via Program() or StaticLibrary().

SCons has a  useful AddPreAction mechanism and it works. For example,

```
def test(env, source, target):
    print(type(source[0]))

env.AddPreAction("$BUILD_DIR/SomeLibrary/foo.cpp.o", test)
```

It will print:
```
<class 'SCons.Node.FS.File'>
```

So, it is possible to customize "foo.cpp" with extra flags (for example, some macro, etc) having `SCons.Node.FS.File`?

P.S: Similar what we can do with env.Object().

Thanks in advance!

Regards, Ivan.


More information about the Scons-users mailing list