]>
git.proxmox.com Git - rustc.git/blob - src/binaryen/scripts/spidermonkify.py
3 # Copyright 2016 WebAssembly Community Group participants
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 A bunch of hackish fixups for testing of SpiderMonkey support. We should
19 get rid of these ASAP.
21 This is meant to be run using BINARYEN_SCRIPTS in emcc, and not standalone.
30 binaryen_root
= os
.path
.abspath(os
.path
.dirname(os
.path
.dirname(__file__
)))
32 js_target
= sys
.argv
[1]
33 wast_target
= sys
.argv
[2]
35 wasm_target
= wast_target
[:-5] + '.wasm'
37 # convert to binary using spidermonkey
40 mozjs -e 'os.file.writeTypedArrayToFile("moz.wasm",
41 new Uint8Array(wasmTextToBinary(os.file.readFile("a.out.wast"))))'
43 >>> map(chr, map(ord, open('moz.wasm').read()))
45 python -c "print str(map(chr,map(ord,
46 open('a.out.wasm').read()))).replace(',', '\n')"
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
+ '"))))'])