Skip to content

Commit a9ebfb7

Browse files
authored
[embuilder] Add support for '*' wildcard for matching library names (#21236)
This is very useful for doing things like `./embuild build libGL*` to `./embuilder clean libc*`.
1 parent ec2ce4c commit a9ebfb7

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

embuilder.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414

1515
import argparse
16+
import fnmatch
1617
import logging
1718
import sys
1819
import time
@@ -120,7 +121,7 @@
120121

121122

122123
def get_help():
123-
all_tasks = get_system_tasks()[1] + PORTS
124+
all_tasks = get_all_tasks()
124125
all_tasks.sort()
125126
return '''
126127
Available targets:
@@ -163,6 +164,10 @@ def get_system_tasks():
163164
return system_libraries, system_tasks
164165

165166

167+
def get_all_tasks():
168+
return get_system_tasks()[1] + PORTS
169+
170+
166171
def main():
167172
all_build_start_time = time.time()
168173

@@ -239,7 +244,10 @@ def main():
239244
for name, targets in task_targets.items():
240245
if targets is None:
241246
# Use target name as task
242-
tasks.append(name)
247+
if '*' in name:
248+
tasks.extend(fnmatch.filter(get_all_tasks(), name))
249+
else:
250+
tasks.append(name)
243251
else:
244252
# There are some ports that we don't want to build as part
245253
# of ALL since the are not well tested or widely used:

test/test_sanity.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# University of Illinois/NCSA Open Source License. Both these licenses can be
44
# found in the LICENSE file.
55

6+
import glob
67
import os
78
import platform
89
import shutil
@@ -729,16 +730,24 @@ def test_embuilder_auto_tasks(self):
729730
# Unless --force is specified
730731
self.assertContained('Building targets: zlib', self.do([EMBUILDER, 'build', 'zlib', 'MINIMAL', '--force']))
731732

732-
def test_embuilder_wasm_backend(self):
733+
def test_embuilder(self):
733734
restore_and_set_up()
734-
# the --lto flag makes us build wasm-bc
735+
# the --lto flag makes us build LTO libraries
735736
self.clear_cache()
736737
self.run_process([EMBUILDER, 'build', 'libemmalloc'])
737738
self.assertExists(os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten'))
738739
self.clear_cache()
739740
self.run_process([EMBUILDER, 'build', 'libemmalloc', '--lto'])
740741
self.assertExists(os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten', 'lto'))
741742

743+
def test_embuilder_wildcards(self):
744+
restore_and_set_up()
745+
glob_match = os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten', 'libwebgpu*.a')
746+
self.run_process([EMBUILDER, 'clear', 'libwebgpu*'])
747+
self.assertFalse(glob.glob(glob_match))
748+
self.run_process([EMBUILDER, 'build', 'libwebgpu*'])
749+
self.assertGreater(len(glob.glob(glob_match)), 3)
750+
742751
def test_binaryen_version(self):
743752
restore_and_set_up()
744753
with open(EM_CONFIG, 'a') as f:

0 commit comments

Comments
 (0)