webruby 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webruby/rake/mruby.rake +1 -0
- data/modules/emscripten/AUTHORS +7 -0
- data/modules/emscripten/LICENSE +26 -0
- data/modules/emscripten/emcc +58 -20
- data/modules/emscripten/emlink.py +2 -265
- data/modules/emscripten/emscripten.py +38 -18
- data/modules/emscripten/scons-tools/emscripten.py +11 -6
- data/modules/emscripten/scons-tools/llvm.py +4 -3
- data/modules/emscripten/src/analyzer.js +32 -13
- data/modules/emscripten/src/embind/embind.js +13 -13
- data/modules/emscripten/src/embind/emval.js +8 -7
- data/modules/emscripten/src/intertyper.js +10 -0
- data/modules/emscripten/src/jsifier.js +28 -6
- data/modules/emscripten/src/library.js +2949 -1322
- data/modules/emscripten/src/library_browser.js +27 -23
- data/modules/emscripten/src/library_egl.js +7 -2
- data/modules/emscripten/src/library_gl.js +15 -2
- data/modules/emscripten/src/library_glut.js +1 -1
- data/modules/emscripten/src/library_jansson.js +1 -1
- data/modules/emscripten/src/library_openal.js +464 -132
- data/modules/emscripten/src/library_path.js +134 -0
- data/modules/emscripten/src/library_sdl.js +222 -50
- data/modules/emscripten/src/modules.js +22 -5
- data/modules/emscripten/src/parseTools.js +13 -2
- data/modules/emscripten/src/postamble.js +60 -34
- data/modules/emscripten/src/preamble.js +67 -18
- data/modules/emscripten/src/relooper/Relooper.cpp +1 -1
- data/modules/emscripten/src/runtime.js +12 -2
- data/modules/emscripten/src/settings.js +869 -826
- data/modules/emscripten/src/shell.js +63 -51
- data/modules/emscripten/src/utility.js +6 -0
- data/modules/emscripten/system/include/bsd/sys/mman.h +1 -1
- data/modules/emscripten/system/include/emscripten/bind.h +28 -28
- data/modules/emscripten/system/include/libc/math.h +8 -0
- data/modules/emscripten/system/include/libc/sys/signal.h +3 -1
- data/modules/emscripten/system/include/libc/sys/stat.h +2 -1
- data/modules/emscripten/system/include/libc/sys/types.h +4 -0
- data/modules/emscripten/system/include/libcxx/CREDITS.TXT +24 -0
- data/modules/emscripten/system/include/libcxx/__bit_reference +27 -8
- data/modules/emscripten/system/include/libcxx/__config +62 -15
- data/modules/emscripten/system/include/libcxx/__debug +5 -1
- data/modules/emscripten/system/include/libcxx/__functional_03 +24 -24
- data/modules/emscripten/system/include/libcxx/__functional_base +22 -4
- data/modules/emscripten/system/include/libcxx/__hash_table +566 -54
- data/modules/emscripten/system/include/libcxx/__locale +11 -3
- data/modules/emscripten/system/include/libcxx/__split_buffer +6 -6
- data/modules/emscripten/system/include/libcxx/__std_stream +58 -30
- data/modules/emscripten/system/include/libcxx/__tree +58 -51
- data/modules/emscripten/system/include/libcxx/__tuple +9 -9
- data/modules/emscripten/system/include/libcxx/algorithm +223 -13
- data/modules/emscripten/system/include/libcxx/array +18 -17
- data/modules/emscripten/system/include/libcxx/atomic +15 -5
- data/modules/emscripten/system/include/libcxx/cctype +2 -2
- data/modules/emscripten/system/include/libcxx/chrono +131 -36
- data/modules/emscripten/system/include/libcxx/cmath +41 -36
- data/modules/emscripten/system/include/libcxx/complex +49 -49
- data/modules/emscripten/system/include/libcxx/cstdio +2 -2
- data/modules/emscripten/system/include/libcxx/cstdlib +5 -5
- data/modules/emscripten/system/include/libcxx/cstring +2 -2
- data/modules/emscripten/system/include/libcxx/cwchar +22 -13
- data/modules/emscripten/system/include/libcxx/deque +27 -14
- data/modules/emscripten/system/include/libcxx/forward_list +36 -35
- data/modules/emscripten/system/include/libcxx/fstream +16 -0
- data/modules/emscripten/system/include/libcxx/functional +348 -23
- data/modules/emscripten/system/include/libcxx/future +66 -0
- data/modules/emscripten/system/include/libcxx/ios +27 -0
- data/modules/emscripten/system/include/libcxx/istream +2 -4
- data/modules/emscripten/system/include/libcxx/iterator +17 -9
- data/modules/emscripten/system/include/libcxx/limits +2 -2
- data/modules/emscripten/system/include/libcxx/list +165 -105
- data/modules/emscripten/system/include/libcxx/locale +154 -43
- data/modules/emscripten/system/include/libcxx/map +165 -224
- data/modules/emscripten/system/include/libcxx/memory +113 -54
- data/modules/emscripten/system/include/libcxx/random +2 -29
- data/modules/emscripten/system/include/libcxx/readme.txt +1 -1
- data/modules/emscripten/system/include/libcxx/regex +60 -15
- data/modules/emscripten/system/include/libcxx/sstream +124 -40
- data/modules/emscripten/system/include/libcxx/string +345 -182
- data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +3 -3
- data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +15 -2
- data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +3 -3
- data/modules/emscripten/system/include/libcxx/support/win32/support.h +10 -11
- data/modules/emscripten/system/include/libcxx/thread +2 -2
- data/modules/emscripten/system/include/libcxx/tuple +134 -65
- data/modules/emscripten/system/include/libcxx/type_traits +232 -24
- data/modules/emscripten/system/include/libcxx/unordered_map +314 -161
- data/modules/emscripten/system/include/libcxx/unordered_set +160 -2
- data/modules/emscripten/system/include/libcxx/utility +225 -40
- data/modules/emscripten/system/include/libcxx/vector +52 -57
- data/modules/emscripten/system/include/net/if.h +20 -1
- data/modules/emscripten/system/include/net/netinet/in.h +69 -5
- data/modules/emscripten/system/include/netdb.h +36 -0
- data/modules/emscripten/system/include/sys/ioctl.h +55 -3
- data/modules/emscripten/system/include/sys/select.h +2 -0
- data/modules/emscripten/system/include/sys/sendfile.h +16 -0
- data/modules/emscripten/system/include/sys/socket.h +181 -35
- data/modules/emscripten/system/lib/dlmalloc.c +10 -12
- data/modules/emscripten/system/lib/libc/musl/src/stdlib/ecvt.c +19 -0
- data/modules/emscripten/system/lib/libc/musl/src/stdlib/fcvt.c +25 -0
- data/modules/emscripten/system/lib/libc/musl/src/stdlib/gcvt.c +8 -0
- data/modules/emscripten/system/lib/libcextra.symbols +3 -0
- data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +24 -0
- data/modules/emscripten/system/lib/libcxx/debug.cpp +11 -9
- data/modules/emscripten/system/lib/libcxx/exception.cpp +9 -0
- data/modules/emscripten/system/lib/libcxx/hash.cpp +6 -0
- data/modules/emscripten/system/lib/libcxx/iostream.cpp +4 -4
- data/modules/emscripten/system/lib/libcxx/locale.cpp +91 -42
- data/modules/emscripten/system/lib/libcxx/readme.txt +1 -1
- data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +1 -1
- data/modules/emscripten/system/lib/libcxx/string.cpp +332 -491
- data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +4 -2
- data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +140 -41
- data/modules/emscripten/system/lib/libcxx/symbols +9 -256
- data/modules/emscripten/system/lib/libcxx/system_error.cpp +3 -0
- data/modules/emscripten/system/lib/libcxx/thread.cpp +16 -3
- data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +12 -2
- data/modules/emscripten/third_party/stb_image.c +4673 -0
- data/modules/emscripten/tools/asm_module.py +273 -0
- data/modules/emscripten/tools/exec_llvm.py +2 -2
- data/modules/emscripten/tools/file_packager.py +36 -16
- data/modules/emscripten/tools/find_bigfuncs.py +9 -9
- data/modules/emscripten/tools/js-optimizer.js +485 -131
- data/modules/emscripten/tools/js_optimizer.py +22 -15
- data/modules/emscripten/tools/merge_asm.py +26 -0
- data/modules/emscripten/tools/nativize_llvm.py +2 -2
- data/modules/emscripten/tools/settings_template_readonly.py +1 -1
- data/modules/emscripten/tools/shared.py +63 -20
- data/modules/emscripten/tools/split_asm.py +30 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-outline1-output.js +686 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-outline1.js +263 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-outline2-output.js +747 -0
- data/modules/emscripten/tools/{test-js-optimizer-asm-outline.js → test-js-optimizer-asm-outline2.js} +1 -1
- data/modules/emscripten/tools/test-js-optimizer-asm-outline3-output.js +28 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-outline3.js +30 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-pre-output.js +4 -4
- data/modules/mruby/AUTHORS +1 -0
- data/modules/mruby/README.md +4 -2
- data/modules/mruby/build_config.rb +6 -6
- data/modules/mruby/doc/mrbgems/README.md +4 -4
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/mrbgem.rake +1 -1
- data/modules/mruby/examples/mrbgems/c_extension_example/mrbgem.rake +1 -1
- data/modules/mruby/examples/mrbgems/ruby_extension_example/mrbgem.rake +1 -1
- data/modules/mruby/include/mrbconf.h +3 -0
- data/modules/mruby/include/mruby/array.h +2 -2
- data/modules/mruby/include/mruby/class.h +4 -4
- data/modules/mruby/include/mruby/compile.h +1 -0
- data/modules/mruby/include/mruby/data.h +1 -1
- data/modules/mruby/include/mruby/hash.h +2 -2
- data/modules/mruby/include/mruby/irep.h +3 -2
- data/modules/mruby/include/mruby/proc.h +1 -1
- data/modules/mruby/include/mruby/range.h +1 -1
- data/modules/mruby/include/mruby/string.h +2 -2
- data/modules/mruby/include/mruby/value.h +43 -26
- data/modules/mruby/include/mruby.h +10 -2
- data/modules/mruby/minirake +2 -2
- data/modules/mruby/mrbgems/mruby-array-ext/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +4 -1
- data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +32 -0
- data/modules/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +13 -5
- data/modules/mruby/mrbgems/mruby-enum-ext/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-enum-ext/test/enum.rb +10 -11
- data/modules/mruby/mrbgems/mruby-eval/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-exit/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-exit/src/mruby-exit.c +24 -0
- data/modules/mruby/mrbgems/mruby-fiber/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +4 -2
- data/modules/mruby/mrbgems/mruby-hash-ext/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-hash-ext/test/hash.rb +5 -7
- data/modules/mruby/mrbgems/mruby-math/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-numeric-ext/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-numeric-ext/test/numeric.rb +2 -2
- data/modules/mruby/mrbgems/mruby-object-ext/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-object-ext/src/object.c +3 -3
- data/modules/mruby/mrbgems/mruby-object-ext/test/nil.rb +3 -3
- data/modules/mruby/mrbgems/mruby-object-ext/test/object.rb +1 -1
- data/modules/mruby/mrbgems/mruby-objectspace/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-objectspace/test/objectspace.rb +36 -37
- data/modules/mruby/mrbgems/mruby-print/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-proc-ext/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-proc-ext/test/proc.rb +8 -8
- data/modules/mruby/mrbgems/mruby-random/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-range-ext/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-range-ext/test/range.rb +6 -6
- data/modules/mruby/mrbgems/mruby-sprintf/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-string-ext/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-string-ext/test/string.rb +6 -6
- data/modules/mruby/mrbgems/mruby-struct/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-symbol-ext/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +2 -2
- data/modules/mruby/mrbgems/mruby-time/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-time/src/time.c +2 -8
- data/modules/mruby/mrbgems/mruby-toplevel-ext/mrbgem.rake +1 -1
- data/modules/mruby/mrbgems/mruby-toplevel-ext/test/toplevel.rb +10 -10
- data/modules/mruby/mrblib/class.rb +15 -9
- data/modules/mruby/mrblib/string.rb +12 -0
- data/modules/mruby/src/array.c +4 -3
- data/modules/mruby/src/class.c +13 -8
- data/modules/mruby/src/codegen.c +9 -8
- data/modules/mruby/src/error.c +7 -5
- data/modules/mruby/src/error.h +1 -0
- data/modules/mruby/src/etc.c +1 -1
- data/modules/mruby/src/gc.c +163 -128
- data/modules/mruby/src/kernel.c +43 -15
- data/modules/mruby/src/numeric.c +9 -7
- data/modules/mruby/src/object.c +1 -1
- data/modules/mruby/src/parse.y +37 -19
- data/modules/mruby/src/range.c +10 -24
- data/modules/mruby/src/state.c +2 -6
- data/modules/mruby/src/string.c +0 -9
- data/modules/mruby/src/variable.c +2 -2
- data/modules/mruby/src/vm.c +12 -6
- data/modules/mruby/tasks/mrbgem_spec.rake +7 -0
- data/modules/mruby/tasks/mrbgems.rake +2 -1
- data/modules/mruby/tasks/mrbgems_test.rake +1 -1
- data/modules/mruby/tasks/mruby_build.rake +4 -3
- data/modules/mruby/tasks/mruby_build_commands.rake +6 -1
- data/modules/mruby/tasks/mruby_build_gem.rake +2 -2
- data/modules/mruby/tasks/toolchains/androideabi.rake +2 -0
- data/modules/mruby/test/assert.rb +2 -2
- data/modules/mruby/test/t/argumenterror.rb +3 -3
- data/modules/mruby/test/t/array.rb +55 -55
- data/modules/mruby/test/t/basicobject.rb +1 -1
- data/modules/mruby/test/t/bs_block.rb +12 -12
- data/modules/mruby/test/t/class.rb +21 -21
- data/modules/mruby/test/t/enumerable.rb +18 -18
- data/modules/mruby/test/t/exception.rb +20 -20
- data/modules/mruby/test/t/false.rb +3 -3
- data/modules/mruby/test/t/float.rb +40 -40
- data/modules/mruby/test/t/gc.rb +10 -10
- data/modules/mruby/test/t/hash.rb +41 -41
- data/modules/mruby/test/t/indexerror.rb +2 -2
- data/modules/mruby/test/t/integer.rb +41 -41
- data/modules/mruby/test/t/kernel.rb +33 -33
- data/modules/mruby/test/t/literals.rb +82 -82
- data/modules/mruby/test/t/localjumperror.rb +1 -1
- data/modules/mruby/test/t/module.rb +170 -31
- data/modules/mruby/test/t/nameerror.rb +5 -5
- data/modules/mruby/test/t/nil.rb +2 -2
- data/modules/mruby/test/t/nomethoderror.rb +1 -1
- data/modules/mruby/test/t/numeric.rb +5 -5
- data/modules/mruby/test/t/object.rb +2 -2
- data/modules/mruby/test/t/proc.rb +8 -8
- data/modules/mruby/test/t/range.rb +9 -9
- data/modules/mruby/test/t/rangeerror.rb +2 -2
- data/modules/mruby/test/t/runtimeerror.rb +1 -1
- data/modules/mruby/test/t/standarderror.rb +2 -2
- data/modules/mruby/test/t/string.rb +100 -100
- data/modules/mruby/test/t/symbol.rb +5 -5
- data/modules/mruby/test/t/syntax.rb +15 -6
- data/modules/mruby/test/t/true.rb +3 -3
- data/modules/mruby/test/t/typeerror.rb +2 -2
- data/modules/mruby/tools/mrbc/mrbc.c +10 -4
- data/modules/mruby/travis_config.rb +1 -0
- data/scripts/gen_gems_config.rb +5 -1
- metadata +19 -4
- data/modules/emscripten/tools/test-js-optimizer-asm-outline-output.js +0 -570
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90c4009581e36a53cf797ad2685ffaf6499097f9
|
4
|
+
data.tar.gz: 6cf5854d209e72baf672e4ec43c691a54710ef49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 810169db5643ffcc255636cb72d21a2fb09ca2e198c729735fa07746b743ceb2b2a07d480bd102a5ae122b09686422737774df5d11c293c580b16d890fe9d622
|
7
|
+
data.tar.gz: 92249c4531db15431fc64e73832c337af1caca5d8fbe570dc5fed67caa77728ac7fafeaf5e78aa8c843a3aea25728ee22be76d6315338795f56cf0ee2733e86e
|
data/lib/webruby/rake/mruby.rake
CHANGED
@@ -25,6 +25,7 @@ end
|
|
25
25
|
MRuby::CrossBuild.new('emscripten') do |conf|
|
26
26
|
toolchain :emscripten
|
27
27
|
conf.build_dir = '#{Webruby.full_build_dir}/mruby/emscripten'
|
28
|
+
conf.gem_clone_dir = '#{File.expand_path("~/.webruby/gems")}'
|
28
29
|
|
29
30
|
#{Webruby::App.config.gembox_lines}
|
30
31
|
#{Webruby::App.config.gem_lines}
|
data/modules/emscripten/AUTHORS
CHANGED
@@ -87,3 +87,10 @@ a license to everyone to use it as detailed in LICENSE.)
|
|
87
87
|
* Manfred Manik Nerurkar <nerurkar*at*made-apps.biz> (copyright owned by MADE, GmbH)
|
88
88
|
* Joseph Gentle <me@josephg.com>
|
89
89
|
* Douglas T. Crosher <dtc-moz@scieneer.com> (copyright owned by Mozilla Founcation)
|
90
|
+
* Soeren Balko <soeren.balko@gmail.com>
|
91
|
+
* Ryan Kelly (ryan@rfk.id.au)
|
92
|
+
* Michael Lelli <toadking@toadking.com>
|
93
|
+
* Yu Kobayashi <yukoba@accelart.jp>
|
94
|
+
* Pin Zhang <zhangpin04@gmail.com>
|
95
|
+
* Nick Bray <ncbray@chromium.org> (copyright owned by Google, Inc.)
|
96
|
+
|
data/modules/emscripten/LICENSE
CHANGED
@@ -66,3 +66,29 @@ IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
66
66
|
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
67
67
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
68
68
|
SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
|
69
|
+
|
70
|
+
==============================================================================
|
71
|
+
|
72
|
+
This program uses portions of Node.js source code located in src/library_path.js,
|
73
|
+
in accordance with the terms of the MIT license. Node's license follows:
|
74
|
+
|
75
|
+
"""
|
76
|
+
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
77
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
78
|
+
of this software and associated documentation files (the "Software"), to
|
79
|
+
deal in the Software without restriction, including without limitation the
|
80
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
81
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
82
|
+
furnished to do so, subject to the following conditions:
|
83
|
+
|
84
|
+
The above copyright notice and this permission notice shall be included in
|
85
|
+
all copies or substantial portions of the Software.
|
86
|
+
|
87
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
88
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
89
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
90
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
91
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
92
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
93
|
+
IN THE SOFTWARE.
|
94
|
+
"""
|
data/modules/emscripten/emcc
CHANGED
@@ -53,6 +53,15 @@ from tools import shared, jsrun
|
|
53
53
|
from tools.shared import Compression, execute, suffix, unsuffixed, unsuffixed_basename
|
54
54
|
from tools.response_file import read_response_file
|
55
55
|
|
56
|
+
CXX_SUFFIXES = ('.cpp', '.cxx', '.cc')
|
57
|
+
SOURCE_SUFFIXES = ('.c', '.cpp', '.cxx', '.cc', '.m', '.mm')
|
58
|
+
BITCODE_SUFFIXES = ('.bc', '.o', '.obj')
|
59
|
+
DYNAMICLIB_SUFFIXES = ('.dylib', '.so', '.dll')
|
60
|
+
STATICLIB_SUFFIXES = ('.a',)
|
61
|
+
ASSEMBLY_SUFFIXES = ('.ll',)
|
62
|
+
LIB_PREFIXES = ('', 'lib')
|
63
|
+
JS_CONTAINING_SUFFIXES = ('js', 'html')
|
64
|
+
|
56
65
|
# Mapping of emcc opt levels to llvm opt levels. We use llvm opt level 3 in emcc opt
|
57
66
|
# levels 2 and 3 (emcc 3 is unsafe opts, so unsuitable for the only level to get
|
58
67
|
# llvm opt level 3, and speed-wise emcc level 2 is already the slowest/most optimizing
|
@@ -302,6 +311,9 @@ Options that are modified or new in %s include:
|
|
302
311
|
your main compiled code (or run it before in
|
303
312
|
some other way).
|
304
313
|
|
314
|
+
For more docs on the options --preload-file
|
315
|
+
accepts, see https://github.com/kripken/emscripten/wiki/Filesystem-Guide
|
316
|
+
|
305
317
|
--compression <codec> Compress both the compiled code and embedded/
|
306
318
|
preloaded files. <codec> should be a triple,
|
307
319
|
|
@@ -450,6 +462,12 @@ Options that are modified or new in %s include:
|
|
450
462
|
memory initialization data embedded inside
|
451
463
|
JavaScript as text. (default is off)
|
452
464
|
|
465
|
+
-Wno-warn-absolute-paths If not specified, the compiler will warn about any
|
466
|
+
uses of absolute paths in -I and -L command line
|
467
|
+
directives. Pass this flag on the command line
|
468
|
+
to hide these warnings and acknowledge that the
|
469
|
+
explicit use of absolute paths is intentional.
|
470
|
+
|
453
471
|
The target file, if specified (-o <target>), defines what will
|
454
472
|
be generated:
|
455
473
|
|
@@ -529,7 +547,7 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG:
|
|
529
547
|
if debug_configure: open(tempout, 'a').write('============= ' + arg + '\n' + src + '\n=============\n\n')
|
530
548
|
except:
|
531
549
|
pass
|
532
|
-
|
550
|
+
elif arg.endswith('.s'):
|
533
551
|
if debug_configure: open(tempout, 'a').write('(compiling .s assembly, must use clang\n')
|
534
552
|
use_js = 0
|
535
553
|
|
@@ -612,15 +630,6 @@ if EMMAKEN_CFLAGS: CC_ADDITIONAL_ARGS += shlex.split(EMMAKEN_CFLAGS)
|
|
612
630
|
|
613
631
|
# ---------------- Utilities ---------------
|
614
632
|
|
615
|
-
SOURCE_SUFFIXES = ('.c', '.cpp', '.cxx', '.cc', '.m', '.mm')
|
616
|
-
BITCODE_SUFFIXES = ('.bc', '.o', '.obj')
|
617
|
-
DYNAMICLIB_SUFFIXES = ('.dylib', '.so', '.dll')
|
618
|
-
STATICLIB_SUFFIXES = ('.a',)
|
619
|
-
ASSEMBLY_SUFFIXES = ('.ll',)
|
620
|
-
LIB_PREFIXES = ('', 'lib')
|
621
|
-
|
622
|
-
JS_CONTAINING_SUFFIXES = ('js', 'html')
|
623
|
-
|
624
633
|
seen_names = {}
|
625
634
|
def uniquename(name):
|
626
635
|
if name not in seen_names:
|
@@ -732,6 +741,12 @@ try:
|
|
732
741
|
|
733
742
|
absolute_warning_shown = False
|
734
743
|
|
744
|
+
# Scan for warning suppression message in advance from other cmdline flags, so that it works even if -I or -L directives are present before this.
|
745
|
+
for i in range(len(newargs)):
|
746
|
+
if newargs[i] == '-Wno-warn-absolute-paths':
|
747
|
+
newargs[i] = ''
|
748
|
+
absolute_warning_shown = True
|
749
|
+
|
735
750
|
settings_changes = []
|
736
751
|
|
737
752
|
def validate_arg_level(level_string, max_level, err_msg):
|
@@ -784,6 +799,7 @@ try:
|
|
784
799
|
newargs[i+1] = ''
|
785
800
|
elif newargs[i].startswith('--minify'):
|
786
801
|
check_bad_eq(newargs[i])
|
802
|
+
assert newargs[i+1] == '0', '0 is the only supported option for --minify; 1 has been deprecated'
|
787
803
|
debug_level = max(1, debug_level)
|
788
804
|
newargs[i] = ''
|
789
805
|
newargs[i+1] = ''
|
@@ -875,7 +891,7 @@ try:
|
|
875
891
|
elif newargs[i].startswith(('-I', '-L')):
|
876
892
|
path_name = newargs[i][2:]
|
877
893
|
if not absolute_warning_shown and os.path.isabs(path_name):
|
878
|
-
logging.warning ('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not
|
894
|
+
logging.warning ('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript). Pass \'-Wno-warn-absolute-paths\' to emcc to hide this warning.') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not
|
879
895
|
absolute_warning_shown = True
|
880
896
|
newargs = [ arg for arg in newargs if arg is not '' ]
|
881
897
|
|
@@ -1007,7 +1023,7 @@ try:
|
|
1007
1023
|
logging.error('no input files\nnote that input files without a known suffix are ignored, make sure your input files end with one of: ' + str(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + STATICLIB_SUFFIXES + ASSEMBLY_SUFFIXES))
|
1008
1024
|
exit(0)
|
1009
1025
|
|
1010
|
-
newargs
|
1026
|
+
newargs = CC_ADDITIONAL_ARGS + newargs
|
1011
1027
|
|
1012
1028
|
assert not (Compression.on and final_suffix != 'html'), 'Compression only works when generating HTML'
|
1013
1029
|
|
@@ -1027,6 +1043,10 @@ try:
|
|
1027
1043
|
exec('shared.Settings.' + key + ' = ' + value)
|
1028
1044
|
|
1029
1045
|
# Apply effects from settings
|
1046
|
+
if bind and shared.Settings.ASM_JS:
|
1047
|
+
logging.warning('disabling asm.js since embind is not ready for it yet')
|
1048
|
+
shared.Settings.ASM_JS = 0
|
1049
|
+
|
1030
1050
|
if shared.Settings.ASM_JS:
|
1031
1051
|
assert opt_level >= 1, 'asm.js requires -O1 or above'
|
1032
1052
|
|
@@ -1046,7 +1066,7 @@ try:
|
|
1046
1066
|
if shared.Settings.CORRECT_SIGNS >= 2 or shared.Settings.CORRECT_OVERFLOWS >= 2 or shared.Settings.CORRECT_ROUNDINGS >= 2:
|
1047
1067
|
debug_level = 4 # must keep debug info to do line-by-line operations
|
1048
1068
|
|
1049
|
-
if debug_level >
|
1069
|
+
if debug_level > 1 and closure:
|
1050
1070
|
logging.warning('disabling closure because debug info was requested')
|
1051
1071
|
closure = False
|
1052
1072
|
|
@@ -1077,6 +1097,13 @@ try:
|
|
1077
1097
|
shared.Settings.LINKABLE = 1 # TODO: add FORCE_DCE option for the brave people that do want to dce here and in side modules
|
1078
1098
|
debug_level = max(debug_level, 2)
|
1079
1099
|
|
1100
|
+
if shared.Settings.DLOPEN_SUPPORT:
|
1101
|
+
shared.Settings.LINKABLE = 1
|
1102
|
+
|
1103
|
+
if shared.Settings.STB_IMAGE and final_suffix in JS_CONTAINING_SUFFIXES:
|
1104
|
+
input_files.append(shared.path_from_root('third_party', 'stb_image.c'))
|
1105
|
+
shared.Settings.EXPORTED_FUNCTIONS += ['_stbi_load', '_stbi_load_from_memory', '_stbi_image_free']
|
1106
|
+
|
1080
1107
|
## Compile source code to bitcode
|
1081
1108
|
|
1082
1109
|
logging.debug('compiling to bitcode')
|
@@ -1091,6 +1118,8 @@ try:
|
|
1091
1118
|
output_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
|
1092
1119
|
temp_files.append(output_file)
|
1093
1120
|
args = newargs + ['-emit-llvm', '-c', input_file, '-o', output_file]
|
1121
|
+
if input_file.endswith(CXX_SUFFIXES):
|
1122
|
+
args += shared.EMSDK_CXX_OPTS
|
1094
1123
|
logging.debug("running:" + call + ' ' + ' '.join(args))
|
1095
1124
|
execute([call] + args) # let compiler frontend print directly, so colors are saved (PIPE kills that)
|
1096
1125
|
if not os.path.exists(output_file):
|
@@ -1268,6 +1297,11 @@ try:
|
|
1268
1297
|
'wctob.c',
|
1269
1298
|
'wctomb.c',
|
1270
1299
|
]],
|
1300
|
+
['stdlib', [
|
1301
|
+
'ecvt.c',
|
1302
|
+
'fcvt.c',
|
1303
|
+
'gcvt.c',
|
1304
|
+
]],
|
1271
1305
|
['string', [
|
1272
1306
|
'wcpcpy.c',
|
1273
1307
|
'wcpncpy.c',
|
@@ -1535,14 +1569,17 @@ try:
|
|
1535
1569
|
|
1536
1570
|
# It is useful to run several js optimizer passes together, to save on unneeded unparsing/reparsing
|
1537
1571
|
js_optimizer_queue = []
|
1572
|
+
js_optimizer_extra_info = {}
|
1538
1573
|
def flush_js_optimizer_queue():
|
1539
|
-
global final, js_optimizer_queue
|
1574
|
+
global final, js_optimizer_queue, js_optimizer_extra_info
|
1575
|
+
if len(js_optimizer_extra_info) == 0:
|
1576
|
+
js_optimizer_extra_info = None
|
1540
1577
|
if len(js_optimizer_queue) > 0 and not(len(js_optimizer_queue) == 1 and js_optimizer_queue[0] == 'last'):
|
1541
1578
|
if DEBUG != '2':
|
1542
1579
|
if shared.Settings.ASM_JS:
|
1543
1580
|
js_optimizer_queue = ['asm'] + js_optimizer_queue
|
1544
1581
|
logging.debug('applying js optimization passes: %s', js_optimizer_queue)
|
1545
|
-
final = shared.Building.js_optimizer(final, js_optimizer_queue, jcache, debug_level >= 4)
|
1582
|
+
final = shared.Building.js_optimizer(final, js_optimizer_queue, jcache, debug_level >= 4, js_optimizer_extra_info)
|
1546
1583
|
js_transform_tempfiles.append(final)
|
1547
1584
|
if DEBUG: save_intermediate('js_opts')
|
1548
1585
|
else:
|
@@ -1551,10 +1588,11 @@ try:
|
|
1551
1588
|
if shared.Settings.ASM_JS:
|
1552
1589
|
passes = ['asm'] + passes
|
1553
1590
|
logging.debug('applying js optimization pass: %s', passes)
|
1554
|
-
final = shared.Building.js_optimizer(final, passes, jcache, debug_level >= 4)
|
1591
|
+
final = shared.Building.js_optimizer(final, passes, jcache, debug_level >= 4, js_optimizer_extra_info)
|
1555
1592
|
js_transform_tempfiles.append(final)
|
1556
1593
|
save_intermediate(name)
|
1557
1594
|
js_optimizer_queue = []
|
1595
|
+
js_optimizer_extra_info = {}
|
1558
1596
|
|
1559
1597
|
if opt_level >= 1:
|
1560
1598
|
logging.debug('running pre-closure post-opts')
|
@@ -1571,7 +1609,7 @@ try:
|
|
1571
1609
|
else:
|
1572
1610
|
return 'eliminate'
|
1573
1611
|
|
1574
|
-
js_optimizer_queue += [get_eliminate(), '
|
1612
|
+
js_optimizer_queue += [get_eliminate(), 'simplifyExpressions']
|
1575
1613
|
|
1576
1614
|
if shared.Settings.RELOOP and not shared.Settings.ASM_JS:
|
1577
1615
|
js_optimizer_queue += ['optimizeShiftsAggressive', get_eliminate()] # aggressive shifts optimization requires loops, it breaks on switches
|
@@ -1585,9 +1623,9 @@ try:
|
|
1585
1623
|
final = shared.Building.closure_compiler(final)
|
1586
1624
|
if DEBUG: save_intermediate('closure')
|
1587
1625
|
|
1588
|
-
if
|
1589
|
-
|
1590
|
-
|
1626
|
+
if shared.Settings.OUTLINING_LIMIT > 0:
|
1627
|
+
js_optimizer_queue += ['outline']
|
1628
|
+
js_optimizer_extra_info['sizeToOutline'] = shared.Settings.OUTLINING_LIMIT
|
1591
1629
|
|
1592
1630
|
if (not closure or shared.Settings.ASM_JS) and shared.Settings.RELOOP and debug_level < 3:
|
1593
1631
|
js_optimizer_queue += ['registerize']
|
@@ -6,9 +6,9 @@ Fast static linker for emscripten outputs. Specifically this links asm.js module
|
|
6
6
|
See https://github.com/kripken/emscripten/wiki/Linking
|
7
7
|
'''
|
8
8
|
|
9
|
-
import
|
9
|
+
import sys
|
10
10
|
from tools import shared
|
11
|
-
from tools import
|
11
|
+
from tools.asm_module import AsmModule
|
12
12
|
|
13
13
|
try:
|
14
14
|
me, main, side, out = sys.argv[:4]
|
@@ -22,269 +22,6 @@ print 'Output:', out
|
|
22
22
|
|
23
23
|
shared.try_delete(out)
|
24
24
|
|
25
|
-
class AsmModule():
|
26
|
-
def __init__(self, filename):
|
27
|
-
self.filename = filename
|
28
|
-
self.js = open(filename).read()
|
29
|
-
|
30
|
-
self.start_asm = self.js.find(js_optimizer.start_asm_marker)
|
31
|
-
self.start_funcs = self.js.find(js_optimizer.start_funcs_marker)
|
32
|
-
self.end_funcs = self.js.rfind(js_optimizer.end_funcs_marker)
|
33
|
-
self.end_asm = self.js.rfind(js_optimizer.end_asm_marker)
|
34
|
-
|
35
|
-
# pre
|
36
|
-
self.pre_js = self.js[:self.start_asm]
|
37
|
-
|
38
|
-
# heap initializer
|
39
|
-
self.staticbump = int(re.search(shared.JS.memory_staticbump_pattern, self.pre_js).group(1))
|
40
|
-
if self.staticbump:
|
41
|
-
self.mem_init_js = re.search(shared.JS.memory_initializer_pattern, self.pre_js).group(0)
|
42
|
-
|
43
|
-
# global initializers
|
44
|
-
global_inits = re.search(shared.JS.global_initializers_pattern, self.pre_js)
|
45
|
-
if global_inits:
|
46
|
-
self.global_inits_js = global_inits.group(0)
|
47
|
-
self.global_inits = map(lambda init: init.split('{')[2][1:].split('(')[0], global_inits.groups(0)[0].split(','))
|
48
|
-
else:
|
49
|
-
self.global_inits_js = ''
|
50
|
-
self.global_inits = []
|
51
|
-
|
52
|
-
# imports (and global variables)
|
53
|
-
first_var = self.js.find('var ', self.js.find('var ', self.start_asm)+4)
|
54
|
-
self.pre_imports_js = self.js[self.start_asm:first_var]
|
55
|
-
self.imports_js = self.js[first_var:self.start_funcs]
|
56
|
-
self.imports = {}
|
57
|
-
for imp in js_optimizer.import_sig.finditer(self.imports_js):
|
58
|
-
key, value = imp.group(0).split('var ')[1][:-1].split('=', 1)
|
59
|
-
self.imports[key] = value
|
60
|
-
#print >> sys.stderr, 'imports', self.imports
|
61
|
-
|
62
|
-
# funcs
|
63
|
-
self.funcs_js = self.js[self.start_funcs:self.end_funcs]
|
64
|
-
self.funcs = set([m.group(2) for m in js_optimizer.func_sig.finditer(self.funcs_js)])
|
65
|
-
#print 'funcs', self.funcs
|
66
|
-
|
67
|
-
# tables and exports
|
68
|
-
post_js = self.js[self.end_funcs:self.end_asm]
|
69
|
-
ret = post_js.find('return')
|
70
|
-
self.tables_js = post_js[:ret]
|
71
|
-
self.exports_js = post_js[ret:]
|
72
|
-
self.tables = self.parse_tables(self.tables_js)
|
73
|
-
self.exports = set([export.strip() for export in self.exports_js[self.exports_js.find('{')+1:self.exports_js.find('}')].split(',')])
|
74
|
-
|
75
|
-
# post
|
76
|
-
self.post_js = self.js[self.end_asm:]
|
77
|
-
self.sendings = {}
|
78
|
-
for sending in [sending.strip() for sending in self.post_js[self.post_js.find('}, { ')+5:self.post_js.find(' }, buffer);')].split(',')]:
|
79
|
-
colon = sending.find(':')
|
80
|
-
self.sendings[sending[:colon].replace('"', '')] = sending[colon+1:].strip()
|
81
|
-
self.module_defs = set(re.findall('var [\w\d_$]+ = Module\["[\w\d_$]+"\] = asm\["[\w\d_$]+"\];\n', self.post_js))
|
82
|
-
|
83
|
-
def relocate_into(self, main):
|
84
|
-
# heap initializer
|
85
|
-
if self.staticbump > 0:
|
86
|
-
new_mem_init = self.mem_init_js[:self.mem_init_js.rfind(', ')] + ', Runtime.GLOBAL_BASE+%d)' % main.staticbump
|
87
|
-
main.pre_js = re.sub(shared.JS.memory_staticbump_pattern, 'STATICTOP = STATIC_BASE + %d;\n' % (main.staticbump + side.staticbump) + new_mem_init, main.pre_js, count=1)
|
88
|
-
|
89
|
-
# Find function name replacements TODO: do not rename duplicate names with duplicate contents, just merge them
|
90
|
-
replacements = {}
|
91
|
-
for func in self.funcs:
|
92
|
-
rep = func
|
93
|
-
while rep in main.funcs:
|
94
|
-
rep += '_'
|
95
|
-
replacements[func] = rep
|
96
|
-
#print >> sys.stderr, 'replacements:', replacements
|
97
|
-
|
98
|
-
# sendings: add invokes for new tables
|
99
|
-
all_sendings = main.sendings
|
100
|
-
added_sending = False
|
101
|
-
for table in self.tables:
|
102
|
-
if table not in main.tables:
|
103
|
-
sig = table[table.rfind('_')+1:]
|
104
|
-
all_sendings['invoke_%s' % sig] = shared.JS.make_invoke(sig, named=False)
|
105
|
-
added_sending = True
|
106
|
-
|
107
|
-
# imports
|
108
|
-
all_imports = main.imports
|
109
|
-
for key, value in self.imports.iteritems():
|
110
|
-
if key in self.funcs or key in main.funcs: continue # external function in one module, implemented in the other
|
111
|
-
value_concrete = '.' not in value # env.key means it is an import, an external value, and not a concrete one
|
112
|
-
main_value = main.imports.get(key)
|
113
|
-
main_value_concrete = main_value and '.' not in main_value
|
114
|
-
if value_concrete and main_value_concrete: continue # standard global var
|
115
|
-
if not main_value or value_concrete:
|
116
|
-
if '+' in value:
|
117
|
-
# relocate
|
118
|
-
value = value.replace('(', '').replace(')', '').replace('| 0', '').replace('|0', '').replace(' ', '')
|
119
|
-
left, right = value.split('+')
|
120
|
-
assert left == 'H_BASE'
|
121
|
-
value = str(main.staticbump + int(right))
|
122
|
-
all_imports[key] = value
|
123
|
-
if (value_concrete or main_value_concrete) and key in all_sendings:
|
124
|
-
del all_sendings[key] # import of external value no longer needed
|
125
|
-
main.imports_js = '\n'.join(['var %s = %s;' % (key, value) for key, value in all_imports.iteritems()]) + '\n'
|
126
|
-
|
127
|
-
if added_sending:
|
128
|
-
sendings_js = ', '.join(['%s: %s' % (key, value) for key, value in all_sendings.iteritems()])
|
129
|
-
sendings_start = main.post_js.find('}, { ')+5
|
130
|
-
sendings_end = main.post_js.find(' }, buffer);')
|
131
|
-
main.post_js = main.post_js[:sendings_start] + sendings_js + main.post_js[sendings_end:]
|
132
|
-
|
133
|
-
# check for undefined references to global variables
|
134
|
-
def check_import(key, value):
|
135
|
-
if value.startswith('+') or value.endswith('|0'): # ignore functions
|
136
|
-
if key not in all_sendings:
|
137
|
-
print >> sys.stderr, 'warning: external variable %s is still not defined after linking' % key
|
138
|
-
for key, value in all_imports.iteritems(): check_import(key, value)
|
139
|
-
|
140
|
-
# tables
|
141
|
-
f_bases = {}
|
142
|
-
f_sizes = {}
|
143
|
-
for table, data in self.tables.iteritems():
|
144
|
-
main.tables[table] = self.merge_tables(table, main.tables.get(table), data, replacements, f_bases, f_sizes)
|
145
|
-
main.combine_tables()
|
146
|
-
#print >> sys.stderr, 'f bases', f_bases
|
147
|
-
|
148
|
-
# relocate
|
149
|
-
temp = shared.Building.js_optimizer(self.filename, ['asm', 'relocate', 'last'], extra_info={
|
150
|
-
'replacements': replacements,
|
151
|
-
'fBases': f_bases,
|
152
|
-
'hBase': main.staticbump
|
153
|
-
})
|
154
|
-
#print >> sys.stderr, 'relocated side into', temp
|
155
|
-
relocated_funcs = AsmModule(temp)
|
156
|
-
shared.try_delete(temp)
|
157
|
-
main.extra_funcs_js = relocated_funcs.funcs_js.replace(js_optimizer.start_funcs_marker, '\n')
|
158
|
-
|
159
|
-
# update function table uses
|
160
|
-
ft_marker = 'FUNCTION_TABLE_'
|
161
|
-
|
162
|
-
def update_fts(what):
|
163
|
-
updates = []
|
164
|
-
i = 1 # avoid seeing marker in recursion
|
165
|
-
while 1:
|
166
|
-
i = what.find(ft_marker, i)
|
167
|
-
if i < 0: break;
|
168
|
-
start = i
|
169
|
-
end = what.find('[', start)
|
170
|
-
table = what[i:end]
|
171
|
-
if table not in f_sizes:
|
172
|
-
# table was not modified
|
173
|
-
i += len(ft_marker)
|
174
|
-
continue
|
175
|
-
nesting = 1
|
176
|
-
while nesting > 0:
|
177
|
-
next = what.find(']', end+1)
|
178
|
-
nesting -= 1
|
179
|
-
nesting += what.count('[', end+1, next)
|
180
|
-
end = next
|
181
|
-
assert end > 0
|
182
|
-
mask = what.rfind('&', start, end)
|
183
|
-
assert mask > 0 and end - mask <= 13
|
184
|
-
fixed = update_fts(what[start:mask+1] + str(f_sizes[table]-1) + ']')
|
185
|
-
updates.append((start, end, fixed))
|
186
|
-
i = end # additional function table uses were done by recursion
|
187
|
-
# apply updates
|
188
|
-
if len(updates) == 0: return what
|
189
|
-
parts = []
|
190
|
-
so_far = 0
|
191
|
-
for i in range(len(updates)):
|
192
|
-
start, end, fixed = updates[i]
|
193
|
-
parts.append(what[so_far:start])
|
194
|
-
parts.append(fixed)
|
195
|
-
so_far = end+1
|
196
|
-
parts.append(what[so_far:])
|
197
|
-
return ''.join(parts)
|
198
|
-
|
199
|
-
main.funcs_js = update_fts(main.funcs_js)
|
200
|
-
main.extra_funcs_js = update_fts(main.extra_funcs_js)
|
201
|
-
|
202
|
-
# global initializers
|
203
|
-
if self.global_inits:
|
204
|
-
my_global_inits = map(lambda init: replacements[init] if init in replacements else init, self.global_inits)
|
205
|
-
all_global_inits = map(lambda init: '{ func: function() { %s() } }' % init, main.global_inits + my_global_inits)
|
206
|
-
all_global_inits_js = '/* global initializers */ __ATINIT__.push(' + ','.join(all_global_inits) + ');'
|
207
|
-
if main.global_inits:
|
208
|
-
target = main.global_inits_js
|
209
|
-
else:
|
210
|
-
target = '// === Body ===\n'
|
211
|
-
all_global_inits_js = target + all_global_inits_js
|
212
|
-
main.pre_js = main.pre_js.replace(target, all_global_inits_js)
|
213
|
-
|
214
|
-
# exports
|
215
|
-
def rep_exp(export):
|
216
|
-
key, value = export.split(':')
|
217
|
-
if key in replacements:
|
218
|
-
repped = replacements[key]
|
219
|
-
return repped + ': ' + repped
|
220
|
-
return export
|
221
|
-
my_exports = map(rep_exp, self.exports)
|
222
|
-
exports = main.exports.union(my_exports)
|
223
|
-
main.exports_js = 'return {' + ','.join(list(exports)) + '};\n})\n'
|
224
|
-
|
225
|
-
# post
|
226
|
-
def rep_def(deff):
|
227
|
-
key = deff.split(' ')[1]
|
228
|
-
if key in replacements:
|
229
|
-
rep = replacements[key]
|
230
|
-
return 'var %s = Module["%s"] = asm["%s"];\n' % (rep, rep, rep)
|
231
|
-
return deff
|
232
|
-
my_module_defs = map(rep_def, self.module_defs)
|
233
|
-
new_module_defs = set(my_module_defs).difference(main.module_defs)
|
234
|
-
if len(new_module_defs) > 0:
|
235
|
-
position = main.post_js.find('Runtime.') # Runtime is the start of the hardcoded ones
|
236
|
-
main.post_js = main.post_js[:position] + ''.join(list(new_module_defs)) + '\n' + main.post_js[position:]
|
237
|
-
|
238
|
-
def write(self, out):
|
239
|
-
f = open(out, 'w')
|
240
|
-
f.write(self.pre_js)
|
241
|
-
f.write(self.pre_imports_js)
|
242
|
-
f.write(self.imports_js)
|
243
|
-
f.write(self.funcs_js)
|
244
|
-
f.write(self.extra_funcs_js)
|
245
|
-
f.write(self.tables_js)
|
246
|
-
f.write(self.exports_js)
|
247
|
-
f.write(self.post_js)
|
248
|
-
f.close()
|
249
|
-
|
250
|
-
# Utilities
|
251
|
-
|
252
|
-
def parse_tables(self, js):
|
253
|
-
tables = {}
|
254
|
-
parts = js.split(';')
|
255
|
-
for part in parts:
|
256
|
-
if '=' not in part: continue
|
257
|
-
part = part.split('var ')[1]
|
258
|
-
name, data = part.split(' = ')
|
259
|
-
tables[name] = data
|
260
|
-
return tables
|
261
|
-
|
262
|
-
def merge_tables(self, table, main, side, replacements, f_bases, f_sizes):
|
263
|
-
sig = table.split('_')[-1]
|
264
|
-
side = side[1:-1].split(',')
|
265
|
-
side = map(lambda f: replacements[f] if f in replacements else f, side)
|
266
|
-
if not main:
|
267
|
-
f_bases[sig] = 0
|
268
|
-
f_sizes[table] = len(side)
|
269
|
-
return '[' + ','.join(side) + ']'
|
270
|
-
main = main[1:-1].split(',')
|
271
|
-
# TODO: handle non-aliasing case too
|
272
|
-
assert len(main) % 2 == 0
|
273
|
-
f_bases[sig] = len(main)
|
274
|
-
ret = main + side
|
275
|
-
size = 2
|
276
|
-
while size < len(ret): size *= 2
|
277
|
-
aborter = ret[1] # we can assume odd indexes have an aborting function with the right signature
|
278
|
-
ret = ret + [aborter]*(size - len(ret))
|
279
|
-
assert len(ret) == size
|
280
|
-
f_sizes[table] = size
|
281
|
-
return '[' + ','.join(ret) + ']'
|
282
|
-
|
283
|
-
def combine_tables(self):
|
284
|
-
self.tables_js = '// EMSCRIPTEN_END_FUNCS\n'
|
285
|
-
for table, data in self.tables.iteritems():
|
286
|
-
self.tables_js += 'var %s = %s;\n' % (table, data)
|
287
|
-
|
288
25
|
main = AsmModule(main)
|
289
26
|
side = AsmModule(side)
|
290
27
|
|
@@ -9,9 +9,8 @@ header files (so that the JS compiler can see the constants in those
|
|
9
9
|
headers, for the libc implementation in JS).
|
10
10
|
'''
|
11
11
|
|
12
|
-
import os, sys, json, optparse, subprocess, re, time, multiprocessing,
|
12
|
+
import os, sys, json, optparse, subprocess, re, time, multiprocessing, string
|
13
13
|
|
14
|
-
from tools import shared
|
15
14
|
from tools import jsrun, cache as cache_module, tempfiles
|
16
15
|
from tools.response_file import read_response_file
|
17
16
|
|
@@ -26,6 +25,7 @@ def get_configuration():
|
|
26
25
|
if hasattr(get_configuration, 'configuration'):
|
27
26
|
return get_configuration.configuration
|
28
27
|
|
28
|
+
from tools import shared
|
29
29
|
configuration = shared.Configuration(environ=os.environ)
|
30
30
|
get_configuration.configuration = configuration
|
31
31
|
return configuration
|
@@ -44,20 +44,25 @@ MIN_CHUNK_SIZE = 1024*1024
|
|
44
44
|
MAX_CHUNK_SIZE = float(os.environ.get('EMSCRIPT_MAX_CHUNK_SIZE') or 'inf') # configuring this is just for debugging purposes
|
45
45
|
|
46
46
|
def process_funcs((i, funcs, meta, settings_file, compiler, forwarded_file, libraries, compiler_engine, temp_files, DEBUG)):
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
47
|
+
try:
|
48
|
+
funcs_file = temp_files.get('.func_%d.ll' % i).name
|
49
|
+
f = open(funcs_file, 'w')
|
50
|
+
f.write(funcs)
|
51
|
+
funcs = None
|
52
|
+
f.write('\n')
|
53
|
+
f.write(meta)
|
54
|
+
f.close()
|
55
|
+
out = jsrun.run_js(
|
56
|
+
compiler,
|
57
|
+
engine=compiler_engine,
|
58
|
+
args=[settings_file, funcs_file, 'funcs', forwarded_file] + libraries,
|
59
|
+
stdout=subprocess.PIPE,
|
60
|
+
cwd=path_from_root('src'))
|
61
|
+
except KeyboardInterrupt:
|
62
|
+
# Python 2.7 seems to lock up when a child process throws KeyboardInterrupt
|
63
|
+
raise Exception()
|
64
|
+
finally:
|
65
|
+
tempfiles.try_delete(funcs_file)
|
61
66
|
if DEBUG: print >> sys.stderr, '.'
|
62
67
|
return out
|
63
68
|
|
@@ -286,8 +291,9 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
|
|
286
291
|
indexed_functions.add(key)
|
287
292
|
if settings.get('ASM_JS'):
|
288
293
|
export_bindings = settings['EXPORT_BINDINGS']
|
294
|
+
export_all = settings['EXPORT_ALL']
|
289
295
|
for key in curr_forwarded_json['Functions']['implementedFunctions'].iterkeys():
|
290
|
-
if key in all_exported_functions or (export_bindings and key.startswith('_emscripten_bind')):
|
296
|
+
if key in all_exported_functions or export_all or (export_bindings and key.startswith('_emscripten_bind')):
|
291
297
|
exported_implemented_functions.add(key)
|
292
298
|
for key, value in curr_forwarded_json['Functions']['unimplementedFunctions'].iteritems():
|
293
299
|
forwarded_json['Functions']['unimplementedFunctions'][key] = value
|
@@ -463,6 +469,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
|
|
463
469
|
}
|
464
470
|
|
465
471
|
''' % (sig, i, args, arg_coercions, jsret))
|
472
|
+
from tools import shared
|
466
473
|
asm_setup += '\n' + shared.JS.make_invoke(sig) + '\n'
|
467
474
|
basic_funcs.append('invoke_%s' % sig)
|
468
475
|
|
@@ -620,6 +627,19 @@ Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
|
|
620
627
|
// EMSCRIPTEN_END_FUNCS
|
621
628
|
''']
|
622
629
|
|
630
|
+
# Create symbol table for self-dlopen
|
631
|
+
if settings.get('DLOPEN_SUPPORT'):
|
632
|
+
symbol_table = {}
|
633
|
+
for k, v in forwarded_json['Variables']['indexedGlobals'].iteritems():
|
634
|
+
if forwarded_json['Variables']['globals'][k]['named']:
|
635
|
+
symbol_table[k] = v + forwarded_json['Runtime']['GLOBAL_BASE']
|
636
|
+
for raw in last_forwarded_json['Functions']['tables'].itervalues():
|
637
|
+
if raw == '': continue
|
638
|
+
table = map(string.strip, raw[raw.find('[')+1:raw.find(']')].split(","))
|
639
|
+
symbol_table.update(map(lambda x: (x[1], x[0]),
|
640
|
+
filter(lambda x: x[1] != '0', enumerate(table))))
|
641
|
+
outfile.write("var SYMBOL_TABLE = %s;" % json.dumps(symbol_table))
|
642
|
+
|
623
643
|
for funcs_js_item in funcs_js: # do this loop carefully to save memory
|
624
644
|
funcs_js_item = indexize(funcs_js_item)
|
625
645
|
funcs_js_item = blockaddrsize(funcs_js_item)
|
@@ -789,7 +809,7 @@ WARNING: You should normally never use this! Use emcc instead.
|
|
789
809
|
'''
|
790
810
|
|
791
811
|
if len(positional) != 1:
|
792
|
-
raise RuntimeError('Must provide exactly one positional argument.')
|
812
|
+
raise RuntimeError('Must provide exactly one positional argument. Got ' + str(len(positional)) + ': "' + '", "'.join(positional) + '"')
|
793
813
|
keywords.infile = os.path.abspath(positional[0])
|
794
814
|
if isinstance(keywords.outfile, basestring):
|
795
815
|
keywords.outfile = open(keywords.outfile, 'w')
|