aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/runner.py18
-rw-r--r--tools/shared.py36
2 files changed, 44 insertions, 10 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 40f721d2..131eca10 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7500,6 +7500,24 @@ elif 'sanity' in str(sys.argv):
assert mtime(SANITY_FILE) >= mtime(CONFIG_FILE)
self.assertNotContained(SANITY_FAIL_MESSAGE, output)
+ # emcc should be configurable directly from EM_CONFIG without any config file
+ restore()
+ config = open(CONFIG_FILE, 'r').read()
+ os.environ['EM_CONFIG'] = config
+ wipe()
+ dirname = tempfile.mkdtemp(prefix='emscripten_test_' + self.__class__.__name__ + '_', dir=TEMP_DIR)
+ open(os.path.join(dirname, 'main.cpp'), 'w').write('''
+ #include <stdio.h>
+ int main() {
+ printf("hello from emcc with no CONFIG_FILE\\n");
+ return 0;
+ }
+ ''')
+ Popen(['python', EMCC, os.path.join(dirname, 'main.cpp'), '-o', os.path.join(dirname, 'a.out.js')]).communicate()
+ self.assertContained('hello from emcc with no CONFIG_FILE', run_js(os.path.join(dirname, 'a.out.js')))
+ del os.environ['EM_CONFIG']
+ shutil.rmtree(dirname)
+
def test_emcc_caching(self):
INCLUDING_MESSAGE = 'emcc: including X'
BUILDING_MESSAGE = 'emcc: building X for cache'
diff --git a/tools/shared.py b/tools/shared.py
index 532f561f..13160713 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -6,15 +6,22 @@ __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
-# Config file
+# Emscripten configuration is done through the EM_CONFIG environment variable.
+# If the string value contained in this environment variable contains newline
+# separated definitions, then these definitions will be used to configure
+# Emscripten. Otherwise, the string is understood to be a path to a settings
+# file that contains the required definitions.
EM_CONFIG = os.environ.get('EM_CONFIG')
if not EM_CONFIG:
EM_CONFIG = '~/.emscripten'
-CONFIG_FILE = os.path.expanduser(EM_CONFIG)
-if not os.path.exists(CONFIG_FILE):
- shutil.copy(path_from_root('settings.py'), CONFIG_FILE)
- print >> sys.stderr, '''
+if '\n' in EM_CONFIG:
+ CONFIG_FILE = None
+else:
+ CONFIG_FILE = os.path.expanduser(EM_CONFIG)
+ if not os.path.exists(CONFIG_FILE):
+ shutil.copy(path_from_root('settings.py'), CONFIG_FILE)
+ print >> sys.stderr, '''
==============================================================================
Welcome to Emscripten!
@@ -28,9 +35,9 @@ make sure LLVM_ROOT and NODE_JS are correct.
This command will now exit. When you are done editing those paths, re-run it.
==============================================================================
''' % (EM_CONFIG, CONFIG_FILE)
- sys.exit(0)
+ sys.exit(0)
try:
- exec(open(CONFIG_FILE, 'r').read())
+ exec(open(CONFIG_FILE, 'r').read() if CONFIG_FILE else EM_CONFIG)
except Exception, e:
print >> sys.stderr, 'Error in evaluating %s (at %s): %s' % (EM_CONFIG, CONFIG_FILE, str(e))
sys.exit(1)
@@ -43,6 +50,8 @@ except Exception, e:
def check_sanity(force=False):
try:
if not force:
+ if not CONFIG_FILE:
+ return # config stored directly in EM_CONFIG => skip sanity checks
settings_mtime = os.stat(CONFIG_FILE).st_mtime
sanity_file = CONFIG_FILE + '_sanity'
try:
@@ -183,8 +192,11 @@ else:
#if 'strict' not in str(SPIDERMONKEY_ENGINE): # XXX temporarily disable strict mode until we sort out some stuff
# SPIDERMONKEY_ENGINE += ['-e', "options('strict')"] # Strict mode in SpiderMonkey. With V8 we check that fallback to non-strict works too
-if 'gcparam' not in str(SPIDERMONKEY_ENGINE):
- SPIDERMONKEY_ENGINE += ['-e', "gcparam('maxBytes', 1024*1024*1024);"] # Our very large files need lots of gc heap
+try:
+ if 'gcparam' not in str(SPIDERMONKEY_ENGINE):
+ SPIDERMONKEY_ENGINE += ['-e', "gcparam('maxBytes', 1024*1024*1024);"] # Our very large files need lots of gc heap
+except NameError:
+ pass
WINDOWS = sys.platform.startswith ('win')
@@ -228,6 +240,8 @@ class TempFiles:
def check_engine(engine):
# TODO: we call this several times, perhaps cache the results?
try:
+ if not CONFIG_FILE:
+ return True # config stored directly in EM_CONFIG => skip engine check
return 'hello, world!' in run_js(path_from_root('tests', 'hello_world.js'), engine)
except Exception, e:
print 'Checking JS engine %s failed. Check %s. Details: %s' % (str(engine), EM_CONFIG, str(e))
@@ -810,7 +824,9 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
# Permanent cache for dlmalloc and stdlibc++
class Cache:
- dirname = os.path.expanduser(os.path.join('~', '.emscripten_cache'))
+ dirname = os.environ.get('EM_CACHE')
+ if not dirname:
+ dirname = os.path.expanduser(os.path.join('~', '.emscripten_cache'))
@staticmethod
def erase():