OK, so c99conv operates on preprocessed source. The best we can do is to have something that regenerates all of the .c files any time any .c or .h file changes. To make this work, you’d want a target like this:
{
'target_name': 'ffmpeg_c89_convert',
'type': 'none',
'actions': [
{
'action_name': 'ffmpeg_c89_convert',
'inputs': [
'file1.c',
'file2.c',
# ...
'file9.h', # list all headers too
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/ffmpeg_c89_convert/file1.c',
'<(SHARED_INTERMEDIATE_DIR)/ffmpeg_c89_convert/file2.c',
# ...
# don't list any headers
],
'action': [
'python',
'ffmpeg_c89_convert.py',
'<(SHARED_INTERMEDIATE_DIR)/ffmpeg_c89_convert',
'<@(_inputs)',
],
},
],
},
{
'target_name': 'ffmpeg',
'type': 'static_library',
'dependencies': [
'ffmpeg_c89_convert',
],
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/ffmpeg_c89_convert/file1.c',
'<(SHARED_INTERMEDIATE_DIR)/ffmpeg_c89_convert/file2.c',
# ...
],
}
ffmpeg_c89_convert.py is a script invoked as ffmpeg_c89_convert.py <output_dir> <input_files> that performs a loop over all input_files; for each one ending in .c, it sets output_file to <output_dir>/<name>, and runs cl -P <input_file> -Fi<temp_file> followed by c99conv <temp_file> <output_file>.
The ffmpeg static library target depends on the ffmpeg_c89_convert target, so all of the files that it wants to compile (in SHARED_INTERMEDIATE_DIR) are produced by the ffmpeg_c89_convert target running the ffmpeg_c89_convert.py script.
The ffmpeg_c89_convert target lists all of the source files in ffmpeg as inputs, and all of the .c files that ffmpeg_c89_convert.py produces as outputs. If any output is missing, or if any input is newer than any output, the entire ffmpeg_c89_convert.py script runs again. It’s important to list the headers as inputs to ffmpeg_c89_convert in addition to the .c files, because any header change might affect the preprocessed output.
You take c99wrap out of the equation, so that you can deal with the “create source compileable by cl” step (cl -P and c99conv) distinctly from the “compile source with cl” step, allowing the latter to be handled as natively (and normally) as possible.
All of this can be simplified slightly by using GYP variables so that you only need to list file1.c, file2.c, and file9.h in one location in the file.