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

Method WriteRules

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

Write Makefile code for any 'rules' 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 rules (used to make oth

(self, rules, extra_sources, extra_outputs)

Source from the content-addressed store, hash-verified

356 self.WriteLn()
357
358 def WriteRules(self, rules, extra_sources, extra_outputs):
359 """Write Makefile code for any 'rules' from the gyp input.
360
361 extra_sources: a list that will be filled in with newly generated source
362 files, if any
363 extra_outputs: a list that will be filled in with any outputs of these
364 rules (used to make other pieces dependent on these rules)
365 """
366 if len(rules) == 0:
367 return
368
369 for rule in rules:
370 if len(rule.get("rule_sources", [])) == 0:
371 continue
372 name = make.StringToMakefileVariable(
373 "{}_{}".format(self.relative_target, rule["rule_name"])
374 )
375 self.WriteLn('\n### Generated for rule "%s":' % name)
376 self.WriteLn('# "%s":' % rule)
377
378 inputs = rule.get("inputs")
379 for rule_source in rule.get("rule_sources", []):
380 (rule_source_dirname, rule_source_basename) = os.path.split(rule_source)
381 (rule_source_root, _rule_source_ext) = os.path.splitext(
382 rule_source_basename
383 )
384
385 outputs = [
386 self.ExpandInputRoot(out, rule_source_root, rule_source_dirname)
387 for out in rule["outputs"]
388 ]
389
390 dirs = set()
391 for out in outputs:
392 if not out.startswith("$"):
393 print(
394 "WARNING: Rule for target %s writes output to local path %s"
395 % (self.target, out)
396 )
397 dir = os.path.dirname(out)
398 if dir:
399 dirs.add(dir)
400 extra_outputs += outputs
401 if int(rule.get("process_outputs_as_sources", False)):
402 extra_sources.extend(outputs)
403
404 components = []
405 for component in rule["action"]:
406 component = self.ExpandInputRoot(
407 component, rule_source_root, rule_source_dirname
408 )
409 if "$(RULE_SOURCES)" in component:
410 component = component.replace("$(RULE_SOURCES)", rule_source)
411 components.append(component)
412
413 command = gyp.common.EncodePOSIXShellList(components)
414 cd_action = "cd $(gyp_local_path)/%s; " % self.path
415 command = cd_action + command

Callers 1

WriteMethod · 0.95

Calls 14

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

Tested by

no test coverage detected