Dependencies on custom-rule output not working
Dependencies on custom-rule output not working
- Subject: Dependencies on custom-rule output not working
- From: Ethan Tira-Thompson <email@hidden>
- Date: Thu, 10 Dec 2009 15:54:49 -0500
For my project we have a script which converts a finite state machine (FSM) shorthand into C++ code, which is then compiled. The C++ output files may be .cc files for direct compilation, or .h header files for inclusion by other source files. A particularly complicated FSM may have both, where the Foo.cc.fsm has #includes for the public parts stored in the Foo.h.fsm.
This works well with a Makefile: I have a rule for converting *.fsm files to $BUILD/*, and then I add a -I$BUILD flag to the compiler so other #includes will pick up the converted .h files. Then I just I do the gcc -MM thing to maintain .d dependency files for make.
However, in Xcode, this does not seem to work properly.
For one thing, when I add a foo.h.fsm to the Xcode project, it refuses to add it to a target. I have to 'get info' and change the type to sourcecode.cpp (but not sourcecode.cpp.h or it won't consider it for being part of a target).
Then I have a custom rule in the target which specifies source files matching *.fsm run my script, with output $(DERIVED_FILES_DIR)/$(INPUT_FILE_DIR)/$(INPUT_FILE_BASE). There is a matching -I $(DERIVED_FILES_DIR)/$(PROJECT_DIR) so #includes find the produced .h files.
Where this fails is that Xcode does not seem to track dependencies on or between these generated source files. In particular, it always builds all "normal" source files first, and then processes the custom rules. Thus for the first build all generated headers are missing and I get lots of errors, but if I let it continue through it will eventually generate these files, and then the *second* build it will build correctly. Similar problems arise if I make modifications to a .h.fsm, because the changes won't hit associated source files until the *next* build.
This indicates Xcode does track some dependencies, because it does rebuild dependent files on the next pass even though they have not been modified directly. The problem is Xcode is not being smart about using the output field of the custom rule specification to track dependencies of other files.
It would be a decent workaround if I could simply make Xcode run the custom rules at the *beginning* of the build instead of the end. This seems like a very error prone default configuration, and I haven't been able to figure out how to override it.
Thoughts? Full fledged bug or am I missing something?
Xcode 3.2.1 on 10.6
Thanks,
-Ethan
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden