On Aug 14, 2007, at 3:29 PM, Yves Poissant wrote: Is there a way, in the project's build configuration, to generate intermediate preprocessor files and save them? I currently use the contextual menu "Preprocess" option to generate the .i file but I would like to get them generated and saved for all the files in a library. Is it possible to specify that in the build configuration?
The general technique is:
1) Project > Edit Active Target 2) Click "Rules" tab 3) Click "+" to create a new rule 4) Change the "Process" popup to "C Source Files" and the "using:" popup to "Custom script:" 5) Set the script to gcc -E ${INPUT_FILE_PATH} > ${TARGET_TEMP_DIR}/${INPUT_FILE_BASE}.i and the "with output files:" to ${TARGET_TEMP_DIR}/${INPUT_FILE_BASE}.i 6) Close the Inspector and build
Your intermediates folder should now be full of .i files instead of .o files.
Note that in order to get your project to preprocess correctly you may need to pass a lot of the other Xcode build settings on the gcc command line. They'll be listed in the full build transcript. For example, if you're compiling against the SDK, you'll want the headers from the SDK while preprocessing, so you'd pass -isysroot ${SDKROOT} too.
Note that this doesn't actually build your build product. You'd have to add the -o ${INPUT_FILE_BASE}.o as well and really make sure that you have all bases covered. It's probably best to define the rule, do a build to get the .i files, then undefine it form normal use, or to set up another target (rules are not per-configuration, they're per-target).
Chris |