Skip to content

Commit 9e1369a

Browse files
committed
Move compiler paths out of top level of shared.py. NFC
This is a step towards separating the import of python modules from the initialization of the compiler. The goal here is to remove top level code (i.e. Remove side effects from importing).
1 parent 9f751bb commit 9e1369a

24 files changed

+143
-135
lines changed

emar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111

1212
from tools import shared
1313

14-
shared.exec_process([shared.LLVM_AR] + sys.argv[1:])
14+
shared.exec_process([shared.paths.LLVM_AR] + sys.argv[1:])

emcc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from tools.cmdline import CLANG_FLAGS_WITH_ARGS, options
4444
from tools.response_file import substitute_response_files
4545
from tools.settings import COMPILE_TIME_SETTINGS, default_setting, settings, user_settings
46-
from tools.shared import DEBUG, DYLIB_EXTENSIONS, in_temp
46+
from tools.shared import DEBUG, DYLIB_EXTENSIONS, in_temp, paths
4747
from tools.toolchain_profiler import ToolchainProfiler
4848
from tools.utils import exit_with_error, get_file_suffix, read_file, unsuffixed_basename
4949

@@ -168,9 +168,9 @@ def make_relative(filename):
168168
@ToolchainProfiler.profile()
169169
def main(args):
170170
if shared.run_via_emxx:
171-
clang = shared.CLANG_CXX
171+
clang = paths.CLANG_CXX
172172
else:
173-
clang = shared.CLANG_CC
173+
clang = paths.CLANG_CC
174174

175175
# Special case the handling of `-v` because it has a special/different meaning
176176
# when used with no other arguments. In particular, we must handle this early
@@ -477,9 +477,9 @@ def phase_setup(state):
477477
@ToolchainProfiler.profile_block('compile inputs')
478478
def phase_compile_inputs(options, state, newargs):
479479
if shared.run_via_emxx:
480-
compiler = [shared.CLANG_CXX]
480+
compiler = [paths.CLANG_CXX]
481481
else:
482-
compiler = [shared.CLANG_CC]
482+
compiler = [paths.CLANG_CC]
483483

484484
if config.COMPILER_WRAPPER:
485485
logger.debug('using compiler wrapper: %s', config.COMPILER_WRAPPER)

emranlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
from tools import shared
1616

17-
shared.exec_process([shared.LLVM_RANLIB] + sys.argv[1:])
17+
shared.exec_process([shared.paths.LLVM_RANLIB] + sys.argv[1:])

emscan-deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
# Add any clang flags that emcc would add.
2222
newargs += compile.get_cflags(tuple(argv))
2323

24-
shared.exec_process([shared.CLANG_SCAN_DEPS] + newargs)
24+
shared.exec_process([shared.paths.CLANG_SCAN_DEPS] + newargs)

emstrip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111

1212
from tools import shared
1313

14-
shared.exec_process([shared.LLVM_STRIP] + sys.argv[1:])
14+
shared.exec_process([shared.paths.LLVM_STRIP] + sys.argv[1:])

test/browser_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
from tools import feature_matrix, shared, utils
3838
from tools.feature_matrix import UNSUPPORTED
39-
from tools.shared import DEBUG, EMCC, exit_with_error
39+
from tools.shared import DEBUG, exit_with_error, paths
4040
from tools.utils import MACOS, WINDOWS, memoize, path_from_root, read_binary
4141

4242
logger = logging.getLogger('common')
@@ -878,7 +878,7 @@ def compile_btest(self, filename, cflags, reporting=Reporting.FULL):
878878
if reporting == Reporting.FULL:
879879
# If C reporting (i.e. the REPORT_RESULT macro) is required we
880880
# also include report_result.c and force-include report_result.h
881-
self.run_process([EMCC, '-c', '-I' + TEST_ROOT,
881+
self.run_process([paths.EMCC, '-c', '-I' + TEST_ROOT,
882882
test_file('report_result.c')] + self.get_cflags(compile_only=True) + (['-fPIC'] if '-fPIC' in cflags else []))
883883
cflags += ['report_result.o', '-include', test_file('report_result.h')]
884884
if EMTEST_BROWSER == 'node':

test/clang_native.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import platform
99
import sys
1010

11-
from tools.shared import CLANG_CC, CLANG_CXX, PIPE
11+
from tools.shared import PIPE, paths
1212
from tools.utils import MACOS, WINDOWS, path_from_root, run_process
1313

1414
logger = logging.getLogger('clang_native')
@@ -63,9 +63,9 @@ def get_clang_native_env():
6363
return CACHED_CLANG_NATIVE_ENV
6464
env = os.environ.copy()
6565

66-
env['CC'] = CLANG_CC
67-
env['CXX'] = CLANG_CXX
68-
env['LD'] = CLANG_CXX
66+
env['CC'] = paths.CLANG_CC
67+
env['CXX'] = paths.CLANG_CXX
68+
env['LD'] = paths.CLANG_CXX
6969

7070
if MACOS:
7171
path = run_process(['xcrun', '--show-sdk-path'], stdout=PIPE).stdout.strip()

test/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from tools import building, config, feature_matrix, shared, utils
3333
from tools.feature_matrix import Feature
3434
from tools.settings import COMPILE_TIME_SETTINGS
35-
from tools.shared import DEBUG, EMCC, EMXX, get_canonical_temp_dir
35+
from tools.shared import DEBUG, get_canonical_temp_dir, paths
3636
from tools.utils import (
3737
WINDOWS,
3838
exit_with_error,
@@ -130,9 +130,9 @@ def copytree(src, dest):
130130

131131
def compiler_for(filename, force_c=False):
132132
if utils.suffix(filename) in ('.cc', '.cxx', '.cpp') and not force_c:
133-
return EMXX
133+
return paths.EMXX
134134
else:
135-
return EMCC
135+
return paths.EMCC
136136

137137

138138
def record_flaky_test(test_name, attempt_count, max_attempts, exception_msg):
@@ -1272,7 +1272,7 @@ def _test_dylink_dso_needed(self, do_run):
12721272
''')
12731273

12741274
def ccshared(src, linkto=None):
1275-
cmdv = [EMCC, src, '-o', utils.unsuffixed(src) + '.wasm', '-sSIDE_MODULE'] + self.get_cflags()
1275+
cmdv = [paths.EMCC, src, '-o', utils.unsuffixed(src) + '.wasm', '-sSIDE_MODULE'] + self.get_cflags()
12761276
if linkto:
12771277
cmdv += linkto
12781278
self.run_process(cmdv)

test/runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ def find_llvm_git_root(dir):
630630
print(f'LLVM git directory: "{llvm_git_root}"')
631631
print_repository_info(llvm_git_root, 'LLVM')
632632

633-
clang_version = utils.run_process([shared.CLANG_CC, '--version'], stdout=subprocess.PIPE).stdout.strip()
634-
print(f'Clang: "{shared.CLANG_CC}"\n{clang_version}\n')
633+
clang_version = utils.run_process([shared.paths.CLANG_CC, '--version'], stdout=subprocess.PIPE).stdout.strip()
634+
print(f'Clang: "{shared.paths.CLANG_CC}"\n{clang_version}\n')
635635

636636
print(f'EMTEST_BROWSER: {browser_common.EMTEST_BROWSER}')
637637
if browser_common.is_firefox():

test/test_benchmark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from decorators import needs_make
2626

2727
from tools import building, utils
28-
from tools.shared import CLANG_CC, CLANG_CXX, EMCC, PIPE, config
28+
from tools.shared import PIPE, config, paths
2929
from tools.utils import run_process
3030

3131
# standard arguments for timing:
@@ -232,7 +232,7 @@ def build(self, parent, filename, args, shared_args, emcc_args, native_args, nat
232232
final = final.replace('.cpp', '')
233233
utils.delete_file(final)
234234
cmd = [
235-
EMCC, filename,
235+
paths.EMCC, filename,
236236
OPTIMIZATIONS,
237237
'-sINITIAL_MEMORY=256MB',
238238
'-sENVIRONMENT=node,shell',
@@ -361,7 +361,7 @@ def get_output_files(self):
361361
aot_v8 = (config.V8_ENGINE if config.V8_ENGINE else []) + ['--no-liftoff']
362362

363363
named_benchmarkers = {
364-
'clang': NativeBenchmarker('clang', [CLANG_CC], [CLANG_CXX]),
364+
'clang': NativeBenchmarker('clang', [paths.CLANG_CC], [paths.CLANG_CXX]),
365365
'gcc': NativeBenchmarker('gcc', ['gcc', '-no-pie'], ['g++', '-no-pie']),
366366
'size': SizeBenchmarker('size'),
367367
'v8': EmscriptenBenchmarker('v8', aot_v8),

0 commit comments

Comments
 (0)