aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/runner.py51
-rwxr-xr-xtools/bindings_generator.py29
-rwxr-xr-xtools/emmaken.py23
-rw-r--r--tools/shared.py1
4 files changed, 75 insertions, 29 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 84545069..e24ea5b1 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -2990,8 +2990,10 @@ if 'benchmark' not in str(sys.argv):
# Build a library into a .bc file. We build the .bc file once and cache it for all our tests. (We cache in
# memory since the test directory is destroyed and recreated for each test. Note that we cache separately
# for different compilers)
- def get_library(self, name, generated_libs, configure=['./configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=True):
+ def get_library(self, name, generated_libs, configure=['./configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=True, build_subdir=None):
if type(generated_libs) is not list: generated_libs = [generated_libs]
+ if build_subdir and configure.startswith('./'):
+ configure = '.' + configure
if GlobalCache is not None:
cache_name = name + '|' + COMPILER
@@ -3007,16 +3009,24 @@ if 'benchmark' not in str(sys.argv):
project_dir = os.path.join(temp_dir, name)
shutil.copytree(path_from_root('tests', name), project_dir) # Useful in debugging sometimes to comment this out
os.chdir(project_dir)
+ if build_subdir:
+ try:
+ os.mkdir('cbuild')
+ except:
+ pass
+ os.chdir(os.path.join(project_dir, 'cbuild'))
env = os.environ.copy()
env['RANLIB'] = env['AR'] = env['CXX'] = env['CC'] = env['LIBTOOL'] = EMMAKEN
env['EMMAKEN_COMPILER'] = COMPILER
env['EMSCRIPTEN_TOOLS'] = path_from_root('tools')
env['CFLAGS'] = env['EMMAKEN_CFLAGS'] = ' '.join(COMPILER_OPTS + COMPILER_TEST_OPTS) # Normal CFLAGS is ignored by some configure's.
- if configure: # Useful in debugging sometimes to comment this out (and 2 lines below)
+ if configure: # Useful in debugging sometimes to comment this out (and the lines below up to and including the |make| call)
+ env['EMMAKEN_JUST_CONFIGURE'] = '1'
Popen(configure + configure_args, stdout=PIPE, stderr=STDOUT, env=env).communicate()[0]
+ del env['EMMAKEN_JUST_CONFIGURE']
Popen(make + make_args, stdout=PIPE, stderr=STDOUT, env=env).communicate()[0]
bc_file = os.path.join(project_dir, 'bc.bc')
- self.do_link(map(lambda lib: os.path.join(project_dir, lib), generated_libs), bc_file)
+ self.do_link(map(lambda lib: os.path.join(project_dir, 'cbuild', lib) if build_subdir else os.path.join(project_dir, lib), generated_libs), bc_file)
if cache and GlobalCache is not None:
print >> sys.stderr, '<save build into cache> ',
GlobalCache[cache_name] = open(bc_file, 'rb').read()
@@ -3025,7 +3035,7 @@ if 'benchmark' not in str(sys.argv):
def get_freetype(self):
global INIT_STACK; INIT_STACK = 1 # TODO: Investigate why this is necessary
- return self.get_library('freetype', os.path.join('objs', '.libs', 'libfreetype.so'))
+ return self.get_library('freetype', os.path.join('objs', '.libs', 'libfreetype.a.bc'))
def test_freetype(self):
if QUANTUM_SIZE == 1: return self.skip('TODO: Figure out and try to fix')
@@ -3059,10 +3069,25 @@ if 'benchmark' not in str(sys.argv):
self.do_test(open(path_from_root('tests', 'zlib', 'example.c'), 'r').read(),
open(path_from_root('tests', 'zlib', 'ref.txt'), 'r').read(),
- libraries=[self.get_library('zlib', os.path.join('libz.a'), make_args=['libz.a'])],
+ libraries=[self.get_library('zlib', os.path.join('libz.a.bc'), make_args=['libz.a'])],
includes=[path_from_root('tests', 'zlib')],
force_c=True)
+ def zzztest_glibc(self):
+ global CORRECT_SIGNS; CORRECT_SIGNS = 1
+ global CORRECT_OVERFLOWS; CORRECT_OVERFLOWS = 1
+ global CORRECT_ROUNDINGS; CORRECT_ROUNDINGS = 1
+
+ self.do_test(r'''
+ #include <stdio.h>
+ int main() { printf("hai\n"); return 1; }
+ ''',
+ libraries=[self.get_library('glibc', [os.path.join('src', '.libs', 'libBulletCollision.a.bc'),
+ os.path.join('src', '.libs', 'libBulletDynamics.a.bc'),
+ os.path.join('src', '.libs', 'libLinearMath.a.bc')],
+ configure_args=['--disable-sanity-checks'])],
+ includes=[path_from_root('tests', 'glibc', 'include')])
+
def test_the_bullet(self): # Called thus so it runs late in the alphabetical cycle... it is long
global SAFE_HEAP, SAFE_HEAP_LINES, USE_TYPED_ARRAYS, LLVM_OPTS
@@ -3078,9 +3103,9 @@ if 'benchmark' not in str(sys.argv):
self.do_test(open(path_from_root('tests', 'bullet', 'Demos', 'HelloWorld', 'HelloWorld.cpp'), 'r').read(),
open(path_from_root('tests', 'bullet', 'output.txt'), 'r').read(),
- libraries=[self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletCollision.a'),
- os.path.join('src', '.libs', 'libBulletDynamics.a'),
- os.path.join('src', '.libs', 'libLinearMath.a')],
+ libraries=[self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletCollision.a.bc'),
+ os.path.join('src', '.libs', 'libBulletDynamics.a.bc'),
+ os.path.join('src', '.libs', 'libLinearMath.a.bc')],
configure_args=['--disable-demos','--disable-dependency-tracking'])],
includes=[path_from_root('tests', 'bullet', 'src')],
js_engines=[SPIDERMONKEY_ENGINE]) # V8 issue 1407
@@ -3143,10 +3168,10 @@ if 'benchmark' not in str(sys.argv):
freetype = self.get_freetype()
poppler = self.get_library('poppler',
- [os.path.join('poppler', '.libs', 'libpoppler.so.13.0.0'),
- os.path.join('goo', '.libs', 'libgoo.a'),
- os.path.join('fofi', '.libs', 'libfofi.a'),
- os.path.join('splash', '.libs', 'libsplash.a'),
+ [os.path.join('poppler', '.libs', 'libpoppler.so.13.0.0.bc'),
+ os.path.join('goo', '.libs', 'libgoo.a.bc'),
+ os.path.join('fofi', '.libs', 'libfofi.a.bc'),
+ os.path.join('splash', '.libs', 'libsplash.a.bc'),
os.path.join('utils', 'pdftoppm.o'),
os.path.join('utils', 'parseargs.o')],
configure_args=['--disable-libjpeg', '--disable-libpng', '--disable-poppler-qt', '--disable-poppler-qt4', '--disable-cms'])
@@ -3187,7 +3212,7 @@ if 'benchmark' not in str(sys.argv):
open(filename, 'w').write(src)
lib = self.get_library('openjpeg',
- [os.path.join('bin', 'libopenjpeg.so'),
+ [os.path.join('bin', 'libopenjpeg.so.1.4.0.bc'),
os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/index.c.o'.split('/')),
os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/convert.c.o'.split('/')),
os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/__/common/color.c.o'.split('/')),
diff --git a/tools/bindings_generator.py b/tools/bindings_generator.py
index deba8930..66462b6d 100755
--- a/tools/bindings_generator.py
+++ b/tools/bindings_generator.py
@@ -359,20 +359,21 @@ gen_c.write('extern "C" {\n')
# Having this object saves us needing to do checks for the object being null each time in the bindings code.
gen_js.write('''
// Bindings utilities
-var Object__cache = {};
-function wrapPointer(ptr, class_) {
- var cache = class_ ? class_.prototype.__cache__ : Object__cache;
+var Object__cache = {}; // we do it this way so we do not modify |Object|
+function wrapPointer(ptr, __class__) {
+ var cache = __class__ ? __class__.prototype.__cache__ : Object__cache;
var ret = cache[ptr];
if (ret) return ret;
- class_ = class_ || Object;
- ret = Object.create(class_.prototype);
+ __class__ = __class__ || Object;
+ ret = Object.create(__class__.prototype);
ret.ptr = ptr;
+ ret.__class__ = __class__;
return cache[ptr] = ret;
}
this['wrapPointer'] = wrapPointer;
-function castObject(obj, class_) {
- return wrapPointer(obj.ptr, class_);
+function castObject(obj, __class__) {
+ return wrapPointer(obj.ptr, __class__);
}
this['castObject'] = castObject;
@@ -381,6 +382,12 @@ this['NULL'] = wrapPointer(0);
function destroy(obj) {
if (!obj['__destroy__']) throw 'Error: Cannot destroy object. (Did you create it yourself?)';
obj['__destroy__']();
+ // Remove from cache, so the object can be GC'd and refs added onto it released
+ if (obj.__class__ !== Object) {
+ delete obj.__class__.prototype.__cache__[obj.ptr];
+ } else {
+ delete Object__cache[obj.ptr];
+ }
}
this['destroy'] = destroy;
@@ -393,6 +400,11 @@ function getPointer(obj) {
return obj.ptr;
}
this['getPointer'] = getPointer;
+
+function getClass(obj) {
+ return obj.__class__;
+}
+this['getClass'] = getClass;
''')
def generate_wrapping_code(classname):
@@ -564,6 +576,9 @@ def generate_class(generating_classname, classname, clazz): # TODO: deprecate ge
print 'Maekin:', classname, generating_classname, mname, mname_suffixed
if constructor:
+ calls += '''
+ %s.prototype.__cache__[this.ptr] = this;
+ this.__class__ = %s;''' % (mname_suffixed, mname_suffixed)
if not dupe:
js_text = '''
function %s(%s) {
diff --git a/tools/emmaken.py b/tools/emmaken.py
index 8539d7b6..76c2e9c8 100755
--- a/tools/emmaken.py
+++ b/tools/emmaken.py
@@ -17,10 +17,14 @@ Example uses:
* With configure, do something like
- RANLIB=PATH/emmaken.py AR=PATH/emmaken.py CXX=PATH/emmaken.py CC=PATH/emmaken.py ./configure [options]
+ EMMAKEN_JUST_CONFIGURE=1 RANLIB=PATH/emmaken.py AR=PATH/emmaken.py CXX=PATH/emmaken.py CC=PATH/emmaken.py ./configure [options]
where PATH is the path to this file.
+ EMMAKEN_JUST_CONFIGURE tells emmaken that it is being run in ./configure,
+ so it should relay everything to gcc/g++. You should not define that when
+ running make, of course.
+
* With CMake, the same command will work (with cmake instead of ./configure). You may also be
able to do the following in your CMakeLists.txt:
@@ -53,20 +57,21 @@ import sys
import os
import subprocess
+print >> sys.stderr, 'emmaken.py: ', ' '.join(sys.argv)
+
abspath = os.path.abspath(os.path.dirname(__file__))
def path_from_root(*pathelems):
return os.path.join(os.path.sep, *(abspath.split(os.sep)[:-1] + list(pathelems)))
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
-# If this is a CMake config, just do that
+# If this is a configure-type thing, just do that
+CONFIGURE_CONFIG = os.environ.get('EMMAKEN_JUST_CONFIGURE')
CMAKE_CONFIG = 'CMakeFiles/cmTryCompileExec.dir' in ' '.join(sys.argv)# or 'CMakeCCompilerId' in ' '.join(sys.argv)
-if CMAKE_CONFIG:
+if CONFIGURE_CONFIG or CMAKE_CONFIG:
compiler = 'g++' if 'CXXCompiler' in ' '.join(sys.argv) else 'gcc'
exit(os.execvp(compiler, [compiler] + sys.argv[1:]))
try:
- print >> sys.stderr, 'emmaken.py: ', ' '.join(sys.argv)
-
#f=open('/dev/shm/tmp/waka.txt', 'a')
#f.write('Args: ' + ' '.join(sys.argv) + '\nCMake? ' + str(CMAKE_CONFIG) + '\n')
#f.close()
@@ -97,7 +102,6 @@ try:
if len(sys.argv) == 2 and 'conftest' not in ' '.join(sys.argv): # Avoid messing with configure, see below too
# ranlib
- os.execvp(LLVM_DIS, ['-show-annotations', sys.argv[1]])
sys.exit(0)
if len(sys.argv) == 1 or sys.argv[1] in ['x', 't']:
# noop ar
@@ -116,7 +120,7 @@ try:
files.append(arg)
if arg.endswith('.c'):
use_cxx = False
- if arg.endswith(('.c', '.cc', '.cpp')):
+ if arg.endswith(('.c', '.cc', '.cpp', '.dT')):
use_linker = False
if arg.endswith('.h'):
header = True
@@ -130,8 +134,8 @@ try:
assert use_linker, 'Linker should be used in this case'
if use_linker:
- call = LLVM_LINK
- newargs = []
+ call = LLVM_LD
+ newargs = ['-disable-opt']
found_o = False
i = 0
while i < len(sys.argv)-1:
@@ -163,6 +167,7 @@ try:
if not use_linker:
newargs.append('-c')
else:
+ print >> sys.stderr, 'Just copy.'
shutil.copy(sys.argv[-1], sys.argv[-2])
exit(0)
diff --git a/tools/shared.py b/tools/shared.py
index ce42d794..cc466e68 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -14,6 +14,7 @@ exec(open(CONFIG_FILE, 'r').read())
CLANG=os.path.expanduser(os.path.join(LLVM_ROOT, 'clang++'))
LLVM_LINK=os.path.join(LLVM_ROOT, 'llvm-link')
+LLVM_LD=os.path.join(LLVM_ROOT, 'llvm-ld')
LLVM_OPT=os.path.expanduser(os.path.join(LLVM_ROOT, 'opt'))
LLVM_AS=os.path.expanduser(os.path.join(LLVM_ROOT, 'llvm-as'))
LLVM_DIS=os.path.expanduser(os.path.join(LLVM_ROOT, 'llvm-dis'))