[Scons-users] scons add source file suffix for env.Object()
Mats Wichmann
mats at wichmann.us
Mon Nov 4 10:30:08 EST 2024
On 11/4/24 06:58, 于 wrote:
> Hi Mats,
>
>
>
>
> Thanks for your help.
>
> I think your solution is better. So that I don't need to create many
> builders for different suffix.
>
>
> I create a new builder(such as below) to build .850, and
> "AsmBulder_ex" can build .850 also.
>
> bld = Builder( action= Action('$ASCOM', '$ASCOMSTR'), \
> suffix='.o', \
> src_suffix='.850')
>
> env.Append(BUILDERS={'AsmBulder_ex': bld})
>
>
> And could you answer me a new question? What are the differences between
> your solution and new builder.
A new builder is fine, but then you have to call it by name. If the
idea is to produce an object file, why not reuse the Object builder,
which already knows how to deal with multiple types of sources, as
described in this snippet from the manual page (in the Builder Objects
section):
The Builder function accepts the following keyword arguments:
action
The command used to build the target from the source. action may be
a string representing a template command line to execute, a list of
strings representing the command to execute with its arguments (suitable
for enclosing white space in an argument), a dictionary mapping source
file name suffixes to any combination of command line strings (if the
builder should accept multiple source file extensions), a Python
function, an Action object (see Action Objects) or a list of any of the
above.
...
Object() has been set up with a mapping as described, dispatching
different file suffixes to different command line strings, and the
method I mentioned adds to that mapping.
More information about the Scons-users
mailing list