wip; fix frozen; still need to fix -j1 for frozen
This commit is contained in:
parent
1b19ed4c39
commit
48e404ab90
|
@ -84,12 +84,6 @@ CFLAGS += -DCIRCUITPY_TRANSLATE_OBJECT=$(CIRCUITPY_TRANSLATE_OBJECT)
|
||||||
###
|
###
|
||||||
# Handle frozen modules.
|
# Handle frozen modules.
|
||||||
|
|
||||||
ifneq ($(FROZEN_DIR),)
|
|
||||||
# To use frozen source modules, put your .py files in a subdirectory (eg scripts/)
|
|
||||||
# and then invoke make with FROZEN_DIR=scripts (be sure to build from scratch).
|
|
||||||
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
|
||||||
endif
|
|
||||||
|
|
||||||
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
|
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
|
||||||
# then invoke make with FROZEN_MPY_DIR=frozen or FROZEN_MPY_DIRS="dir1 dir2"
|
# then invoke make with FROZEN_MPY_DIR=frozen or FROZEN_MPY_DIRS="dir1 dir2"
|
||||||
# (be sure to build from scratch).
|
# (be sure to build from scratch).
|
||||||
|
|
|
@ -270,10 +270,10 @@ def qstr_escape(qst):
|
||||||
return re.sub(r"[^A-Za-z0-9_]", esc_char, qst)
|
return re.sub(r"[^A-Za-z0-9_]", esc_char, qst)
|
||||||
|
|
||||||
|
|
||||||
def parse_input_headers(infiles):
|
def parse_input_headers_with_translations(infiles):
|
||||||
qcfgs = {}
|
qcfgs = {}
|
||||||
qstrs = {}
|
qstrs = {}
|
||||||
i18ns = set()
|
translations = set()
|
||||||
|
|
||||||
# add static qstrs
|
# add static qstrs
|
||||||
for qstr in static_qstr_list:
|
for qstr in static_qstr_list:
|
||||||
|
@ -305,7 +305,7 @@ def parse_input_headers(infiles):
|
||||||
|
|
||||||
match = re.match(r'^TRANSLATE\("(.*)"\)$', line)
|
match = re.match(r'^TRANSLATE\("(.*)"\)$', line)
|
||||||
if match:
|
if match:
|
||||||
i18ns.add(match.group(1))
|
translations.add(match.group(1))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# is this a QSTR line?
|
# is this a QSTR line?
|
||||||
|
@ -347,8 +347,12 @@ def parse_input_headers(infiles):
|
||||||
sys.stderr.write("ERROR: Empty preprocessor output - check for errors above\n")
|
sys.stderr.write("ERROR: Empty preprocessor output - check for errors above\n")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
return qcfgs, qstrs, i18ns
|
return qcfgs, qstrs, translations
|
||||||
|
|
||||||
|
# Used externally by mpy-tool.py. Don't pass back translations.
|
||||||
|
def parse_input_headers(infiles):
|
||||||
|
qcfgs, qstrs, translations = parse_input_headers_with_translations(infiles)
|
||||||
|
return (qcfgs, qstrs)
|
||||||
|
|
||||||
def escape_bytes(qstr, qbytes):
|
def escape_bytes(qstr, qbytes):
|
||||||
if all(32 <= ord(c) <= 126 and c != "\\" and c != '"' for c in qstr):
|
if all(32 <= ord(c) <= 126 and c != "\\" and c != '"' for c in qstr):
|
||||||
|
@ -370,7 +374,7 @@ def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr):
|
||||||
return '%d, %d, "%s"' % (qhash, qlen, qdata)
|
return '%d, %d, "%s"' % (qhash, qlen, qdata)
|
||||||
|
|
||||||
|
|
||||||
def print_qstr_data(qcfgs, qstrs, i18ns):
|
def print_qstr_data(qcfgs, qstrs, translations):
|
||||||
# get config variables
|
# get config variables
|
||||||
cfg_bytes_len = int(qcfgs["BYTES_IN_LEN"])
|
cfg_bytes_len = int(qcfgs["BYTES_IN_LEN"])
|
||||||
cfg_bytes_hash = int(qcfgs["BYTES_IN_HASH"])
|
cfg_bytes_hash = int(qcfgs["BYTES_IN_HASH"])
|
||||||
|
@ -393,7 +397,7 @@ def print_qstr_data(qcfgs, qstrs, i18ns):
|
||||||
print(
|
print(
|
||||||
"// Enumerate translated texts but don't actually include translations. Instead, the linker will link them in."
|
"// Enumerate translated texts but don't actually include translations. Instead, the linker will link them in."
|
||||||
)
|
)
|
||||||
for i, original in enumerate(sorted(i18ns)):
|
for i, original in enumerate(sorted(translations)):
|
||||||
print('TRANSLATION("{}", {})'.format(original, i))
|
print('TRANSLATION("{}", {})'.format(original, i))
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
@ -402,8 +406,8 @@ def print_qstr_data(qcfgs, qstrs, i18ns):
|
||||||
|
|
||||||
|
|
||||||
def do_work(infiles):
|
def do_work(infiles):
|
||||||
qcfgs, qstrs, i18ns = parse_input_headers(infiles)
|
qcfgs, qstrs, translations = parse_input_headers_with_translations(infiles)
|
||||||
print_qstr_data(qcfgs, qstrs, i18ns)
|
print_qstr_data(qcfgs, qstrs, translations)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import argparse
|
import argparse
|
||||||
|
|
|
@ -166,7 +166,7 @@ endif
|
||||||
|
|
||||||
ifneq ($(FROZEN_MANIFEST),)
|
ifneq ($(FROZEN_MANIFEST),)
|
||||||
# to build frozen_content.c from a manifest
|
# to build frozen_content.c from a manifest
|
||||||
$(BUILD)/frozen_content.c: FORCE $(BUILD)/genhdr/qstrdefs.generated.h | $(MICROPY_MPYCROSS_DEPENDENCY)
|
$(BUILD)/frozen_content.c: $(BUILD)/genhdr/qstrdefs.generated.h $(FROZEN_MANIFEST) | $(MICROPY_MPYCROSS_DEPENDENCY)
|
||||||
$(Q)$(MAKE_MANIFEST) -o $@ -v "MPY_DIR=$(TOP)" -v "MPY_LIB_DIR=$(MPY_LIB_DIR)" -v "PORT_DIR=$(shell pwd)" -v "BOARD_DIR=$(BOARD_DIR)" -b "$(BUILD)" $(if $(MPY_CROSS_FLAGS),-f"$(MPY_CROSS_FLAGS)",) --mpy-tool-flags="$(MPY_TOOL_FLAGS)" $(FROZEN_MANIFEST)
|
$(Q)$(MAKE_MANIFEST) -o $@ -v "MPY_DIR=$(TOP)" -v "MPY_LIB_DIR=$(MPY_LIB_DIR)" -v "PORT_DIR=$(shell pwd)" -v "BOARD_DIR=$(BOARD_DIR)" -b "$(BUILD)" $(if $(MPY_CROSS_FLAGS),-f"$(MPY_CROSS_FLAGS)",) --mpy-tool-flags="$(MPY_TOOL_FLAGS)" $(FROZEN_MANIFEST)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,28 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016-2019 Damien P. George
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
|
||||||
# Python 2/3 compatibility code
|
# Python 2/3 compatibility code
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
Loading…
Reference in New Issue