[Scons-users] src_suffix getings ignored
Mats Wichmann
mats at wichmann.us
Sun May 22 09:39:52 EDT 2022
On Sat, May 21, 2022, at 11:50, Mats Wichmann wrote:
>
> I think you need to plumb your builders into the CFile builder's
> mechanism, so SCons's internal plumbing knows it's another way to create
> a .c file (with a .h as an additional file, which means you need an
> emitter as well to inject the .h file.
To elaborate a little more here, the kind of thing you're doing works
when you're writing a builder which transforms one file type to another.
But in your example, you're not calling that builder, you're calling an
existing builder - Object in the sample, CFile I mentioned if you wanted
to generate the .c. Those builders are a special type called a
composite builder, an instance of a proxy class which holds a dictionary
mapping the suffixes that builder will know about to what to do. Since
SCons looks in the dictionary of a composit builder to find the rule for
the suffix of the source file, you have to get added to those
dictionaries, or you'll get exactly the kind of error you're getting.
If you print out the BUILDERS entry in your environment you can see
which existing builders are of this type. Here's a snip from mine (I
hope this doesn't get mangled, I'm having to use an alternate email
client temporarily due to some crash problems)
'CFile': <SCons.Builder.CompositeBuilder object at 0x7f5f4bb792e0>,
'CXXFile': <SCons.Builder.CompositeBuilder object at 0x7f5f4bb79460>,
'DVI': <SCons.Builder.CompositeBuilder object at 0x7f5f4bb80ca0>,
'JavaFile': <SCons.Builder.CompositeBuilder object at 0x7f5f4bb79b80>,
'Object': <SCons.Builder.CompositeBuilder object at 0x7f5f4bbe57c0>,
'PDF': <SCons.Builder.CompositeBuilder object at 0x7f5f4bb80190>,
'SharedObject': <SCons.Builder.CompositeBuilder object at
0x7f5f4bbe5970>,
'StaticObject': <SCons.Builder.CompositeBuilder object at
0x7f5f4bbe57c0>,
This, unhelpfully, isn't documented at the manpage level. There's a
description in a source code comment:
===
There is also a proxy that looks like a Builder:
CompositeBuilder
This proxies for a Builder with an action that is actually a
dictionary that knows how to map file suffixes to a specific
action. This is so that we can invoke different actions
(compilers, compile options) for different flavors of source
files.
===
Additionally:
===
Builders and their proxies have the following public interface methods
used by other modules:
- __call__()
THE public interface. Calling a Builder object (with the
use of internal helper methods) sets up the target and source
dependencies, appropriate mapping to a specific action, and the
environment manipulation necessary for overridden construction
variable. This also takes care of warning about possible mistakes
in keyword arguments.
- add_emitter()
Adds an emitter for a specific file suffix, used by some Tool
modules to specify that (for example) a yacc invocation on a .y
can create a .h *and* a .c file.
- add_action()
Adds an action for a specific file suffix, heavily used by
Tool modules to add their specific action(s) for turning
a source file into an object file to the global static
and shared object file Builders.
===
More information about the Scons-users
mailing list