aboutsummaryrefslogtreecommitdiff
path: root/tools/shared.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-31 17:15:45 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-31 17:15:45 -0800
commitac0972ebf6cb8ff17f1bbbf01526d29fd2d2f420 (patch)
tree499dd06881cddf43520b40cc62b51276ca411c60 /tools/shared.py
parent64c779641a2a9587613cc65ad7251890f18e25c3 (diff)
parent375eb145c8a6c1627a8b93f81d40fd1aa7fc899b (diff)
Merge branch 'incoming'
Diffstat (limited to 'tools/shared.py')
-rw-r--r--tools/shared.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/shared.py b/tools/shared.py
index f94bb263..b55e60dc 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -588,8 +588,14 @@ class Building:
COMPILER_TEST_OPTS = [] # For use of the test runner
@staticmethod
- def get_building_env():
+ def get_building_env(native=False):
env = os.environ.copy()
+ if native:
+ env['CC'] = CLANG_CC
+ env['CXX'] = CLANG_CPP
+ env['LD'] = CLANG
+ env['CFLAGS'] = '-O2 -fno-math-errno'
+ return env
env['CC'] = EMCC if not WINDOWS else 'python %r' % EMCC
env['CXX'] = EMXX if not WINDOWS else 'python %r' % EMXX
env['AR'] = EMAR if not WINDOWS else 'python %r' % EMAR
@@ -667,14 +673,14 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
raise
@staticmethod
- def build_library(name, build_dir, output_dir, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None):
+ def build_library(name, build_dir, output_dir, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None, native=False):
''' 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).
This cache is just during the test runner. There is a different concept of caching as well, see |Cache|. '''
if type(generated_libs) is not list: generated_libs = [generated_libs]
- if source_dir is None: source_dir = path_from_root('tests', name)
+ if source_dir is None: source_dir = path_from_root('tests', name.replace('_native', ''))
temp_dir = build_dir
if copy_project:
@@ -695,7 +701,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
# os.unlink(lib) # make sure compilation completed successfully
# except:
# pass
- env = Building.get_building_env()
+ env = Building.get_building_env(native)
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 |link| call)
@@ -1075,7 +1081,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
Building._is_ar_cache[filename] = sigcheck
return sigcheck
except Exception, e:
- print >> sys.stderr, 'shared.Building.is_ar failed to test whether file \'%s\' is a llvm archive file! Failed on exception: %s' % (filename, e)
+ if DEBUG: print >> sys.stderr, 'shared.Building.is_ar failed to test whether file \'%s\' is a llvm archive file! Failed on exception: %s' % (filename, e)
return False
@staticmethod
@@ -1095,7 +1101,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
assert os.path.exists(test_ll)
try_delete(test_ll)
except Exception, e:
- print >> sys.stderr, 'shared.Building.is_bitcode failed to test whether file \'%s\' is a llvm bitcode file! Failed on exception: %s' % (filename, e)
+ if DEBUG: print >> sys.stderr, 'shared.Building.is_bitcode failed to test whether file \'%s\' is a llvm bitcode file! Failed on exception: %s' % (filename, e)
return False
# look for magic signature