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

Method RunGNGen

deps/v8/tools/mb/mb.py:677–767  ·  view source on GitHub ↗
(self, vals, compute_grit_inputs_for_analyze=False)

Source from the content-addressed store, hash-verified

675 return vals
676
677 def RunGNGen(self, vals, compute_grit_inputs_for_analyze=False):
678 build_dir = self.args.path[0]
679
680 cmd = self.GNCmd('gen', build_dir, '--check')
681 gn_args = self.GNArgs(vals)
682 if compute_grit_inputs_for_analyze:
683 gn_args += ' compute_grit_inputs_for_analyze=true'
684
685 # Since GN hasn't run yet, the build directory may not even exist.
686 self.MaybeMakeDirectory(self.ToAbsPath(build_dir))
687
688 gn_args_path = self.ToAbsPath(build_dir, 'args.gn')
689 self.WriteFile(gn_args_path, gn_args, force_verbose=True)
690
691 swarming_targets = []
692 if getattr(self.args, 'swarming_targets_file', None):
693 # We need GN to generate the list of runtime dependencies for
694 # the compile targets listed (one per line) in the file so
695 # we can run them via swarming. We use gn_isolate_map.pyl to convert
696 # the compile targets to the matching GN labels.
697 path = self.args.swarming_targets_file
698 if not self.Exists(path):
699 self.WriteFailureAndRaise('"%s" does not exist' % path,
700 output_path=None)
701 contents = self.ReadFile(path)
702 swarming_targets = set(contents.splitlines())
703
704 isolate_map = self.ReadIsolateMap()
705 self.RemovePossiblyStaleRuntimeDepsFiles(vals, swarming_targets,
706 isolate_map, build_dir)
707 err, labels = self.MapTargetsToLabels(isolate_map, swarming_targets)
708 if err:
709 raise MBErr(err)
710
711 gn_runtime_deps_path = self.ToAbsPath(build_dir, 'runtime_deps')
712 self.WriteFile(gn_runtime_deps_path, '\n'.join(labels) + '\n')
713 cmd.append('--runtime-deps-list-file=%s' % gn_runtime_deps_path)
714
715 ret, output, _ = self.Run(cmd)
716 if ret:
717 if self.args.json_output:
718 # write errors to json.output
719 self.WriteJSON({'output': output}, self.args.json_output)
720 # If `gn gen` failed, we should exit early rather than trying to
721 # generate isolates. Run() will have already logged any error output.
722 self.Print('GN gen failed: %d' % ret)
723 return ret
724
725 android = 'target_os="android"' in vals['gn_args']
726 for target in swarming_targets:
727 if android:
728 # Android targets may be either android_apk or executable. The former
729 # will result in runtime_deps associated with the stamp file, while the
730 # latter will result in runtime_deps associated with the executable.
731 label = isolate_map[target]['label']
732 runtime_deps_targets = [
733 target + '.runtime_deps',
734 'obj/%s.runtime_deps' % label.replace(':', '/'),

Callers 3

CmdGenMethod · 0.95
GetConfigMethod · 0.95
RunGNAnalyzeMethod · 0.95

Calls 15

GNCmdMethod · 0.95
GNArgsMethod · 0.95
MaybeMakeDirectoryMethod · 0.95
ToAbsPathMethod · 0.95
WriteFileMethod · 0.95
ExistsMethod · 0.95
WriteFailureAndRaiseMethod · 0.95
ReadFileMethod · 0.95
ReadIsolateMapMethod · 0.95
MapTargetsToLabelsMethod · 0.95
RunMethod · 0.95

Tested by

no test coverage detected