How do explicitly create the output directory needed by an action?

Skip to first unread message

Mark Callow

May 1, 2017, 6:25:09 AM5/1/17
to gyp-developer
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 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': [
              'outputs': [
             'conditions': [
                ['GENERATOR == "xcode"', {
                  'action': [
                    'bash', '-l', '-c', 'doxygen <(doxyConfig)'
               # ... other GENERATOR's actions
              ], # action conditional
            }, # buildDoc action

Refael Ackermann

May 1, 2017, 6:37:32 AM5/1/17
to Mark Callow, gyp-developer
I have a few (unproven) ideas:
  1. Use a "copies" target first, it'll make the directory
  2. try to set the inputs == outputs ==  '<(output_dir)' for the  'makeDocOutDir' action
  3. write a small wrapper script that does the two and call it  ['python', '', '<(output_dir)', '<(doxyConfig)']


You received this message because you are subscribed to the Google Groups "gyp-developer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Mark Mentovai

May 1, 2017, 9:38:32 AM5/1/17
to Mark Callow, gyp-developer
The general (and portable) solution is to have your action invoke a script that does what you need.

On Mon, May 1, 2017 at 6:25 AM, Mark Callow <> wrote:
Reply all
Reply to author
0 new messages