Skip to content

Commit

Permalink
[embuilder] Add support for '*' wildcard for matching library names (#…
Browse files Browse the repository at this point in the history
…21236)

This is very useful for doing things like `./embuild build libGL*` to
`./embuilder clean libc*`.
  • Loading branch information
sbc100 committed Feb 1, 2024
1 parent ec2ce4c commit a9ebfb7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
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

0 comments on commit a9ebfb7

Please sign in to comment.