]>
Commit | Line | Data |
---|---|---|
abe05a73 XL |
1 | #! /usr/bin/env python |
2 | ||
3 | # Copyright 2016 WebAssembly Community Group participants | |
4 | # | |
5 | # Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | # you may not use this file except in compliance with the License. | |
7 | # You may obtain a copy of the License at | |
8 | # | |
9 | # http://www.apache.org/licenses/LICENSE-2.0 | |
10 | # | |
11 | # Unless required by applicable law or agreed to in writing, software | |
12 | # distributed under the License is distributed on an "AS IS" BASIS, | |
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | # See the License for the specific language governing permissions and | |
15 | # limitations under the License. | |
16 | ||
17 | ''' | |
18 | A bunch of hackish fixups for testing of SpiderMonkey support. We should | |
19 | get rid of these ASAP. | |
20 | ||
21 | This is meant to be run using BINARYEN_SCRIPTS in emcc, and not standalone. | |
22 | ''' | |
23 | ||
24 | import os | |
25 | import subprocess | |
26 | import sys | |
27 | ||
28 | import emscripten | |
29 | ||
30 | binaryen_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) | |
31 | ||
32 | js_target = sys.argv[1] | |
33 | wast_target = sys.argv[2] | |
34 | ||
35 | wasm_target = wast_target[:-5] + '.wasm' | |
36 | ||
37 | # convert to binary using spidermonkey | |
38 | ''' | |
39 | using something like | |
40 | mozjs -e 'os.file.writeTypedArrayToFile("moz.wasm", | |
41 | new Uint8Array(wasmTextToBinary(os.file.readFile("a.out.wast"))))' | |
42 | investigate with | |
43 | >>> map(chr, map(ord, open('moz.wasm').read())) | |
44 | or | |
45 | python -c "print str(map(chr,map(ord, | |
46 | open('a.out.wasm').read()))).replace(',', '\n')" | |
47 | ''' | |
48 | subprocess.check_call( | |
49 | emscripten.shared.SPIDERMONKEY_ENGINE + | |
50 | ['-e', 'os.file.writeTypedArrayToFile("' + wasm_target + | |
51 | '", new Uint8Array(wasmTextToBinary(os.file.readFile("' + | |
52 | wast_target + '"))))']) |