MCPcopy Create free account
hub / github.com/nodejs/node / WriteActions

Method WriteActions

tools/gyp/pylib/gyp/generator/android.py:252–356  ·  view source on GitHub ↗

Write Makefile code for any 'actions' from the gyp input. extra_sources: a list that will be filled in with newly generated source files, if any extra_outputs: a list that will be filled in with any outputs of these actions (used to make

(self, actions, extra_sources, extra_outputs)

Source from the content-addressed store, hash-verified

250 return self.android_module
251
252 def WriteActions(self, actions, extra_sources, extra_outputs):
253 """Write Makefile code for any 'actions' from the gyp input.
254
255 extra_sources: a list that will be filled in with newly generated source
256 files, if any
257 extra_outputs: a list that will be filled in with any outputs of these
258 actions (used to make other pieces dependent on these
259 actions)
260 """
261 for action in actions:
262 name = make.StringToMakefileVariable(
263 "{}_{}".format(self.relative_target, action["action_name"])
264 )
265 self.WriteLn('### Rules for action "%s":' % action["action_name"])
266 inputs = action["inputs"]
267 outputs = action["outputs"]
268
269 # Build up a list of outputs.
270 # Collect the output dirs we'll need.
271 dirs = set()
272 for out in outputs:
273 if not out.startswith("$"):
274 print(
275 'WARNING: Action for target "%s" writes output to local path '
276 '"%s".' % (self.target, out)
277 )
278 dir = os.path.split(out)[0]
279 if dir:
280 dirs.add(dir)
281 if int(action.get("process_outputs_as_sources", False)):
282 extra_sources += outputs
283
284 # Prepare the actual command.
285 command = gyp.common.EncodePOSIXShellList(action["action"])
286 if "message" in action:
287 quiet_cmd = "Gyp action: %s ($@)" % action["message"]
288 else:
289 quiet_cmd = "Gyp action: %s ($@)" % name
290 if len(dirs) > 0:
291 command = "mkdir -p %s" % " ".join(dirs) + "; " + command
292
293 cd_action = "cd $(gyp_local_path)/%s; " % self.path
294 command = cd_action + command
295
296 # The makefile rules are all relative to the top dir, but the gyp actions
297 # are defined relative to their containing dir. This replaces the gyp_*
298 # variables for the action rule with an absolute version so that the
299 # output goes in the right place.
300 # Only write the gyp_* rules for the "primary" output (:1);
301 # it's superfluous for the "extra outputs", and this avoids accidentally
302 # writing duplicate dummy rules for those outputs.
303 main_output = make.QuoteSpaces(self.LocalPathify(outputs[0]))
304 self.WriteLn("%s: gyp_local_path := $(LOCAL_PATH)" % main_output)
305 self.WriteLn("%s: gyp_var_prefix := $(GYP_VAR_PREFIX)" % main_output)
306 self.WriteLn(
307 "%s: gyp_intermediate_dir := "
308 "$(abspath $(gyp_intermediate_dir))" % main_output
309 )

Callers 1

WriteMethod · 0.95

Calls 11

WriteLnMethod · 0.95
LocalPathifyMethod · 0.95
intFunction · 0.85
formatMethod · 0.65
addMethod · 0.65
getMethod · 0.65
setFunction · 0.50
printFunction · 0.50
mapFunction · 0.50
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected