MCPcopy Index your code
hub / github.com/nodejs/node / build_and_check

Function build_and_check

deps/v8/tools/dev/gen-static-roots.py:115–172  ·  view source on GitHub ↗
(target)

Source from the content-addressed store, hash-verified

113
114
115def build_and_check(target):
116 print(f"-> Building: {target}")
117 # Currently the out dir always needs to be exactly 2 levels deep relative to
118 # the project root or siso fails to remote compile (see b/429331398).
119 build_prefix = f"_gen-static-roots-{target}"
120 build_dir = args.out / f"{build_prefix}-{machine_target()}.release"
121 if not build_dir.exists():
122 build_dir.mkdir(parents=True, exist_ok=True)
123 config = STATIC_ROOT_CONFIGURATIONS[target]
124
125 # Let gm create the default config
126 e = dict(os.environ)
127 e['V8_GM_OUTDIR'] = f"{args.out}"
128 e['V8_GM_BUILD_DIR_PREFIX'] = build_prefix
129 run([f"{sys.executable}", f"{GM}", f"{machine_target()}.release.gn_args"],
130 env=e)
131
132 # Patch the default config according to our needs
133 gn_args_template = config["gn_args"].copy()
134 gn_args = (build_dir / "args.gn").open("r").read().splitlines()
135
136 needs_updating = False
137 found = 0
138 for line in filter(bool, gn_args):
139 result = re.search(r"^([^ ]+) = (.+)$", line)
140 if not result or len(result.groups()) != 2:
141 print(f"Error parsing {build_dir / 'args.gn'} at line '{line}'")
142 exit(255)
143 if result.group(1) in gn_args_template:
144 found += 1
145 if result.group(2) != f"{gn_args_template[result.group(1)]}":
146 needs_updating = True
147
148 if needs_updating or found < len(gn_args_template):
149 print("# Updating gn args")
150 with (build_dir / "args.gn").open("w") as f:
151 for line in filter(bool, gn_args):
152 result = re.search(r"^([^ ]+) = (.+)$", line)
153 if result.group(1) in gn_args_template:
154 line = f"{result.group(1)} = {gn_args_template[result.group(1)]}"
155 gn_args_template.pop(result.group(1))
156 f.write(f"{line}\n")
157 for extra, val in gn_args_template.items():
158 f.write(f"{extra} = {val}\n")
159
160 # Build mksnapshot
161 run([f"{sys.executable}", f"{GM}", f"{machine_target()}.release.mksnapshot"],
162 env=e)
163
164 # Generate static roots file and check if it changed
165 filename = f"static-roots-{target}.h"
166 out_file = Path(tempfile.gettempdir()) / filename
167 run([f"{build_dir / 'mksnapshot'}", "--static-roots-src", f"{out_file}"])
168 target_file = V8_PATH / 'src' / 'roots' / filename
169 if not filecmp.cmp(out_file, target_file):
170 shutil.move(out_file, target_file)
171 return True
172 return False

Callers 1

Calls 15

machine_targetFunction · 0.85
popMethod · 0.80
cmpMethod · 0.80
runFunction · 0.70
copyMethod · 0.65
openMethod · 0.65
printFunction · 0.50
filterFunction · 0.50
exitFunction · 0.50
existsMethod · 0.45
mkdirMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…