[v0.1.0a5] Handled the case that no symbol is exported in .o file
This commit is contained in:
parent
33e7e5a8cb
commit
26db97fb12
3 changed files with 15 additions and 6 deletions
|
@ -1,4 +1,6 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
## 0.1.0a5
|
||||||
|
- Handled the case that no symbol is exported in .o file
|
||||||
## 0.1.0a4
|
## 0.1.0a4
|
||||||
- Added `compile_flags` property to `Gecko` class
|
- Added `compile_flags` property to `Gecko` class
|
||||||
## 0.1.0a3
|
## 0.1.0a3
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = supGecko
|
name = supGecko
|
||||||
version = 0.1.0a4
|
version = 0.1.0a5
|
||||||
author = sup39
|
author = sup39
|
||||||
author_email = sms@sup39.dev
|
author_email = sms@sup39.dev
|
||||||
description = A helper library to write Gecko code
|
description = A helper library to write Gecko code
|
||||||
|
@ -15,7 +15,8 @@ classifiers =
|
||||||
License :: OSI Approved :: MIT License
|
License :: OSI Approved :: MIT License
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
packages = find:
|
packages = find_namespace:
|
||||||
|
include_package_data = True
|
||||||
python_requires = >=3.8
|
python_requires = >=3.8
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
|
|
|
@ -7,10 +7,15 @@ import tempfile
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def system(argv, *args, **kwargs):
|
def system(argv, *, catch=None, **kwargs):
|
||||||
r = subprocess.run(argv, *args, capture_output=True, text=True, **kwargs)
|
r = subprocess.run(argv, capture_output=True, text=True, **kwargs)
|
||||||
if r.returncode:
|
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
|
return r.stdout
|
||||||
|
|
||||||
def write_extra_input(x, file):
|
def write_extra_input(x, file):
|
||||||
|
@ -83,10 +88,11 @@ def compile(
|
||||||
|
|
||||||
# gecko symbols
|
# gecko symbols
|
||||||
symbols = {}
|
symbols = {}
|
||||||
|
errmsg_nosymbol = "section '.text' mentioned in a -j option, but not found in any input file"
|
||||||
lines = system([
|
lines = system([
|
||||||
'powerpc-eabi-objdump',
|
'powerpc-eabi-objdump',
|
||||||
'-tj.text', distLOBJ,
|
'-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]:
|
for line in lines[4:-3]:
|
||||||
ch1, ch2 = line.split('\t')
|
ch1, ch2 = line.split('\t')
|
||||||
addr = int(ch1.split(None, 2)[0], 16)
|
addr = int(ch1.split(None, 2)[0], 16)
|
||||||
|
|
Loading…
Reference in a new issue