Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[embuilder] Add support for '*' wildcard for matching library names #21236

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions embuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""

import argparse
import fnmatch
import logging
import sys
import time
Expand Down Expand Up @@ -120,7 +121,7 @@


def get_help():
all_tasks = get_system_tasks()[1] + PORTS
all_tasks = get_all_tasks()
all_tasks.sort()
return '''
Available targets:
Expand Down Expand Up @@ -163,6 +164,10 @@ def get_system_tasks():
return system_libraries, system_tasks


def get_all_tasks():
return get_system_tasks()[1] + PORTS


def main():
all_build_start_time = time.time()

Expand Down Expand Up @@ -239,7 +244,10 @@ def main():
for name, targets in task_targets.items():
if targets is None:
# Use target name as task
tasks.append(name)
if '*' in name:
tasks.extend(fnmatch.filter(get_all_tasks(), name))
else:
tasks.append(name)
else:
# There are some ports that we don't want to build as part
# of ALL since the are not well tested or widely used:
Expand Down
13 changes: 11 additions & 2 deletions test/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.

import glob
import os
import platform
import shutil
Expand Down Expand Up @@ -729,16 +730,24 @@ def test_embuilder_auto_tasks(self):
# Unless --force is specified
self.assertContained('Building targets: zlib', self.do([EMBUILDER, 'build', 'zlib', 'MINIMAL', '--force']))

def test_embuilder_wasm_backend(self):
def test_embuilder(self):
restore_and_set_up()
# the --lto flag makes us build wasm-bc
# the --lto flag makes us build LTO libraries
self.clear_cache()
self.run_process([EMBUILDER, 'build', 'libemmalloc'])
self.assertExists(os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten'))
self.clear_cache()
self.run_process([EMBUILDER, 'build', 'libemmalloc', '--lto'])
self.assertExists(os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten', 'lto'))

def test_embuilder_wildcards(self):
restore_and_set_up()
glob_match = os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten', 'libwebgpu*.a')
self.run_process([EMBUILDER, 'clear', 'libwebgpu*'])
self.assertFalse(glob.glob(glob_match))
self.run_process([EMBUILDER, 'build', 'libwebgpu*'])
self.assertGreater(len(glob.glob(glob_match)), 3)

def test_binaryen_version(self):
restore_and_set_up()
with open(EM_CONFIG, 'a') as f:
Expand Down
Loading