From 9035ffff55ac443f7df0138211ed78d24fc5f856 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 9 Aug 2014 09:22:06 +0800 Subject: [PATCH] linux: Don't set CXX to clang when building node modules. --- .travis.yml | 2 +- script/cibuild | 18 +++++++++++++----- script/lib/util.py | 12 ++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a2686f8..3678c68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: cpp -compiler: gcc +compiler: clang os: - linux - osx diff --git a/script/cibuild b/script/cibuild index 2343fa5..c8ad4a6 100755 --- a/script/cibuild +++ b/script/cibuild @@ -4,7 +4,7 @@ import os import subprocess import sys -from lib.util import rm_rf +from lib.util import execute, rm_rf, scoped_env SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) @@ -21,9 +21,10 @@ LINUX_DEPS = [ def main(): os.environ['CI'] = '1' - if os.environ['TRAVIS'] == 'true' and sys.platform == 'linux2': - subprocess.check_call(['sudo', 'apt-get', 'update']) - subprocess.check_call(['sudo', 'apt-get', 'install'] + LINUX_DEPS) + is_travis = (os.getenv('TRAVIS') == 'true') + if is_travis and sys.platform == 'linux2': + execute(['sudo', 'apt-get', 'update']) + execute(['sudo', 'apt-get', 'install'] + LINUX_DEPS) rm_rf(os.path.join(SOURCE_ROOT, 'out')) rm_rf(os.path.join(SOURCE_ROOT, 'node_modules')) @@ -33,7 +34,14 @@ def main(): rm_rf(os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor', 'download', 'libchromiumcontent')) - run_script('bootstrap.py') + if is_travis and sys.platform == 'linux2': + with scoped_env('CXX', 'g++'): + with scoped_env('CC', 'gcc'): + run_script('bootstrap.py') + run_script('update.py') + else: + run_script('bootstrap.py') + run_script('cpplint.py') if sys.platform != 'win32': run_script('pylint.py') diff --git a/script/lib/util.py b/script/lib/util.py index 1759574..f817150 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -29,6 +29,18 @@ def scoped_cwd(path): os.chdir(cwd) +@contextlib.contextmanager +def scoped_env(key, value): + origin = '' + if key in os.environ: + origin = os.environ[key] + os.environ[key] = value + try: + yield + finally: + os.environ[key] = origin + + def download(text, url, path): safe_mkdir(os.path.dirname(path)) with open(path, 'wb') as local_file: -- 2.7.4