I have an action for which I need to explicitly create the output directory. My first thought was to make the action something like
'action': [ 'mkdir', '-p', '<(output_dir)', '&&', 'build_command' ]
but the GYP generators put comments around the && and any other connectors for shell commands so they don't work. The above action results just in running the mkdir part. build_command is not run.
So next I tried adding a separate preceding action that would create the directory as shown below. With this I get "assert group_ref.__class__ == PBXGroup" which is at around line 1301 in xcodeproj_file.py. This happens because the first action adds <(output_dir) as a PBXFileReference. When xcodeproj_file is adding the second action, it is expecting to find either nothing or a PBXGroup with that same path to use as its output and asserts when it finds a PBXFileReference instead.
I have temporarily worked around this in the makeDocOutDir action by using "'outputs': [ ],". This means the action will be run even if the directory exists.
I surely can't be the first project that has needed to explicitly create an output directory. How can I do it properly?
========== An actions[] that triggers the assert ============
'actions': [
{
'action_name': 'makeDocOutDir',
'message': 'Making output dir for tools docs',
'inputs': [ '../<(doxyConfig)' ],
#'process_outputs_as_sources': 1,
'outputs': [ '<(output_dir)' ],
'action': [ 'mkdir', '-p', '<(output_dir)', ],
},
{
'action_name': 'buildDoc',
'message': 'Generating tools documentation with Doxygen',
'inputs': [
'../<(doxyConfig)',
'toktx.cpp',
],
'outputs': [
'<(output_dir)/html',
'<(output_dir)/latex',
'<(output_dir)/man',
],
'conditions': [
['GENERATOR == "xcode"', {
'action': [
'bash', '-l', '-c', 'doxygen <(doxyConfig)'
],
# ... other GENERATOR's actions
}],
], # action conditional
}, # buildDoc action