Commit d926fa5d authored by schneider's avatar schneider
Browse files

Merge branch 'rahix/meson-micropython' into 'master'

fix(build): Fix module changes not getting picked up

See merge request card10/firmware!328
parents 8a2de29e d71a6cf8
......@@ -3,6 +3,8 @@
import sys
import os
import tempfile
import shutil
def main():
......@@ -16,23 +18,41 @@ def main():
modules |= makemoduledefs.find_module_registrations(source)
stdout = sys.stdout
with open(sys.argv[2], "w") as f:
sys.stdout = f
with tempfile.TemporaryFile("w+") as temp:
sys.stdout = temp
makemoduledefs.generate_module_table_header(sorted(modules))
sys.stdout = stdout
# Read contents of existing file and compare
try:
with open(sys.argv[2], "r") as f:
old_content = f.read()
except FileNotFoundError:
old_content = ""
temp.seek(0)
new_content = temp.read()
if new_content == old_content:
# If both file contain the same content, exit early
sys.exit(0)
with open(sys.argv[2], "w") as f:
f.write(new_content)
try:
os.mkdir(os.path.dirname(sys.argv[2]) + "/genhdr")
except FileExistsError:
pass
linkname = os.path.dirname(sys.argv[2]) + "/genhdr/" + os.path.basename(sys.argv[2])
linkname = (
os.path.dirname(sys.argv[2]) + "/genhdr/" + os.path.basename(sys.argv[2])
)
if os.path.exists(linkname):
os.unlink(linkname)
os.symlink(
"../" + os.path.basename(sys.argv[2]),
linkname,
)
shutil.copy(sys.argv[2], linkname)
sys.stdout = stdout
if __name__ == "__main__":
......
......@@ -11,8 +11,6 @@ shift 5
OUTPUT_DIR="$(dirname "$OUTPUT")"
mkdir -p "$OUTPUT_DIR/genhdr"
ln -sf "$(realpath --relative-to="$OUTPUT_DIR/genhdr" "$OUTPUT")" "$OUTPUT_DIR/genhdr/$(basename "$OUTPUT")"
# call gcc -E to generate qstr.i.last
gcc -E -DNO_QSTR -I"$SOURCE_DIR/micropython" -I"$PROJECT_SRC" -I"$OUTPUT_DIR" "$@" >"$OUTPUT_DIR/qstr.i.last"
......
qstr_genhdr_h = custom_target(
'genhdr-qstrdefs.generated.h',
output: 'qstrdefs.generated.h',
input: qstr_h,
command: ['cp', '@INPUT@', '@OUTPUT@'],
)
......@@ -43,6 +43,7 @@ qstr_h = custom_target(
input: [
'modules/qstrdefs.h',
'mpconfigport.h',
modules_h,
micropython_sources,
micropython_extmod_sources,
],
......@@ -50,7 +51,9 @@ qstr_h = custom_target(
command: [micropython_gen_qstr, meson.current_source_dir(), '@OUTPUT@', '@INPUT@'],
)
mp_headers = [version_h, modules_h, qstr_h]
subdir('./genhdr')
mp_headers = [version_h, modules_h, qstr_h, qstr_genhdr_h]
#################################
# Python Frozen Modules #
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment