aboutsummaryrefslogtreecommitdiff
path: root/emlink.py
blob: 7311f84a3a5c0d65614778c22b4ffe09f7cc8c82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python2

'''
Fast static linker for emscripten outputs. Specifically this links asm.js modules.

See https://github.com/kripken/emscripten/wiki/Linking
'''

import sys
from tools import shared
from tools.asm_module import AsmModule

try:
  me, main, side, out = sys.argv[:4]
except:
  print >> sys.stderr, 'usage: emlink.py [main module] [side module] [output name]'
  sys.exit(1)

print 'Main module:', main
print 'Side module:', side
print 'Output:', out

shared.try_delete(out)

main = AsmModule(main)
side = AsmModule(side)

side.relocate_into(main)
main.write(out)