diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 4acbafef40..a80165f21a 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -84,12 +84,6 @@ CFLAGS += -DCIRCUITPY_TRANSLATE_OBJECT=$(CIRCUITPY_TRANSLATE_OBJECT) ### # 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 # then invoke make with FROZEN_MPY_DIR=frozen or FROZEN_MPY_DIRS="dir1 dir2" # (be sure to build from scratch). diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py index fd1b6a2b44..5f63fa7c55 100644 --- a/py/makeqstrdata.py +++ b/py/makeqstrdata.py @@ -270,10 +270,10 @@ def qstr_escape(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 = {} qstrs = {} - i18ns = set() + translations = set() # add static qstrs for qstr in static_qstr_list: @@ -305,7 +305,7 @@ def parse_input_headers(infiles): match = re.match(r'^TRANSLATE\("(.*)"\)$', line) if match: - i18ns.add(match.group(1)) + translations.add(match.group(1)) continue # 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.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): 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) -def print_qstr_data(qcfgs, qstrs, i18ns): +def print_qstr_data(qcfgs, qstrs, translations): # get config variables cfg_bytes_len = int(qcfgs["BYTES_IN_LEN"]) cfg_bytes_hash = int(qcfgs["BYTES_IN_HASH"]) @@ -393,7 +397,7 @@ def print_qstr_data(qcfgs, qstrs, i18ns): print( "// 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() @@ -402,8 +406,8 @@ def print_qstr_data(qcfgs, qstrs, i18ns): def do_work(infiles): - qcfgs, qstrs, i18ns = parse_input_headers(infiles) - print_qstr_data(qcfgs, qstrs, i18ns) + qcfgs, qstrs, translations = parse_input_headers_with_translations(infiles) + print_qstr_data(qcfgs, qstrs, translations) if __name__ == "__main__": import argparse diff --git a/py/mkrules.mk b/py/mkrules.mk index ebba517138..730ac9704f 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -166,7 +166,7 @@ endif ifneq ($(FROZEN_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) endif diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 18d2b65c41..31212fd5bd 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -1,6 +1,28 @@ #!/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 from __future__ import print_function