Skip to content

Commit 6f6313a

Browse files
authored
Use utils.py directly rather than imported via shared.py. NFC (#25727)
1 parent 674a95a commit 6f6313a

File tree

11 files changed

+23
-24
lines changed

11 files changed

+23
-24
lines changed

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def make_relative(filename):
124124

125125
root = unsuffixed_basename(name)
126126
with tarfile.open(name, 'w') as reproduce_file:
127-
reproduce_file.add(shared.path_from_root('emscripten-version.txt'), os.path.join(root, 'version.txt'))
127+
reproduce_file.add(utils.path_from_root('emscripten-version.txt'), os.path.join(root, 'version.txt'))
128128

129129
with shared.get_temp_files().get_file(suffix='.tar') as rsp_name:
130130
with open(rsp_name, 'w') as rsp:

test/benchmark/benchmark_sse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
from common import EMRUN, test_file
2222

2323
from tools.config import V8_ENGINE
24-
from tools.shared import CLANG_CXX, EMCC, WINDOWS
25-
from tools.utils import run_process
24+
from tools.shared import CLANG_CXX, EMCC
25+
from tools.utils import WINDOWS, run_process
2626

2727
# System info
2828
system_info = subprocess.check_output([EMRUN, '--system_info'], stderr=subprocess.STDOUT, text=True)

test/common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
from tools import building, config, feature_matrix, shared, utils
4242
from tools.feature_matrix import UNSUPPORTED, Feature, min_browser_versions
4343
from tools.settings import COMPILE_TIME_SETTINGS
44-
from tools.shared import DEBUG, EMCC, EMXX, get_canonical_temp_dir, path_from_root
44+
from tools.shared import DEBUG, EMCC, EMXX, get_canonical_temp_dir
4545
from tools.utils import (
4646
WINDOWS,
4747
exit_with_error,
4848
memoize,
49+
path_from_root,
4950
read_binary,
5051
read_file,
5152
write_binary,
@@ -257,7 +258,7 @@ def open_url_args(url):
257258
EMMAKE = utils.bat_suffix(path_from_root('emmake'))
258259
EMCMAKE = utils.bat_suffix(path_from_root('emcmake'))
259260
EMCONFIGURE = utils.bat_suffix(path_from_root('emconfigure'))
260-
EMRUN = utils.bat_suffix(shared.path_from_root('emrun'))
261+
EMRUN = utils.bat_suffix(utils.path_from_root('emrun'))
261262
WASM_DIS = os.path.join(building.get_binaryen_bin(), 'wasm-dis')
262263
LLVM_OBJDUMP = shared.llvm_tool_path('llvm-objdump')
263264
PYTHON = sys.executable

test/test_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565

6666
from tools import ports, shared
6767
from tools.feature_matrix import Feature
68-
from tools.shared import DEBUG, EMCC, FILE_PACKAGER, PIPE, WINDOWS
69-
from tools.utils import delete_dir
68+
from tools.shared import DEBUG, EMCC, FILE_PACKAGER, PIPE
69+
from tools.utils import WINDOWS, delete_dir
7070

7171

7272
def make_test_chunked_synchronous_xhr_server(support_byte_ranges, data, port):

test/test_interactive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from common import BrowserCore, create_file, test_file
1414
from decorators import also_with_minimal_runtime, parameterized
1515

16-
from tools.shared import WINDOWS
16+
from tools.utils import WINDOWS
1717

1818

1919
class interactive(BrowserCore):

test/test_sanity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ def test_bootstrap(self):
807807
self.assert_fail([EMCC, test_file('hello_world.c')], expected)
808808

809809
# Running bootstrap.py should fix that
810-
bootstrap = shared.bat_suffix(shared.path_from_root('bootstrap'))
810+
bootstrap = shared.bat_suffix(path_from_root('bootstrap'))
811811
self.run_process([bootstrap])
812812

813813
# Now the compiler should work again
@@ -828,4 +828,4 @@ def test_bootstrap_without_em_config(self):
828828
env['PATH'] = os.pathsep.join(new_path)
829829

830830
# Running bootstrap.py should not fail
831-
self.run_process([shared.bat_suffix(shared.path_from_root('bootstrap'))], env=env)
831+
self.run_process([shared.bat_suffix(path_from_root('bootstrap'))], env=env)

test/test_sockets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
)
2929

3030
from tools import config
31-
from tools.shared import CLANG_CC, EMCC, path_from_root
32-
from tools.utils import run_process
31+
from tools.shared import CLANG_CC, EMCC
32+
from tools.utils import path_from_root, run_process
3333

3434
npm_checked = False
3535

tools/link.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@
4545
settings,
4646
user_settings,
4747
)
48-
from .shared import DEBUG, DYLIB_EXTENSIONS, WINDOWS, do_replace, in_temp
48+
from .shared import DEBUG, DYLIB_EXTENSIONS, do_replace, in_temp
4949
from .toolchain_profiler import ToolchainProfiler
5050
from .utils import (
51+
WINDOWS,
5152
delete_file,
5253
exit_with_error,
5354
get_file_suffix,
@@ -2131,7 +2132,7 @@ def phase_source_transforms(options):
21312132
global final_js
21322133
safe_copy(final_js, final_js + '.tr.js')
21332134
final_js += '.tr.js'
2134-
posix = not shared.WINDOWS
2135+
posix = not WINDOWS
21352136
logger.debug('applying transform: %s', options.js_transform)
21362137
shared.check_call(remove_quotes(shlex.split(options.js_transform, posix=posix) + [os.path.abspath(final_js)]))
21372138
save_intermediate('transformed')

tools/ports/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class Ports:
189189
@staticmethod
190190
def get_include_dir(*parts):
191191
dirname = cache.get_include_dir(*parts)
192-
shared.safe_ensure_dirs(dirname)
192+
utils.safe_ensure_dirs(dirname)
193193
return dirname
194194

195195
@staticmethod
@@ -215,7 +215,7 @@ def install_headers(src_dir, pattern='*.h', target=None):
215215
assert os.path.exists(dest)
216216
if target:
217217
dest = os.path.join(dest, target)
218-
shared.safe_ensure_dirs(dest)
218+
utils.safe_ensure_dirs(dest)
219219
matches = glob.glob(os.path.join(src_dir, pattern))
220220
assert matches, f'no headers found to install in {src_dir}'
221221
for f in matches:
@@ -275,7 +275,7 @@ def build_port(src_dir, output_path, port_name, includes=[], flags=[], cxxflags=
275275
@staticmethod
276276
def get_dir(*parts):
277277
dirname = os.path.join(config.PORTS, *parts)
278-
shared.safe_ensure_dirs(dirname)
278+
utils.safe_ensure_dirs(dirname)
279279
return dirname
280280

281281
@staticmethod
@@ -373,7 +373,7 @@ def retrieve():
373373

374374
def unpack():
375375
logger.info(f'unpacking port: {name}')
376-
shared.safe_ensure_dirs(fullname)
376+
utils.safe_ensure_dirs(fullname)
377377
shutil.unpack_archive(filename=fullpath, extract_dir=fullname)
378378
utils.write_file(marker, url + '\n')
379379

tools/shared.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@
4444
from . import cache, config, diagnostics, filelock, tempfiles, utils
4545
from .settings import settings
4646
from .utils import (
47-
WINDOWS,
4847
bat_suffix,
4948
exit_with_error,
5049
memoize,
5150
path_from_root,
5251
safe_ensure_dirs,
53-
set_version_globals,
5452
)
5553

5654
DEBUG_SAVE = DEBUG or int(os.environ.get('EMCC_DEBUG_SAVE', '0'))
@@ -213,7 +211,7 @@ def run_js_tool(filename, jsargs=[], node_args=[], **kw): # noqa: B006
213211

214212

215213
def get_npm_cmd(name, missing_ok=False):
216-
if WINDOWS:
214+
if utils.WINDOWS:
217215
cmd = [path_from_root('node_modules/.bin', name + '.cmd')]
218216
else:
219217
cmd = config.NODE_JS + [path_from_root('node_modules/.bin', name)]
@@ -626,7 +624,7 @@ def get_llvm_target():
626624

627625

628626
def init():
629-
set_version_globals()
627+
utils.set_version_globals()
630628
setup_temp_dirs()
631629

632630

0 commit comments

Comments
 (0)