custom rules/steps and dependencies
custom rules/steps and dependencies
- Subject: custom rules/steps and dependencies
- From: Mark Lentczner <email@hidden>
- Date: Mon, 22 Mar 2004 22:17:11 -0800
This is what I'm trying to do:
I'm using Antlr to generate some lexers and parsers, and I'd like Xcode
to run Antlr as needed.
My first attempt to set this up was to add a custom build rule so that
Xcode takes a .g file, runs Antlr on it, and knows that it results in a
.cpp and two .hpp files. And Xcode happily feeds these outputs back
and compiles them with g++ and all is well... except...
Two of my .g files use the generated result of another .g file. So,
there is a dependency in order of compilation, and of updating
(changing the one .g file will require re-Antlr'ing the other two .g
files.) I can see no way to express this dependency, either in the
rule or on the files.
My second attempt was to remove the custom build rule, and add a shell
script build step to the target that runs first. This shell script
calls make, and a Makefile takes care of knowing about the dependencies
between .g files. In the build step I identify all the .g files as
inputs, and all the generated .cpp and .hpp files as outputs. Alas,
this doesn't work well: Xcode reasons that if ANY of the outputs are
newer than ANY of the inputs, then the script must be run. This is
reasonable - except that the script is building multiple things- So,
sometimes when make thinks everything is up to date, Xcode will not.
In fact it is pretty easy to get the files into this state, and Xcode
runs the script and rebuilds every time.
My third attempt has the make file touch all the targets after building
any of them (!). This is clearly sub-optimal: If any input (.g file)
changes, even though make will correctly only rebuild the .cpp and .hpp
files it has to, Xcode will end up recompiling them all. (But, at
least, next time Xcode builds, if no .g files have changed, it won't
run the make file again.)
The long and the short of it:
1) There doesn't seem to be enough power in Xcode's custom build rules
to handle new kinds of source files if they have any dependencies.
2) Xcode's shell script steps can't really be used to build more than
one thing per step, because Xcode sees the inputs and outputs as
monolithic. (Which is all it can do since it doesn't know which inputs
each output depends on.)
Do I really have to add a separate shell script stage for each of my .g
files? Or am I missing something? Or should I be filling out a
feature request form?
- Mark
Mark Lentczner
email@hidden
http://www.wheatfarm.org/
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.