Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tools to split and merge asm modules from the surrounding code
- Loading branch information
Showing
4 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python2 | ||
|
||
''' | ||
Splits a compiler outputted program into the asm module and the surrounding shell. This | ||
can be useful if you want to process the shell in some manner (e.g. minifiy it) in ways | ||
that would be harmful to asm.js code. | ||
''' | ||
|
||
import sys | ||
import shared | ||
|
||
try: | ||
me, in_shell, in_asm, outfile = sys.argv[:4] | ||
except: | ||
print >> sys.stderr, 'usage: emlink.py [input file] [shell output file] [asm output file]' | ||
sys.exit(1) | ||
|
||
print 'Shell input:', in_shell | ||
print 'Asm input:', in_asm | ||
print 'Input file:', outfile | ||
|
||
shared.try_delete(outfile) | ||
|
||
pre, post = open(in_shell).read().split('// ASM_CODE\n') | ||
open(outfile, 'w').write(pre + '\n' + open(in_asm).read() + '\n' + post) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python2 | ||
|
||
''' | ||
Splits a compiler outputted program into the asm module and the surrounding shell. This | ||
can be useful if you want to process the shell in some manner (e.g. minifiy it) in ways | ||
that would be harmful to asm.js code. | ||
''' | ||
|
||
import sys | ||
import shared | ||
from asm_module import AsmModule | ||
|
||
try: | ||
me, infile, out_shell, out_asm = sys.argv[:4] | ||
except: | ||
print >> sys.stderr, 'usage: emlink.py [input file] [shell output file] [asm output file]' | ||
sys.exit(1) | ||
|
||
print 'Input file:', infile | ||
print 'Shell output:', out_shell | ||
print 'Asm output:', out_asm | ||
|
||
shared.try_delete(out_shell) | ||
shared.try_delete(out_asm) | ||
|
||
module = AsmModule(infile) | ||
|
||
open(out_shell, 'w').write(module.pre_js + '\n// ASM_CODE\n' + module.post_js) | ||
open(out_asm, 'w').write(module.asm_js) | ||
|