diff options
-rwxr-xr-x | tools/emconfiguren.py | 15 | ||||
-rwxr-xr-x | tools/emmaken.py | 8 | ||||
-rw-r--r-- | tools/shared.py | 39 |
3 files changed, 50 insertions, 12 deletions
diff --git a/tools/emconfiguren.py b/tools/emconfiguren.py new file mode 100755 index 00000000..abe41564 --- /dev/null +++ b/tools/emconfiguren.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +''' +This is a helper script for emmaken.py. See docs in that file for more info. +''' + +import os, sys + +__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +def path_from_root(*pathelems): + return os.path.join(__rootpath__, *pathelems) +exec(open(path_from_root('tools', 'shared.py'), 'r').read()) + +Building.configure(sys.argv[1:]) + diff --git a/tools/emmaken.py b/tools/emmaken.py index f3ecefce..8e2144b2 100755 --- a/tools/emmaken.py +++ b/tools/emmaken.py @@ -23,7 +23,13 @@ opt yourself, but be careful with the parameters you pass). Example uses: - * With configure, do something like + * For configure, instead of ./configure, cmake, etc., run emconfiguren.py + with that command as an argument, for example + + emconfiguren.py ./configure [options] + + emconfiguren.py is a tiny script that just sets some environment vars + as a convenience. The command just shown is equivalent to EMMAKEN_JUST_CONFIGURE=1 RANLIB=PATH/emmaken.py AR=PATH/emmaken.py CXX=PATH/emmakenxx.py CC=PATH/emmaken.py ./configure [options] diff --git a/tools/shared.py b/tools/shared.py index 360f80cc..4bbfe81c 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -222,6 +222,29 @@ class Building: COMPILER_TEST_OPTS = [] @staticmethod + def get_building_env(): + env = os.environ.copy() + env['RANLIB'] = env['AR'] = env['CXX'] = env['CC'] = env['LIBTOOL'] = EMMAKEN + env['EMMAKEN_COMPILER'] = Building.COMPILER + env['EMSCRIPTEN_TOOLS'] = path_from_root('tools') + env['CFLAGS'] = env['EMMAKEN_CFLAGS'] = ' '.join(COMPILER_OPTS + Building.COMPILER_TEST_OPTS) # Normal CFLAGS is ignored by some configure's. + return env + + @staticmethod + def configure(args, stdout=None, stderr=None, env=None): + if env is None: + env = Building.get_building_env() + env['EMMAKEN_JUST_CONFIGURE'] = '1' + Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()[0] + del env['EMMAKEN_JUST_CONFIGURE'] + + @staticmethod + def make(args, stdout=None, stderr=None, env=None): + if env is None: + env = Building.get_building_env() + Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()[0] + + @staticmethod def build_library(name, build_dir, output_dir, generated_libs, configure=['./configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}): ''' 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 @@ -248,20 +271,14 @@ class Building: # os.unlink(lib) # make sure compilation completed successfully # except: # pass - env = os.environ.copy() - env['RANLIB'] = env['AR'] = env['CXX'] = env['CC'] = env['LIBTOOL'] = EMMAKEN - env['EMMAKEN_COMPILER'] = Building.COMPILER - env['EMSCRIPTEN_TOOLS'] = path_from_root('tools') - env['CFLAGS'] = env['EMMAKEN_CFLAGS'] = ' '.join(COMPILER_OPTS + Building.COMPILER_TEST_OPTS) # Normal CFLAGS is ignored by some configure's. + env = Building.get_building_env() for k, v in env_init.iteritems(): env[k] = v 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=open(os.path.join(output_dir, 'configure_'), 'w'), - stderr=open(os.path.join(output_dir, 'configure_err'), 'w'), env=env).communicate()[0] - del env['EMMAKEN_JUST_CONFIGURE'] - Popen(make + make_args, stdout=open(os.path.join(output_dir, 'make_'), 'w'), - stderr=open(os.path.join(output_dir, 'make_err'), 'w'), env=env).communicate()[0] + Building.configure(configure + configure_args, stdout=open(os.path.join(output_dir, 'configure_'), 'w'), + stderr=open(os.path.join(output_dir, 'configure_err'), 'w'), env=env) + Building.make(make + make_args, stdout=open(os.path.join(output_dir, 'make_'), 'w'), + stderr=open(os.path.join(output_dir, 'make_err'), 'w'), env=env) bc_file = os.path.join(project_dir, 'bc.bc') Building.link(generated_libs, bc_file) if cache is not None: |