Skip to content

Commit

Permalink
Merge pull request #160 from brentru/sync-brentru-branch
Browse files Browse the repository at this point in the history
Adds a configurable timeout for builds
  • Loading branch information
tyeth authored Sep 13, 2023
2 parents 9b8ed98 + fe15057 commit 0e6d88b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions build_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
BUILD_WARN = False
sys.argv.remove("--no_warn")

# optional timeout argument to extend build time
# for larger sketches or firmware builds
BUILD_TIMEOUT = False
if "--build_timeout" in sys.argv:
BUILD_TIMEOUT = True
popen_timeout = int(sys.argv[sys.argv.index("--build_timeout") + 1])
sys.argv.pop(sys.argv.index("--build_timeout") + 1)
sys.argv.remove("--build_timeout")

# add user bin to path!
BUILD_DIR = ''
# add user bin to path!
Expand Down Expand Up @@ -375,7 +384,10 @@ def generate_uf2(example_path):
cmd = ['python3', 'uf2conv.py', input_file, '-c', '-f', family_id, '-b', "0x0000", '-o', output_file]

proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
r = proc.wait(timeout=60)
if BUILD_TIMEOUT:
r = proc.wait(timeout=popen_timeout)
else:
r = proc.wait(timeout=60)
out = proc.stdout.read()
err = proc.stderr.read()
if r == 0 and not err:
Expand Down Expand Up @@ -461,7 +473,10 @@ def test_examples_in_folder(folderpath):
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
try:
out, err = proc.communicate(timeout=120)
if BUILD_TIMEOUT:
out, err = proc.communicate(timeout=popen_timeout)
else:
out, err = proc.communicate(timeout=120)
r = proc.returncode
except:
proc.kill()
Expand Down

0 comments on commit 0e6d88b

Please sign in to comment.