Skip to content

Commit dddcae4

Browse files
authored
Allow multiple dependencies in bootstrap system (#20931)
1 parent 11beacc commit dddcae4

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

bootstrap.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,37 @@
2020
from tools import shared, utils
2121

2222
actions = [
23-
('npm packages', 'package.json', [shutil.which('npm'), 'ci']),
24-
# TODO(sbc): Remove the checked in entry point files and have them
25-
# built on demand by this step.
26-
('create entry points', 'tools/maint/create_entry_points.py', [sys.executable, 'tools/maint/create_entry_points.py']),
27-
('git submodules', 'test/third_party/posixtestsuite/', [shutil.which('git'), 'submodule', 'update', '--init']),
23+
('npm packages', ['package.json'], [shutil.which('npm'), 'ci']),
24+
('create entry points', [
25+
'tools/maint/create_entry_points.py',
26+
'tools/maint/run_python.bat',
27+
'tools/maint/run_python.sh',
28+
'tools/maint/run_python.ps1',
29+
],
30+
[sys.executable, 'tools/maint/create_entry_points.py']),
31+
('git submodules', ['test/third_party/posixtestsuite/'], [shutil.which('git'), 'submodule', 'update', '--init']),
2832
]
2933

3034

3135
def get_stamp_file(action_name):
3236
return os.path.join(STAMP_DIR, action_name.replace(' ', '_') + '.stamp')
3337

3438

39+
def check_deps(name, deps):
40+
stamp_file = get_stamp_file(name)
41+
if not os.path.exists(stamp_file):
42+
return False
43+
for dep in deps:
44+
dep = utils.path_from_root(dep)
45+
if os.path.getmtime(dep) > os.path.getmtime(stamp_file):
46+
return False
47+
return True
48+
49+
3550
def check():
36-
for name, filename, _ in actions:
37-
stamp_file = get_stamp_file(name)
38-
filename = utils.path_from_root(filename)
39-
if not os.path.exists(stamp_file) or os.path.getmtime(filename) > os.path.getmtime(stamp_file):
40-
utils.exit_with_error(f'emscripten setup is not complete ("{name}" is out-of-date). Run bootstrap.py to update')
51+
for name, deps, _ in actions:
52+
if not check_deps(name, deps):
53+
utils.exit_with_error(f'emscripten setup is not complete ("{name}" is out-of-date). Run `bootstrap` to update')
4154

4255

4356
def main(args):
@@ -46,13 +59,12 @@ def main(args):
4659
parser.add_argument('-n', '--dry-run', action='store_true', help='dry run', default=False)
4760
args = parser.parse_args()
4861

49-
for name, filename, cmd in actions:
50-
stamp_file = get_stamp_file(name)
51-
filename = utils.path_from_root(filename)
52-
if os.path.exists(stamp_file) and os.path.getmtime(filename) <= os.path.getmtime(stamp_file):
62+
for name, deps, cmd in actions:
63+
if check_deps(name, deps):
5364
print('Up-to-date: %s' % name)
5465
continue
5566
print('Out-of-date: %s' % name)
67+
stamp_file = get_stamp_file(name)
5668
if args.dry_run:
5769
print(' (skipping: dry run) -> %s' % ' '.join(cmd))
5870
return

test/test_sanity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def test_bootstrap(self):
757757
# Touching package.json should cause compiler to fail with bootstrap message
758758
Path(utils.path_from_root('package.json')).touch()
759759
err = self.expect_fail([EMCC, test_file('hello_world.c')])
760-
self.assertContained('emcc: error: emscripten setup is not complete ("npm packages" is out-of-date). Run bootstrap.py to update', err)
760+
self.assertContained('emcc: error: emscripten setup is not complete ("npm packages" is out-of-date). Run `bootstrap` to update', err)
761761

762762
# Running bootstrap.py should fix that
763763
bootstrap = shared.bat_suffix(shared.path_from_root('bootstrap'))

0 commit comments

Comments
 (0)