diff --git a/bootstrap.py b/bootstrap.py index 858ddf734448..695ae528b212 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -20,11 +20,15 @@ from tools import shared, utils actions = [ - ('npm packages', 'package.json', [shutil.which('npm'), 'ci']), - # TODO(sbc): Remove the checked in entry point files and have them - # built on demand by this step. - ('create entry points', 'tools/maint/create_entry_points.py', [sys.executable, 'tools/maint/create_entry_points.py']), - ('git submodules', 'test/third_party/posixtestsuite/', [shutil.which('git'), 'submodule', 'update', '--init']), + ('npm packages', ['package.json'], [shutil.which('npm'), 'ci']), + ('create entry points', [ + 'tools/maint/create_entry_points.py', + 'tools/maint/run_python.bat', + 'tools/maint/run_python.sh', + 'tools/maint/run_python.ps1', + ], + [sys.executable, 'tools/maint/create_entry_points.py']), + ('git submodules', ['test/third_party/posixtestsuite/'], [shutil.which('git'), 'submodule', 'update', '--init']), ] @@ -32,12 +36,21 @@ def get_stamp_file(action_name): return os.path.join(STAMP_DIR, action_name.replace(' ', '_') + '.stamp') +def check_deps(name, deps): + stamp_file = get_stamp_file(name) + if not os.path.exists(stamp_file): + return False + for dep in deps: + dep = utils.path_from_root(dep) + if os.path.getmtime(dep) > os.path.getmtime(stamp_file): + return False + return True + + def check(): - for name, filename, _ in actions: - stamp_file = get_stamp_file(name) - filename = utils.path_from_root(filename) - if not os.path.exists(stamp_file) or os.path.getmtime(filename) > os.path.getmtime(stamp_file): - utils.exit_with_error(f'emscripten setup is not complete ("{name}" is out-of-date). Run bootstrap.py to update') + for name, deps, _ in actions: + if not check_deps(name, deps): + utils.exit_with_error(f'emscripten setup is not complete ("{name}" is out-of-date). Run `bootstrap` to update') def main(args): @@ -46,13 +59,12 @@ def main(args): parser.add_argument('-n', '--dry-run', action='store_true', help='dry run', default=False) args = parser.parse_args() - for name, filename, cmd in actions: - stamp_file = get_stamp_file(name) - filename = utils.path_from_root(filename) - if os.path.exists(stamp_file) and os.path.getmtime(filename) <= os.path.getmtime(stamp_file): + for name, deps, cmd in actions: + if check_deps(name, deps): print('Up-to-date: %s' % name) continue print('Out-of-date: %s' % name) + stamp_file = get_stamp_file(name) if args.dry_run: print(' (skipping: dry run) -> %s' % ' '.join(cmd)) return diff --git a/test/test_sanity.py b/test/test_sanity.py index 942469ae7a28..8ff59d68d275 100644 --- a/test/test_sanity.py +++ b/test/test_sanity.py @@ -757,7 +757,7 @@ def test_bootstrap(self): # Touching package.json should cause compiler to fail with bootstrap message Path(utils.path_from_root('package.json')).touch() err = self.expect_fail([EMCC, test_file('hello_world.c')]) - self.assertContained('emcc: error: emscripten setup is not complete ("npm packages" is out-of-date). Run bootstrap.py to update', err) + self.assertContained('emcc: error: emscripten setup is not complete ("npm packages" is out-of-date). Run `bootstrap` to update', err) # Running bootstrap.py should fix that bootstrap = shared.bat_suffix(shared.path_from_root('bootstrap'))