mirror of
https://github.com/google/pebble.git
synced 2025-07-05 14:20:30 -04:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
27
third_party/jerryscript/js_tooling/transform_js.py
vendored
Executable file
27
third_party/jerryscript/js_tooling/transform_js.py
vendored
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python
|
||||
import re
|
||||
import sys
|
||||
|
||||
# when cross-compiling JerryScript with Emscripten, we need to fix a few minor things
|
||||
# to account for the various setups as some of the code assumes to be execute inside of node
|
||||
|
||||
def replace_ensured(s, old, new):
|
||||
result = s.replace(old, new)
|
||||
# make sure our search pattern `old` actually matched something
|
||||
# if we didn't change anything it means that we missed the Emscrupten outout (e.g. new version)
|
||||
assert result != s, "Emscripten output does not match expected output of 1.35.0"
|
||||
return result
|
||||
|
||||
# load file to be processed
|
||||
with open(sys.argv[1], "r") as f:
|
||||
source = f.read()
|
||||
|
||||
# source = replace_ensured(source, "func = eval('_' + ident); // explicit lookup",
|
||||
# "// func = eval('_' + ident); // explicit lookup")
|
||||
source = replace_ensured(source, "process['on']('uncaughtException',",
|
||||
"process['on']('uncaughtException-ignore',")
|
||||
|
||||
source = "(function(){\n%s\n})(this);" % source
|
||||
|
||||
with open(sys.argv[1], "w") as f:
|
||||
f.write(source)
|
Loading…
Add table
Add a link
Reference in a new issue