mirror of
https://github.com/fluencelabs/musl
synced 2025-04-24 23:02:14 +00:00
[WebAssembly] Keep itermediate files (#31)
In particular we need to keep the generated headers around so they can be installed later. This behavior mimics more closely what the musl Makefile does now that it supports out-of-tree building (i.e. it puts all the generated files under obj)
This commit is contained in:
parent
8977c9eba7
commit
14ffeeb5bb
51
libc.py
51
libc.py
@ -209,34 +209,26 @@ class AsmCompiler(Compiler):
|
|||||||
cwd=self.tmpdir)
|
cwd=self.tmpdir)
|
||||||
|
|
||||||
|
|
||||||
def run(clang_dir, binaryen_dir, sexpr_wasm, musl, arch, out, save_temps,
|
def run(clang_dir, binaryen_dir, sexpr_wasm, musl, arch, out, compile_to_wasm):
|
||||||
compile_to_wasm):
|
objdir = os.path.join(os.path.dirname(out), 'obj')
|
||||||
if save_temps:
|
if os.path.isdir(objdir):
|
||||||
tmpdir = os.path.join(musl, 'obj')
|
shutil.rmtree(objdir)
|
||||||
if os.path.isdir(tmpdir):
|
os.mkdir(objdir)
|
||||||
shutil.rmtree(tmpdir)
|
|
||||||
os.mkdir(tmpdir)
|
|
||||||
else:
|
|
||||||
tmpdir = tempfile.mkdtemp()
|
|
||||||
|
|
||||||
try:
|
create_version(musl, objdir)
|
||||||
create_version(musl, tmpdir)
|
build_headers(musl, arch, objdir)
|
||||||
build_headers(musl, arch, tmpdir)
|
sources = musl_sources(musl, include_weak=compile_to_wasm)
|
||||||
sources = musl_sources(musl, include_weak=compile_to_wasm)
|
if compile_to_wasm:
|
||||||
if compile_to_wasm:
|
compiler = ObjCompiler(out, clang_dir, musl, arch, objdir)
|
||||||
compiler = ObjCompiler(out, clang_dir, musl, arch, tmpdir)
|
else:
|
||||||
else:
|
compiler = AsmCompiler(out, clang_dir, musl, arch, objdir, binaryen_dir,
|
||||||
compiler = AsmCompiler(out, clang_dir, musl, arch, tmpdir, binaryen_dir,
|
sexpr_wasm)
|
||||||
sexpr_wasm)
|
compiler.compile(sources)
|
||||||
compiler.compile(sources)
|
compiler.binary()
|
||||||
compiler.binary()
|
if compile_to_wasm:
|
||||||
if compile_to_wasm:
|
compiler.compile([os.path.join(musl, 'crt', 'crt1.c')])
|
||||||
compiler.compile([os.path.join(musl, 'crt', 'crt1.c')])
|
shutil.copy(os.path.join(objdir, compiler.compiled[0]),
|
||||||
shutil.copy(os.path.join(tmpdir, compiler.compiled[0]),
|
os.path.dirname(out))
|
||||||
os.path.dirname(out))
|
|
||||||
finally:
|
|
||||||
if not save_temps:
|
|
||||||
shutil.rmtree(tmpdir)
|
|
||||||
|
|
||||||
|
|
||||||
def getargs():
|
def getargs():
|
||||||
@ -254,8 +246,6 @@ def getargs():
|
|||||||
parser.add_argument('--out', '-o', type=str,
|
parser.add_argument('--out', '-o', type=str,
|
||||||
default=os.path.join(os.getcwd(), 'musl.wast'),
|
default=os.path.join(os.getcwd(), 'musl.wast'),
|
||||||
help='Output file')
|
help='Output file')
|
||||||
parser.add_argument('--save-temps', default=False, action='store_true',
|
|
||||||
help='Save temporary files')
|
|
||||||
parser.add_argument('--verbose', default=False, action='store_true',
|
parser.add_argument('--verbose', default=False, action='store_true',
|
||||||
help='Verbose')
|
help='Verbose')
|
||||||
parser.add_argument('--compile-to-wasm', default=False, action='store_true',
|
parser.add_argument('--compile-to-wasm', default=False, action='store_true',
|
||||||
@ -269,8 +259,7 @@ def main():
|
|||||||
if args.verbose:
|
if args.verbose:
|
||||||
verbose = True
|
verbose = True
|
||||||
return run(args.clang_dir, args.binaryen_dir, args.sexpr_wasm,
|
return run(args.clang_dir, args.binaryen_dir, args.sexpr_wasm,
|
||||||
args.musl, args.arch, args.out, args.save_temps,
|
args.musl, args.arch, args.out, args.compile_to_wasm)
|
||||||
args.compile_to_wasm)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user