Skip to content

Commit

Permalink
Allow multiple dependencies in bootstrap system
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Dec 15, 2023
1 parent 0c95291 commit 4303855
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
40 changes: 26 additions & 14 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,37 @@
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']),
]


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):
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down

0 comments on commit 4303855

Please sign in to comment.