Always output a tarball from cc_binary to simplify logic. (#936)

* Always output a tarball from cc_binary to simplify logic. This will change the result of --config=wasm builds that were previously outputting a single file.

* better to use early return here

* Always output a tarball from cc_binary to simplify logic. This will change the result of --config=wasm builds that were previously outputting a single file.

* better to use early return here

Co-authored-by: Mitch Foley <mitchfoley@chromium.org>
This commit is contained in:
walkingeyerobot
2021-12-01 18:26:16 -05:00
committed by GitHub
parent 846f683bea
commit c7305b4045
2 changed files with 10 additions and 31 deletions

View File

@@ -153,17 +153,14 @@ if os.path.exists(wasm_base + '.debug.wasm') and os.path.exists(wasm_base):
wasm_base,
'--add-section=external_debug_info=debugsection.tmp'])
# If we have more than one output file then create tarball
if len(files) > 1:
cmd = ['tar', 'cf', 'tmp.tar'] + files
subprocess.check_call(cmd, cwd=outdir)
os.rename(os.path.join(outdir, 'tmp.tar'), output_file)
elif len(files) == 1:
# Otherwise, if only have a single output than move it to the expected name
if files[0] != os.path.basename(output_file):
os.rename(os.path.join(outdir, files[0]), output_file)
else:
# Make sure we have at least one output file.
if not len(files):
print('emcc.py did not appear to output any known files!')
sys.exit(1)
# cc_binary must output exactly one file; put all the output files in a tarball.
cmd = ['tar', 'cf', 'tmp.tar'] + files
subprocess.check_call(cmd, cwd=outdir)
os.rename(os.path.join(outdir, 'tmp.tar'), output_file)
sys.exit(0)