Reputation: 29178
I would like an alternative to Make where I can easily use some Python code to generate some intermediate files.
I bumped into Scons that claims to be similar to Make. I would like to translate this kind of Makefile into Scons where the calls to Python will be done into Scons itself.
.PHONY all clean mrproper
all: out
A=$(wildcard *.a)
B=$(A:.b=.a)
C=$(B:.c=.b)
D=$(wildcard *.d)
C=$(D:.c=.d)
-include $(wildcard *.dep)
*.b : *.a
python -mfoo a2b $< -o $@ -M [email protected]
*.c : *.b
python -mfoo b2c $< -o $@
*.e : *.d
python -mfoo d2e $< -o $@
out: $(E) $(C)
python -mfoo out $^ -o $@
clean:
$(RM) $(B) $(C) $(E)
mrproper: clean
$(RM) out *.dep
Is it possible to do it so? I am not interested in a working solution, just the build blocks I need to start.
What I am missing is that Scons offers helpers such as
env.Program(target = 'helloworld', source = ["helloworld.c"])
Which works with standard extensions (*.c
, *.s
, ...). Unfortunately I don't want to make a program, and I want to specify the recipe. Said differently I am looking for something more like this:
env.append(env.Recipe(target='%.b', deps=['out/%.a', 'out'], builder=foo_a2b))
Upvotes: 3
Views: 191
Reputation: 4052
This sounds like you want to write/define your own Builder, speaking in SCons parlance. Please have a look at our ToolsForFools Guide which tries to explain how you can teach new "build recipes" to SCons. Note, how you can always specify a true Python callable (e.g. a function) instead of a mere string for an Action. You may also want to check out the MAN page (especially the section about 'Action Objects') and the User Guide for a better and more exhaustive introduction to this build system.
Finally, feel free to join our User mailing list [email protected] and ask follow-up questions there. Our community is always eager to help...
Upvotes: 2