build.py: remove retry logic (#24986)

pull/83/head
Willem Melching 3 years ago committed by GitHub
parent 42d51a1b95
commit 712445c531
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 101
      selfdrive/manager/build.py

@ -1,8 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import subprocess import subprocess
import sys
import time
import textwrap import textwrap
from pathlib import Path from pathlib import Path
@ -28,62 +26,49 @@ def build(spinner: Spinner, dirty: bool = False) -> None:
nproc = os.cpu_count() nproc = os.cpu_count()
j_flag = "" if nproc is None else f"-j{nproc - 1}" j_flag = "" if nproc is None else f"-j{nproc - 1}"
for retry in [True, False]: scons: subprocess.Popen = subprocess.Popen(["scons", j_flag, "--cache-populate"], cwd=BASEDIR, env=env, stderr=subprocess.PIPE)
scons: subprocess.Popen = subprocess.Popen(["scons", j_flag, "--cache-populate"], cwd=BASEDIR, env=env, stderr=subprocess.PIPE) assert scons.stderr is not None
assert scons.stderr is not None
compile_output = []
compile_output = []
# Read progress from stderr and update spinner
# Read progress from stderr and update spinner while scons.poll() is None:
while scons.poll() is None: try:
try: line = scons.stderr.readline()
line = scons.stderr.readline() if line is None:
if line is None: continue
continue line = line.rstrip()
line = line.rstrip()
prefix = b'progress: '
prefix = b'progress: ' if line.startswith(prefix):
if line.startswith(prefix): i = int(line[len(prefix):])
i = int(line[len(prefix):]) spinner.update_progress(MAX_BUILD_PROGRESS * min(1., i / TOTAL_SCONS_NODES), 100.)
spinner.update_progress(MAX_BUILD_PROGRESS * min(1., i / TOTAL_SCONS_NODES), 100.) elif len(line):
elif len(line): compile_output.append(line)
compile_output.append(line) print(line.decode('utf8', 'replace'))
print(line.decode('utf8', 'replace')) except Exception:
except Exception: pass
pass
if scons.returncode != 0:
if scons.returncode != 0: # Read remaining output
# Read remaining output r = scons.stderr.read().split(b'\n')
r = scons.stderr.read().split(b'\n') compile_output += r
compile_output += r
# Build failed log errors
if retry and (not dirty): errors = [line.decode('utf8', 'replace') for line in compile_output
if not os.getenv("CI"): if any(err in line for err in [b'error: ', b'not found, needed by target'])]
print("scons build failed, cleaning in") error_s = "\n".join(errors)
for i in range(3, -1, -1): add_file_handler(cloudlog)
print("....%d" % i) cloudlog.error("scons build failed\n" + error_s)
time.sleep(1)
subprocess.check_call(["scons", "-c"], cwd=BASEDIR, env=env) # Show TextWindow
else: spinner.close()
print("scons build failed after retry") if not os.getenv("CI"):
sys.exit(1) error_s = "\n \n".join("\n".join(textwrap.wrap(e, 65)) for e in errors)
else: with TextWindow("openpilot failed to build\n \n" + error_s) as t:
# Build failed log errors t.wait_for_exit()
errors = [line.decode('utf8', 'replace') for line in compile_output exit(1)
if any(err in line for err in [b'error: ', b'not found, needed by target'])]
error_s = "\n".join(errors)
add_file_handler(cloudlog)
cloudlog.error("scons build failed\n" + error_s)
# Show TextWindow
spinner.close()
if not os.getenv("CI"):
error_s = "\n \n".join("\n".join(textwrap.wrap(e, 65)) for e in errors)
with TextWindow("openpilot failed to build\n \n" + error_s) as t:
t.wait_for_exit()
exit(1)
else:
break
# enforce max cache size # enforce max cache size
cache_files = [f for f in CACHE_DIR.rglob('*') if f.is_file()] cache_files = [f for f in CACHE_DIR.rglob('*') if f.is_file()]

Loading…
Cancel
Save