@@ -46,6 +46,39 @@ def _find_framework_dir(outputs):
46
46
return prefix + ".framework"
47
47
return None
48
48
49
+ def _framework_packaging_symlink_headers (ctx , inputs , outputs ):
50
+ inputs_by_basename = {input .basename : input for input in inputs }
51
+
52
+ # If this check is true it means that multiple inputs have the same 'basename',
53
+ # an additional check is done to see if that was caused by 'action_inputs' containing
54
+ # two different paths to the same file
55
+ #
56
+ # In that case fails with a msg listing the differences found
57
+ if len (inputs_by_basename ) < len (inputs ):
58
+ inputs_by_basename_paths = [x .path for x in inputs_by_basename .values ()]
59
+ inputs_with_duplicated_basename = [x for x in inputs if not x .path in inputs_by_basename_paths ]
60
+ if len (inputs_with_duplicated_basename ) > 0 :
61
+ fail ("""
62
+ [Error] Multiple files with the same name exists.\n
63
+ See below for the list of paths found for each basename:\n
64
+ {}
65
+ """ .format ({x .basename : (x .path , inputs_by_basename [x .basename ].path ) for x in inputs_with_duplicated_basename }))
66
+
67
+ # If no error occurs create symlinks for each output with
68
+ # each input as 'target_file'
69
+ output_input_dict = {output : inputs_by_basename [output .basename ] for output in outputs }
70
+ for (output , input ) in output_input_dict .items ():
71
+ ctx .actions .symlink (output = output , target_file = input )
72
+
73
+ def _framework_packaging_symlink_modulemap (ctx , inputs , outputs ):
74
+ if len (inputs ) != 1 or len (outputs ) != 1 :
75
+ fail ("""
76
+ Multiple .modulemap files found, double check expected inputs and outputs:\n
77
+ inputs: {}\n
78
+ outputs: {}
79
+ """ .format ([x .path for x in inputs ], [x .path for x in outputs ]))
80
+ ctx .actions .symlink (output = outputs [0 ], target_file = inputs [0 ])
81
+
49
82
def _framework_packaging (ctx , action , inputs , outputs , manifest = None ):
50
83
if not inputs :
51
84
return []
@@ -63,13 +96,20 @@ def _framework_packaging(ctx, action, inputs, outputs, manifest = None):
63
96
args .add ("--action" , action )
64
97
args .add_all ("--inputs" , inputs )
65
98
args .add_all ("--outputs" , outputs )
66
- ctx .actions .run (
67
- executable = ctx .executable ._framework_packaging ,
68
- arguments = [args ],
69
- inputs = action_inputs ,
70
- outputs = outputs ,
71
- mnemonic = "PackagingFramework%s" % action .title ().replace ("_" , "" ),
72
- )
99
+
100
+ if action in ["header" , "private_header" ]:
101
+ _framework_packaging_symlink_headers (ctx , inputs , outputs )
102
+ elif action == "modulemap" :
103
+ _framework_packaging_symlink_modulemap (ctx , inputs , outputs )
104
+ else :
105
+ ctx .actions .run (
106
+ executable = ctx .executable ._framework_packaging ,
107
+ arguments = [args ],
108
+ inputs = action_inputs ,
109
+ outputs = outputs ,
110
+ mnemonic = "PackagingFramework%s" % action .title ().replace ("_" , "" ),
111
+ )
112
+
73
113
return outputs
74
114
75
115
def _add_to_dict_if_present (dict , key , value ):
0 commit comments