diff --git a/CHANGELOG.md b/CHANGELOG.md index 23fb959..7a731e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # Changelog +## 0.1.0a5 +- Handled the case that no symbol is exported in .o file ## 0.1.0a4 - Added `compile_flags` property to `Gecko` class ## 0.1.0a3 diff --git a/setup.cfg b/setup.cfg index 4d7d3a8..38d3abe 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = supGecko -version = 0.1.0a4 +version = 0.1.0a5 author = sup39 author_email = sms@sup39.dev description = A helper library to write Gecko code @@ -15,7 +15,8 @@ classifiers = License :: OSI Approved :: MIT License [options] -packages = find: +packages = find_namespace: +include_package_data = True python_requires = >=3.8 [options.packages.find] diff --git a/src/supGecko/asm.py b/src/supGecko/asm.py index 0fb1ba3..c2a183c 100644 --- a/src/supGecko/asm.py +++ b/src/supGecko/asm.py @@ -7,10 +7,15 @@ import tempfile import os import subprocess -def system(argv, *args, **kwargs): - r = subprocess.run(argv, *args, capture_output=True, text=True, **kwargs) +def system(argv, *, catch=None, **kwargs): + r = subprocess.run(argv, capture_output=True, text=True, **kwargs) if r.returncode: - raise Exception(f'Fail to run {argv[0]} (code={r.returncode}): {r.stderr}') + if catch is not None: + # catch(r) returns the alternate stdout for handled errors + o = catch(r) + # if catch(r) returns None, the error is unexpected and should be raised + if o is not None: return o + raise Exception(f'Fail to run {argv} (code={r.returncode}): {r.stderr}') return r.stdout def write_extra_input(x, file): @@ -83,10 +88,11 @@ def compile( # gecko symbols symbols = {} + errmsg_nosymbol = "section '.text' mentioned in a -j option, but not found in any input file" lines = system([ 'powerpc-eabi-objdump', '-tj.text', distLOBJ, - ]).split('\n') + ], catch=lambda r: '' if r.returncode==1 and errmsg_nosymbol in r.stderr else None).split('\n') for line in lines[4:-3]: ch1, ch2 = line.split('\t') addr = int(ch1.split(None, 2)[0], 16)