webruby 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webruby/config.rb +4 -9
- data/lib/webruby/rake/files.rake +2 -2
- data/modules/emscripten/AUTHORS +9 -1
- data/modules/emscripten/CONTRIBUTING.markdown +5 -0
- data/modules/emscripten/ChangeLog +435 -0
- data/modules/emscripten/cmake/Modules/FindOpenAL.cmake +26 -0
- data/modules/emscripten/cmake/Platform/Emscripten.cmake +9 -2
- data/modules/emscripten/em++ +0 -2
- data/modules/emscripten/emcc +92 -32
- data/modules/emscripten/emlink.py +16 -13
- data/modules/emscripten/emmake +1 -1
- data/modules/emscripten/emrun +918 -0
- data/modules/emscripten/emrun.bat +2 -0
- data/modules/emscripten/emscripten.py +545 -20
- data/modules/emscripten/src/analyzer.js +6 -1
- data/modules/emscripten/src/compiler.js +25 -16
- data/modules/emscripten/src/emrun_postjs.js +20 -0
- data/modules/emscripten/{tests → src}/hello_world.js +0 -0
- data/modules/emscripten/src/intertyper.js +45 -16
- data/modules/emscripten/src/jsifier.js +78 -48
- data/modules/emscripten/src/library.js +381 -96
- data/modules/emscripten/src/library_browser.js +50 -53
- data/modules/emscripten/src/library_egl.js +66 -24
- data/modules/emscripten/src/library_fs.js +122 -90
- data/modules/emscripten/src/library_gl.js +739 -353
- data/modules/emscripten/src/library_glfw.js +9 -3
- data/modules/emscripten/src/library_glut.js +10 -5
- data/modules/emscripten/src/library_idbfs.js +14 -14
- data/modules/emscripten/src/library_memfs.js +65 -41
- data/modules/emscripten/src/library_nodefs.js +61 -9
- data/modules/emscripten/src/library_openal.js +4 -4
- data/modules/emscripten/src/library_path.js +9 -13
- data/modules/emscripten/src/library_sdl.js +301 -64
- data/modules/emscripten/src/library_sockfs.js +7 -5
- data/modules/emscripten/src/modules.js +62 -22
- data/modules/emscripten/src/parseTools.js +135 -102
- data/modules/emscripten/src/postamble.js +3 -4
- data/modules/emscripten/src/preamble.js +49 -29
- data/modules/emscripten/src/proxyClient.js +1 -1
- data/modules/emscripten/src/proxyWorker.js +10 -10
- data/modules/emscripten/src/relooper/Relooper.cpp +15 -4
- data/modules/emscripten/src/runtime.js +32 -8
- data/modules/emscripten/src/settings.js +25 -8
- data/modules/emscripten/src/shell.html +6 -3
- data/modules/emscripten/src/shell.js +13 -11
- data/modules/emscripten/src/simd.js +602 -432
- data/modules/emscripten/src/struct_info.json +22 -2
- data/modules/emscripten/src/utility.js +32 -17
- data/modules/emscripten/system/include/SDL/SDL_events.h +1 -0
- data/modules/emscripten/system/include/compat/ctype.h +17 -0
- data/modules/emscripten/system/include/compat/wchar.h +23 -0
- data/modules/emscripten/system/include/compat/wctype.h +23 -0
- data/modules/emscripten/system/include/emscripten/emmintrin.h +87 -0
- data/modules/emscripten/system/include/emscripten/emscripten.h +30 -4
- data/modules/emscripten/system/include/emscripten/vector.h +29 -1
- data/modules/emscripten/system/include/emscripten/xmmintrin.h +131 -0
- data/modules/emscripten/system/include/libcxx/CREDITS.TXT +9 -1
- data/modules/emscripten/system/include/libcxx/__bit_reference +8 -8
- data/modules/emscripten/system/include/libcxx/__config +95 -17
- data/modules/emscripten/system/include/libcxx/__debug +25 -4
- data/modules/emscripten/system/include/libcxx/__functional_03 +7 -7
- data/modules/emscripten/system/include/libcxx/__functional_base +169 -9
- data/modules/emscripten/system/include/libcxx/__functional_base_03 +1 -1
- data/modules/emscripten/system/include/libcxx/__hash_table +25 -25
- data/modules/emscripten/system/include/libcxx/__locale +21 -19
- data/modules/emscripten/system/include/libcxx/__mutex_base +2 -33
- data/modules/emscripten/system/include/libcxx/__split_buffer +9 -9
- data/modules/emscripten/system/include/libcxx/__std_stream +14 -0
- data/modules/emscripten/system/include/libcxx/__tree +35 -26
- data/modules/emscripten/system/include/libcxx/__tuple +15 -15
- data/modules/emscripten/system/include/libcxx/__tuple_03 +2 -2
- data/modules/emscripten/system/include/libcxx/__undef_min_max +8 -0
- data/modules/emscripten/system/include/libcxx/algorithm +121 -110
- data/modules/emscripten/system/include/libcxx/array +15 -15
- data/modules/emscripten/system/include/libcxx/bitset +4 -4
- data/modules/emscripten/system/include/libcxx/chrono +51 -17
- data/modules/emscripten/system/include/libcxx/cmath +25 -23
- data/modules/emscripten/system/include/libcxx/codecvt +21 -18
- data/modules/emscripten/system/include/libcxx/complex +48 -7
- data/modules/emscripten/system/include/libcxx/cstddef +1 -1
- data/modules/emscripten/system/include/libcxx/cstdio +8 -1
- data/modules/emscripten/system/include/libcxx/cstdlib +1 -1
- data/modules/emscripten/system/include/libcxx/cwchar +1 -1
- data/modules/emscripten/system/include/libcxx/deque +26 -12
- data/modules/emscripten/system/include/libcxx/dynarray +311 -0
- data/modules/emscripten/system/include/libcxx/exception +4 -4
- data/modules/emscripten/system/include/libcxx/ext/__hash +3 -3
- data/modules/emscripten/system/include/libcxx/ext/hash_map +19 -15
- data/modules/emscripten/system/include/libcxx/ext/hash_set +7 -3
- data/modules/emscripten/system/include/libcxx/forward_list +33 -7
- data/modules/emscripten/system/include/libcxx/fstream +4 -4
- data/modules/emscripten/system/include/libcxx/functional +200 -170
- data/modules/emscripten/system/include/libcxx/future +83 -39
- data/modules/emscripten/system/include/libcxx/initializer_list +24 -11
- data/modules/emscripten/system/include/libcxx/iomanip +147 -0
- data/modules/emscripten/system/include/libcxx/ios +24 -16
- data/modules/emscripten/system/include/libcxx/iosfwd +19 -19
- data/modules/emscripten/system/include/libcxx/istream +13 -8
- data/modules/emscripten/system/include/libcxx/iterator +108 -417
- data/modules/emscripten/system/include/libcxx/limits +8 -4
- data/modules/emscripten/system/include/libcxx/list +28 -8
- data/modules/emscripten/system/include/libcxx/locale +153 -390
- data/modules/emscripten/system/include/libcxx/map +280 -100
- data/modules/emscripten/system/include/libcxx/memory +49 -97
- data/modules/emscripten/system/include/libcxx/mutex +2 -2
- data/modules/emscripten/system/include/libcxx/new +43 -14
- data/modules/emscripten/system/include/libcxx/numeric +2 -2
- data/modules/emscripten/system/include/libcxx/optional +697 -0
- data/modules/emscripten/system/include/libcxx/ostream +17 -8
- data/modules/emscripten/system/include/libcxx/queue +5 -5
- data/modules/emscripten/system/include/libcxx/random +53 -51
- data/modules/emscripten/system/include/libcxx/ratio +11 -11
- data/modules/emscripten/system/include/libcxx/readme.txt +1 -1
- data/modules/emscripten/system/include/libcxx/regex +23 -20
- data/modules/emscripten/system/include/libcxx/scoped_allocator +1 -1
- data/modules/emscripten/system/include/libcxx/set +166 -2
- data/modules/emscripten/system/include/libcxx/shared_mutex +419 -0
- data/modules/emscripten/system/include/libcxx/sstream +4 -4
- data/modules/emscripten/system/include/libcxx/stack +3 -3
- data/modules/emscripten/system/include/libcxx/streambuf +5 -5
- data/modules/emscripten/system/include/libcxx/string +372 -324
- data/modules/emscripten/system/include/libcxx/support/ibm/limits.h +99 -0
- data/modules/emscripten/system/include/libcxx/support/ibm/support.h +54 -0
- data/modules/emscripten/system/include/libcxx/support/ibm/xlocale.h +326 -0
- data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +6 -6
- data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +15 -15
- data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +2 -0
- data/modules/emscripten/system/include/libcxx/support/win32/support.h +6 -1
- data/modules/emscripten/system/include/libcxx/system_error +14 -8
- data/modules/emscripten/system/include/libcxx/thread +7 -8
- data/modules/emscripten/system/include/libcxx/tuple +29 -88
- data/modules/emscripten/system/include/libcxx/type_traits +253 -209
- data/modules/emscripten/system/include/libcxx/typeindex +3 -3
- data/modules/emscripten/system/include/libcxx/unordered_map +162 -101
- data/modules/emscripten/system/include/libcxx/unordered_set +79 -2
- data/modules/emscripten/system/include/libcxx/utility +20 -20
- data/modules/emscripten/system/include/libcxx/valarray +23 -23
- data/modules/emscripten/system/include/libcxx/vector +114 -91
- data/modules/emscripten/system/lib/libc/musl/src/regex/regcomp.c +3352 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/regerror.c +35 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/regexec.c +1011 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/tre-mem.c +158 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/tre.h +231 -0
- data/modules/emscripten/system/lib/libcextra.symbols +7 -0
- data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +9 -1
- data/modules/emscripten/system/lib/libcxx/algorithm.cpp +1 -0
- data/modules/emscripten/system/lib/libcxx/debug.cpp +66 -42
- data/modules/emscripten/system/lib/libcxx/exception.cpp +88 -16
- data/modules/emscripten/system/lib/libcxx/future.cpp +6 -0
- data/modules/emscripten/system/lib/libcxx/ios.cpp +7 -2
- data/modules/emscripten/system/lib/libcxx/iostream.cpp +8 -8
- data/modules/emscripten/system/lib/libcxx/locale.cpp +38 -11
- data/modules/emscripten/system/lib/libcxx/mutex.cpp +3 -0
- data/modules/emscripten/system/lib/libcxx/new.cpp +44 -10
- data/modules/emscripten/system/lib/libcxx/optional.cpp +25 -0
- data/modules/emscripten/system/lib/libcxx/random.cpp +26 -0
- data/modules/emscripten/system/lib/libcxx/readme.txt +1 -1
- data/modules/emscripten/system/lib/libcxx/shared_mutex.cpp +101 -0
- data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +11 -7
- data/modules/emscripten/system/lib/libcxx/string.cpp +3 -1
- data/modules/emscripten/system/lib/libcxx/strstream.cpp +7 -7
- data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +12 -13
- data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +33 -36
- data/modules/emscripten/system/lib/libcxx/symbols +187 -168
- data/modules/emscripten/system/lib/libcxx/system_error.cpp +1 -0
- data/modules/emscripten/system/lib/libcxx/thread.cpp +7 -3
- data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +9 -6
- data/modules/emscripten/system/lib/libcxx/valarray.cpp +2 -0
- data/modules/emscripten/third_party/lzma.js/doit.bat +4 -0
- data/modules/emscripten/third_party/lzma.js/doit.sh +9 -2
- data/modules/emscripten/tools/cache.py +5 -7
- data/modules/emscripten/tools/cache.pyc +0 -0
- data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +7 -0
- data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +9 -1
- data/modules/emscripten/tools/eliminator/eliminator-test-output.js +3 -0
- data/modules/emscripten/tools/eliminator/eliminator-test.js +9 -1
- data/modules/emscripten/tools/file_packager.py +93 -50
- data/modules/emscripten/tools/js-optimizer.js +98 -48
- data/modules/emscripten/tools/js_optimizer.py +4 -4
- data/modules/emscripten/tools/js_optimizer.pyc +0 -0
- data/modules/emscripten/tools/jsrun.py +1 -1
- data/modules/emscripten/tools/jsrun.pyc +0 -0
- data/modules/emscripten/tools/response_file.py +6 -0
- data/modules/emscripten/tools/response_file.pyc +0 -0
- data/modules/emscripten/tools/settings_template_readonly.py +2 -0
- data/modules/emscripten/tools/shared.py +88 -34
- data/modules/emscripten/tools/shared.pyc +0 -0
- data/modules/emscripten/tools/split.py +21 -13
- data/modules/mruby/build_config.rb +7 -1
- data/modules/mruby/doc/compile/README.md +5 -9
- data/modules/mruby/include/mrbconf.h +5 -2
- data/modules/mruby/include/mruby/array.h +1 -0
- data/modules/mruby/include/mruby/compile.h +2 -4
- data/modules/mruby/include/mruby/dump.h +7 -16
- data/modules/mruby/include/mruby/hash.h +1 -1
- data/modules/mruby/include/mruby/irep.h +14 -2
- data/modules/mruby/include/mruby/khash.h +8 -7
- data/modules/mruby/include/mruby/string.h +1 -0
- data/modules/mruby/include/mruby/value.h +5 -2
- data/modules/mruby/include/mruby.h +12 -13
- data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +16 -6
- data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +18 -30
- data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +21 -0
- data/modules/mruby/mrbgems/mruby-math/src/math.c +1 -1
- data/modules/mruby/mrbgems/mruby-random/src/random.c +144 -47
- data/modules/mruby/mrbgems/mruby-random/test/random.rb +44 -0
- data/modules/mruby/mrbgems/mruby-struct/src/struct.c +5 -5
- data/modules/mruby/mrblib/numeric.rb +99 -33
- data/modules/mruby/src/array.c +11 -4
- data/modules/mruby/src/backtrace.c +2 -2
- data/modules/mruby/src/class.c +49 -30
- data/modules/mruby/src/codegen.c +131 -79
- data/modules/mruby/src/debug.c +1 -1
- data/modules/mruby/src/dump.c +213 -163
- data/modules/mruby/src/error.c +17 -17
- data/modules/mruby/src/error.h +1 -1
- data/modules/mruby/src/etc.c +10 -0
- data/modules/mruby/src/gc.c +35 -17
- data/modules/mruby/src/hash.c +5 -5
- data/modules/mruby/src/kernel.c +36 -14
- data/modules/mruby/src/load.c +238 -296
- data/modules/mruby/src/numeric.c +18 -98
- data/modules/mruby/src/object.c +3 -5
- data/modules/mruby/src/parse.y +63 -56
- data/modules/mruby/src/proc.c +8 -5
- data/modules/mruby/src/re.h +0 -1
- data/modules/mruby/src/state.c +65 -27
- data/modules/mruby/src/string.c +3 -31
- data/modules/mruby/src/symbol.c +3 -3
- data/modules/mruby/src/variable.c +12 -5
- data/modules/mruby/src/vm.c +90 -72
- data/modules/mruby/tasks/mruby_build.rake +10 -1
- data/modules/mruby/tasks/toolchains/gcc.rake +12 -2
- data/modules/mruby/tasks/toolchains/{vs2012.rake → visualcpp.rake} +1 -1
- data/modules/mruby/test/driver.c +3 -3
- data/modules/mruby/test/t/array.rb +5 -5
- data/modules/mruby/test/t/class.rb +14 -1
- data/modules/mruby/test/t/kernel.rb +4 -0
- data/modules/mruby/test/t/module.rb +4 -4
- data/modules/mruby/test/t/nameerror.rb +1 -1
- data/modules/mruby/tools/mrbc/mrbc.c +23 -17
- data/modules/mruby/travis_config.rb +10 -1
- metadata +28 -5
- data/modules/mruby/tasks/toolchains/vs2010.rake +0 -3
@@ -14,9 +14,9 @@
|
|
14
14
|
#include "limits"
|
15
15
|
#include <sys/types.h>
|
16
16
|
#if !defined(_WIN32)
|
17
|
-
#if !defined(__sun__) && !defined(__linux__)
|
17
|
+
#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX)
|
18
18
|
#include <sys/sysctl.h>
|
19
|
-
#endif // !__sun__ && !__linux__
|
19
|
+
#endif // !__sun__ && !__linux__ && !_AIX
|
20
20
|
#include <unistd.h>
|
21
21
|
#endif // !_WIN32
|
22
22
|
|
@@ -89,7 +89,11 @@ thread::hardware_concurrency() _NOEXCEPT
|
|
89
89
|
#else // defined(CTL_HW) && defined(HW_NCPU)
|
90
90
|
// TODO: grovel through /proc or check cpuid on x86 and similar
|
91
91
|
// instructions on other architectures.
|
92
|
-
#
|
92
|
+
# if defined(_MSC_VER) && ! defined(__clang__)
|
93
|
+
_LIBCPP_WARNING("hardware_concurrency not yet implemented")
|
94
|
+
# else
|
95
|
+
# warning hardware_concurrency not yet implemented
|
96
|
+
# endif
|
93
97
|
return 0; // Means not computable [thread.thread.static]
|
94
98
|
#endif // defined(CTL_HW) && defined(HW_NCPU)
|
95
99
|
}
|
@@ -20,12 +20,18 @@
|
|
20
20
|
|
21
21
|
#include "typeinfo"
|
22
22
|
|
23
|
-
#if !
|
23
|
+
#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
|
24
24
|
|
25
25
|
std::bad_cast::bad_cast() _NOEXCEPT
|
26
26
|
{
|
27
27
|
}
|
28
28
|
|
29
|
+
std::bad_typeid::bad_typeid() _NOEXCEPT
|
30
|
+
{
|
31
|
+
}
|
32
|
+
|
33
|
+
#ifndef __GLIBCXX__
|
34
|
+
|
29
35
|
std::bad_cast::~bad_cast() _NOEXCEPT
|
30
36
|
{
|
31
37
|
}
|
@@ -36,10 +42,6 @@ std::bad_cast::what() const _NOEXCEPT
|
|
36
42
|
return "std::bad_cast";
|
37
43
|
}
|
38
44
|
|
39
|
-
std::bad_typeid::bad_typeid() _NOEXCEPT
|
40
|
-
{
|
41
|
-
}
|
42
|
-
|
43
45
|
std::bad_typeid::~bad_typeid() _NOEXCEPT
|
44
46
|
{
|
45
47
|
}
|
@@ -67,4 +69,5 @@ std::bad_typeid::what() const _NOEXCEPT
|
|
67
69
|
}
|
68
70
|
#endif
|
69
71
|
|
70
|
-
#endif //
|
72
|
+
#endif // !__GLIBCXX__
|
73
|
+
#endif // !LIBCXXRT && !_LIBCPPABI_VERSION
|
@@ -5,7 +5,14 @@ export CXX=`../../../em-config LLVM_ROOT`/clang++
|
|
5
5
|
echo "native"
|
6
6
|
make clean
|
7
7
|
DECODER_ONLY=0 make lzip -j 4 # native build
|
8
|
-
|
8
|
+
case `uname` in
|
9
|
+
*_NT*)
|
10
|
+
mv lzip.exe ../lzma-native.exe
|
11
|
+
;;
|
12
|
+
*)
|
13
|
+
mv lzip ../lzma-native
|
14
|
+
;;
|
15
|
+
esac
|
9
16
|
|
10
17
|
exit # just build natively, that's it
|
11
18
|
|
@@ -18,7 +25,7 @@ echo "bitcode decoder only"
|
|
18
25
|
make clean
|
19
26
|
DECODER_ONLY=1 ../../../emmake make lzip -j 4
|
20
27
|
mv lzip lzip-decoder.bc
|
21
|
-
|
28
|
+
|
22
29
|
cd ..
|
23
30
|
|
24
31
|
echo "javascript full"
|
@@ -13,8 +13,7 @@ class Cache:
|
|
13
13
|
self.debug = debug
|
14
14
|
|
15
15
|
def ensure(self):
|
16
|
-
|
17
|
-
os.makedirs(self.dirname)
|
16
|
+
shared.safe_ensure_dirs(self.dirname)
|
18
17
|
|
19
18
|
def erase(self):
|
20
19
|
tempfiles.try_delete(self.dirname)
|
@@ -48,11 +47,7 @@ class JCache:
|
|
48
47
|
|
49
48
|
def ensure(self):
|
50
49
|
self.cache.ensure()
|
51
|
-
|
52
|
-
try:
|
53
|
-
os.makedirs(self.dirname)
|
54
|
-
except (IOError, OSError):
|
55
|
-
pass
|
50
|
+
shared.safe_ensure_dirs(self.dirname)
|
56
51
|
|
57
52
|
def get_shortkey(self, keys):
|
58
53
|
if type(keys) not in [list, tuple]:
|
@@ -196,3 +191,6 @@ def chunkify(funcs, chunk_size, chunking_file, DEBUG=False):
|
|
196
191
|
# if previous_mapping.get(ident) != new_mapping.get(ident):
|
197
192
|
# print >> sys.stderr, 'mapping inconsistency', ident, previous_mapping.get(ident), new_mapping.get(ident)
|
198
193
|
return [''.join([func[1] for func in chunk]) for chunk in chunks] # remove function names
|
194
|
+
|
195
|
+
import shared
|
196
|
+
|
Binary file
|
@@ -291,4 +291,11 @@ function watIf() {
|
|
291
291
|
if ($cmp38) {} else {}
|
292
292
|
}
|
293
293
|
}
|
294
|
+
function select2($foundBase_0_off0) {
|
295
|
+
$foundBase_0_off0 = $foundBase_0_off0 | 0;
|
296
|
+
var $call24 = 0;
|
297
|
+
$call24 = MUST_RUN() | 0;
|
298
|
+
STACKTOP = sp;
|
299
|
+
return ($foundBase_0_off0 ? 0 : $call24) | 0;
|
300
|
+
}
|
294
301
|
|
@@ -362,5 +362,13 @@ function watIf() {
|
|
362
362
|
}
|
363
363
|
}
|
364
364
|
}
|
365
|
-
|
365
|
+
function select2($foundBase_0_off0) {
|
366
|
+
$foundBase_0_off0 = $foundBase_0_off0 | 0;
|
367
|
+
var $call24 = 0, $retval_0 = 0;
|
368
|
+
$call24 = MUST_RUN() | 0;
|
369
|
+
$retval_0 = $foundBase_0_off0 ? 0 : $call24;
|
370
|
+
STACKTOP = sp;
|
371
|
+
return $retval_0 | 0;
|
372
|
+
}
|
373
|
+
// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf", "select2"]
|
366
374
|
|
@@ -8852,5 +8852,13 @@ function intoCond() {
|
|
8852
8852
|
HEAP32[$504 >> 2] = $503;
|
8853
8853
|
}
|
8854
8854
|
}
|
8855
|
-
|
8855
|
+
function math(a, b, c, d) {
|
8856
|
+
var x, y, z, w;
|
8857
|
+
x = a;
|
8858
|
+
y = Math_abs(b);
|
8859
|
+
z = Math_fround(c);
|
8860
|
+
w = Math_imul(d);
|
8861
|
+
print(x + y + z + w);
|
8862
|
+
}
|
8863
|
+
// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU", "asm", "phi", "intoCond", "math"]
|
8856
8864
|
|
@@ -11,10 +11,7 @@ data downloads.
|
|
11
11
|
|
12
12
|
Usage:
|
13
13
|
|
14
|
-
file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--
|
15
|
-
|
16
|
-
--pre-run Will generate wrapper code that does preloading in Module.preRun. This is necessary if you add this
|
17
|
-
code before the main file has been loading, which includes necessary components like addRunDependency.
|
14
|
+
file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
|
18
15
|
|
19
16
|
--crunch=X Will compress dxt files to crn with quality level X. The crunch commandline tool must be present
|
20
17
|
and CRUNCH should be defined in ~/.emscripten that points to it. JS crunch decompressing code will
|
@@ -30,6 +27,10 @@ Usage:
|
|
30
27
|
|
31
28
|
--use-preload-cache Stores package in IndexedDB so that subsequent loads don't need to do XHR. Checks package version.
|
32
29
|
|
30
|
+
--no-heap-copy If specified, the preloaded filesystem is not copied inside the Emscripten HEAP, but kept in a separate typed array outside it.
|
31
|
+
The default, if this is not specified, is to embed the VFS inside the HEAP, so that mmap()ing files in it is a no-op.
|
32
|
+
Passing this flag optimizes for fread() usage, omitting it optimizes for mmap() usage.
|
33
|
+
|
33
34
|
Notes:
|
34
35
|
|
35
36
|
* The file packager generates unix-style file paths. So if you are on windows and a file is accessed at
|
@@ -46,7 +47,7 @@ from shared import Compression, execute, suffix, unsuffixed
|
|
46
47
|
from subprocess import Popen, PIPE, STDOUT
|
47
48
|
|
48
49
|
if len(sys.argv) == 1:
|
49
|
-
print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--compress COMPRESSION_DATA] [--
|
50
|
+
print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
|
50
51
|
See the source for more details.'''
|
51
52
|
sys.exit(0)
|
52
53
|
|
@@ -69,12 +70,16 @@ in_preload = False
|
|
69
70
|
in_embed = False
|
70
71
|
has_preloaded = False
|
71
72
|
in_compress = 0
|
72
|
-
pre_run = False
|
73
73
|
crunch = 0
|
74
74
|
plugins = []
|
75
75
|
jsoutput = None
|
76
76
|
force = True
|
77
|
+
# If set to True, IndexedDB (IDBFS in library_idbfs.js) is used to locally cache VFS XHR so that subsequent
|
78
|
+
# page loads can read the data from the offline cache instead.
|
77
79
|
use_preload_cache = False
|
80
|
+
# If set to True, the blob received from XHR is moved to the Emscripten HEAP, optimizing for mmap() performance.
|
81
|
+
# If set to False, the XHR blob is kept intact, and fread()s etc. are performed directly to that data. This optimizes for minimal memory usage and fread() performance.
|
82
|
+
no_heap_copy = True
|
78
83
|
|
79
84
|
for arg in sys.argv[1:]:
|
80
85
|
if arg == '--preload':
|
@@ -91,15 +96,12 @@ for arg in sys.argv[1:]:
|
|
91
96
|
in_compress = 1
|
92
97
|
in_preload = False
|
93
98
|
in_embed = False
|
94
|
-
elif arg == '--pre-run':
|
95
|
-
pre_run = True
|
96
|
-
in_preload = False
|
97
|
-
in_embed = False
|
98
|
-
in_compress = 0
|
99
99
|
elif arg == '--no-force':
|
100
100
|
force = False
|
101
101
|
elif arg == '--use-preload-cache':
|
102
102
|
use_preload_cache = True
|
103
|
+
elif arg == '--no-heap-copy':
|
104
|
+
no_heap_copy = False
|
103
105
|
elif arg.startswith('--js-output'):
|
104
106
|
jsoutput = arg.split('=')[1] if '=' in arg else None
|
105
107
|
elif arg.startswith('--crunch'):
|
@@ -141,6 +143,13 @@ if (not force) and len(data_files) == 0:
|
|
141
143
|
has_preloaded = False
|
142
144
|
|
143
145
|
ret = '''
|
146
|
+
var Module;
|
147
|
+
if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
|
148
|
+
if (!Module.expectedDataFileDownloads) {
|
149
|
+
Module.expectedDataFileDownloads = 0;
|
150
|
+
Module.finishedDataFileDownloads = 0;
|
151
|
+
}
|
152
|
+
Module.expectedDataFileDownloads++;
|
144
153
|
(function() {
|
145
154
|
'''
|
146
155
|
|
@@ -345,18 +354,9 @@ if has_preloaded:
|
|
345
354
|
send: function() {},
|
346
355
|
onload: function() {
|
347
356
|
var byteArray = this.byteArray.subarray(this.start, this.end);
|
348
|
-
|
349
|
-
var ddsHeader = byteArray.subarray(0, 128);
|
350
|
-
var that = this;
|
351
|
-
requestDecrunch(this.name, byteArray.subarray(128), function(ddsData) {
|
352
|
-
byteArray = new Uint8Array(ddsHeader.length + ddsData.length);
|
353
|
-
byteArray.set(ddsHeader, 0);
|
354
|
-
byteArray.set(ddsData, 128);
|
355
|
-
that.finish(byteArray);
|
356
|
-
});
|
357
|
-
} else {
|
357
|
+
%s
|
358
358
|
this.finish(byteArray);
|
359
|
-
|
359
|
+
%s
|
360
360
|
},
|
361
361
|
finish: function(byteArray) {
|
362
362
|
var that = this;
|
@@ -366,13 +366,26 @@ if has_preloaded:
|
|
366
366
|
if (that.audio) {
|
367
367
|
Module['removeRunDependency']('fp ' + that.name); // workaround for chromium bug 124926 (still no audio with this, but at least we don't hang)
|
368
368
|
} else {
|
369
|
-
|
369
|
+
Module.printErr('Preloading file ' + that.name + ' failed');
|
370
370
|
}
|
371
371
|
}, false, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
|
372
372
|
this.requests[this.name] = null;
|
373
373
|
},
|
374
374
|
};
|
375
|
-
'''
|
375
|
+
''' % ('' if not crunch else '''
|
376
|
+
if (this.crunched) {
|
377
|
+
var ddsHeader = byteArray.subarray(0, 128);
|
378
|
+
var that = this;
|
379
|
+
requestDecrunch(this.name, byteArray.subarray(128), function(ddsData) {
|
380
|
+
byteArray = new Uint8Array(ddsHeader.length + ddsData.length);
|
381
|
+
byteArray.set(ddsHeader, 0);
|
382
|
+
byteArray.set(ddsData, 128);
|
383
|
+
that.finish(byteArray);
|
384
|
+
});
|
385
|
+
} else {
|
386
|
+
''', '' if not crunch else '''
|
387
|
+
}
|
388
|
+
''')
|
376
389
|
|
377
390
|
counter = 0
|
378
391
|
for file_ in data_files:
|
@@ -412,11 +425,17 @@ for file_ in data_files:
|
|
412
425
|
|
413
426
|
if has_preloaded:
|
414
427
|
# Get the big archive and split it up
|
415
|
-
|
428
|
+
if no_heap_copy:
|
429
|
+
use_data = '''
|
416
430
|
// copy the entire loaded file into a spot in the heap. Files will refer to slices in that. They cannot be freed though.
|
417
431
|
var ptr = Module['_malloc'](byteArray.length);
|
418
432
|
Module['HEAPU8'].set(byteArray, ptr);
|
419
433
|
DataRequest.prototype.byteArray = Module['HEAPU8'].subarray(ptr, ptr+byteArray.length);
|
434
|
+
'''
|
435
|
+
else:
|
436
|
+
use_data = '''
|
437
|
+
// Reuse the bytearray from the XHR as the source for file reads.
|
438
|
+
DataRequest.prototype.byteArray = byteArray;
|
420
439
|
'''
|
421
440
|
for file_ in data_files:
|
422
441
|
if file_['mode'] == 'preload':
|
@@ -432,18 +451,19 @@ if has_preloaded:
|
|
432
451
|
''' % use_data
|
433
452
|
|
434
453
|
package_uuid = uuid.uuid4();
|
454
|
+
remote_package_name = os.path.basename(Compression.compressed_name(data_target) if Compression.on else data_target)
|
435
455
|
code += r'''
|
436
|
-
|
437
|
-
|
438
|
-
|
456
|
+
var PACKAGE_PATH;
|
457
|
+
if (typeof window === 'object') {
|
458
|
+
PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
|
459
|
+
} else {
|
460
|
+
// worker
|
461
|
+
PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/');
|
439
462
|
}
|
440
|
-
Module.expectedDataFileDownloads++;
|
441
|
-
|
442
|
-
var PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
|
443
463
|
var PACKAGE_NAME = '%s';
|
444
464
|
var REMOTE_PACKAGE_NAME = '%s';
|
445
465
|
var PACKAGE_UUID = '%s';
|
446
|
-
''' % (data_target,
|
466
|
+
''' % (data_target, remote_package_name, package_uuid)
|
447
467
|
|
448
468
|
if use_preload_cache:
|
449
469
|
code += r'''
|
@@ -536,7 +556,7 @@ if has_preloaded:
|
|
536
556
|
};
|
537
557
|
'''
|
538
558
|
|
539
|
-
|
559
|
+
ret += r'''
|
540
560
|
function fetchRemotePackage(packageName, callback, errback) {
|
541
561
|
var xhr = new XMLHttpRequest();
|
542
562
|
xhr.open('GET', packageName, true);
|
@@ -564,9 +584,9 @@ if has_preloaded:
|
|
564
584
|
num++;
|
565
585
|
}
|
566
586
|
total = Math.ceil(total * Module.expectedDataFileDownloads/num);
|
567
|
-
Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')');
|
587
|
+
if (Module['setStatus']) Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')');
|
568
588
|
} else if (!Module.dataFileDownloads) {
|
569
|
-
Module['setStatus']('Downloading data...');
|
589
|
+
if (Module['setStatus']) Module['setStatus']('Downloading data...');
|
570
590
|
}
|
571
591
|
};
|
572
592
|
xhr.onload = function(event) {
|
@@ -576,6 +596,12 @@ if has_preloaded:
|
|
576
596
|
xhr.send(null);
|
577
597
|
};
|
578
598
|
|
599
|
+
function handleError(error) {
|
600
|
+
console.error('package error:', error);
|
601
|
+
};
|
602
|
+
'''
|
603
|
+
|
604
|
+
code += r'''
|
579
605
|
function processPackageData(arrayBuffer) {
|
580
606
|
Module.finishedDataFileDownloads++;
|
581
607
|
assert(arrayBuffer, 'Loading data file failed.');
|
@@ -584,15 +610,10 @@ if has_preloaded:
|
|
584
610
|
%s
|
585
611
|
};
|
586
612
|
Module['addRunDependency']('datafile_%s');
|
587
|
-
|
588
|
-
function handleError(error) {
|
589
|
-
console.error('package error:', error);
|
590
|
-
};
|
591
613
|
''' % (use_data, data_target) # use basename because from the browser's point of view, we need to find the datafile in the same dir as the html file
|
592
614
|
|
593
615
|
code += r'''
|
594
|
-
if (!Module.preloadResults)
|
595
|
-
Module.preloadResults = {};
|
616
|
+
if (!Module.preloadResults) Module.preloadResults = {};
|
596
617
|
'''
|
597
618
|
|
598
619
|
if use_preload_cache:
|
@@ -631,21 +652,43 @@ if has_preloaded:
|
|
631
652
|
if (Module['setStatus']) Module['setStatus']('Downloading...');
|
632
653
|
'''
|
633
654
|
else:
|
655
|
+
# Not using preload cache, so we might as well start the xhr ASAP, potentially before JS parsing of the main codebase if it's after us.
|
656
|
+
# Only tricky bit is the fetch is async, but also when runWithFS is called is async, so we handle both orderings.
|
657
|
+
ret += r'''
|
658
|
+
var fetched = null, fetchedCallback = null;
|
659
|
+
fetchRemotePackage('%s', function(data) {
|
660
|
+
if (fetchedCallback) {
|
661
|
+
fetchedCallback(data);
|
662
|
+
fetchedCallback = null;
|
663
|
+
} else {
|
664
|
+
fetched = data;
|
665
|
+
}
|
666
|
+
}, handleError);
|
667
|
+
''' % os.path.basename(Compression.compressed_name(data_target) if Compression.on else data_target)
|
668
|
+
|
634
669
|
code += r'''
|
635
670
|
Module.preloadResults[PACKAGE_NAME] = {fromCache: false};
|
636
|
-
|
671
|
+
if (fetched) {
|
672
|
+
processPackageData(fetched);
|
673
|
+
fetched = null;
|
674
|
+
} else {
|
675
|
+
fetchedCallback = processPackageData;
|
676
|
+
}
|
637
677
|
'''
|
638
678
|
|
639
|
-
|
640
|
-
|
641
|
-
if (typeof Module == 'undefined') Module = {};
|
642
|
-
if (!Module['preRun']) Module['preRun'] = [];
|
643
|
-
Module["preRun"].push(function() {
|
679
|
+
ret += '''
|
680
|
+
function runWithFS() {
|
644
681
|
'''
|
645
682
|
ret += code
|
646
|
-
|
647
|
-
|
648
|
-
|
683
|
+
ret += '''
|
684
|
+
}
|
685
|
+
if (Module['calledRun']) {
|
686
|
+
runWithFS();
|
687
|
+
} else {
|
688
|
+
if (!Module['preRun']) Module['preRun'] = [];
|
689
|
+
Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
|
690
|
+
}
|
691
|
+
'''
|
649
692
|
|
650
693
|
if crunch:
|
651
694
|
ret += '''
|