SCons: Builder with $ TARGET not specified creates a builder output in src dir instead of dir

I have a builder that looks like this:

sFooBuilder = Builder( action = os.path.join(rBuildPath, 'foo_binary') + ' $SOURCE',        
                        suffix = '.c',
                        src_suffix = '.foo'
        )

Since the binary code that I rely on does not accept the $ TARGET argument and creates a runtime error, otherwise I will only specify the $ SOURCE argument. It happens that the output file of the binary file is placed in the src directory instead of the dir option. However, SCons expects an output file in the options directory.

Each time you call scons, the build target above is executed due to the following:

scons: building `variant_dir/foo.c' because it doesn't exist

And just to copy the file to the dir version using Command Builder does not work either

scons: warning: Two different environments were specified for target foo.c,
        but they appear to have the same action: foo_binary $SOURCE
File "sconscript", 
scons: *** Multiple ways to build the same target were specified for: foo.c  foo.foo'] and from ['foo.c'])
File "/sconscript",

: ?
- ( ), ? , , .

!

+3
1

foo_binary input.foo output.c , ? ? ? env.FooBuilder('foo.c', 'foo.foo').

dir, scons , _dir/foo.c. , , . , , , scons "foo.c", .

, - foo_binary , . , , , , , . . :

sFooBuilder = Builder(action=[
            os.path.join(rBuildPath, 'foo_binary') + ' $SOURCE',
            Move('$TARGET.dir', '$TARGET.srcpath')],
            suffix = '.c', src_suffix = '.foo' )

2 :

foo_binary foo.foo
mv foo.c variant_dir

, , ( foo.c ), .

, . SCons .

, (foo.foo.in foo.foo dir, foo.c), .

+2

Source: https://habr.com/ru/post/1774818/


All Articles