From 47e2b25a50813ee1ba46966bc301ebd57d03bfef Mon Sep 17 00:00:00 2001 From: Faidon Liambotis Date: Mon, 13 Mar 2023 15:39:47 +0000 Subject: [PATCH] flasher_stub: drop --embed from wrap_stub.py Since commit 94f29a5 the flasher stub is not embedded in the Python source, but rather included as simple json files. As such, wrap_stub.py --embed was converted to basically just vary the build dir. Rather than keep this indirection and for better clarity, remove that piece of code and replace it by a simple "cp" in the Makefile. While at it, replace the target name from "embed" to "install", as this more akin to a "make install" step. --- flasher_stub/Makefile | 12 ++++++------ flasher_stub/README.md | 2 +- flasher_stub/wrap_stub.py | 7 +------ 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/flasher_stub/Makefile b/flasher_stub/Makefile index 41eae45585..739ada7e38 100644 --- a/flasher_stub/Makefile +++ b/flasher_stub/Makefile @@ -1,7 +1,7 @@ # Makefile to compile the flasher stub program # # Note that YOU DO NOT NEED TO COMPILE THIS IN ORDER TO JUST USE -# esptool.py - a precompiled version is embedded in esptool.py, +# esptool.py - a precompiled version is included in esptool.py, # so if you don't want to modify the stub code then you are good to go. # # See the comments in the top of the Makefile for parameters that @@ -91,11 +91,11 @@ STUBS_ELF += \ $(STUB_ELF_32H2) endif -.PHONY: all clean embed +.PHONY: all clean install all: $(STUBS_ELF:.elf=.json) -embed: $(patsubst $(BUILD_DIR)/%.elf,$(ESPTOOL_STUBS_DIR)/%.json,$(STUBS_ELF)) +install: $(patsubst $(BUILD_DIR)/%.elf,$(ESPTOOL_STUBS_DIR)/%.json,$(STUBS_ELF)) $(BUILD_DIR): $(Q) mkdir $@ @@ -104,9 +104,9 @@ $(BUILD_DIR)/%.json: $(BUILD_DIR)/%.elf @echo " WRAP $^ -> $(BUILD_DIR)" $(Q) $(WRAP_STUB) $^ -$(ESPTOOL_STUBS_DIR)/%.json: $(BUILD_DIR)/%.elf - @echo " WRAP $^ -> $(ESPTOOL_STUBS_DIR)" - $(Q) $(WRAP_STUB) --embed $^ +$(ESPTOOL_STUBS_DIR)/%.json: $(BUILD_DIR)/%.json + @echo " INSTALL $^ -> $@" + $(Q) cp $^ $@ CFLAGS = -std=c99 -Wall -Werror -Os \ -mtext-section-literals -mlongcalls -nostdlib -fno-builtin -flto \ diff --git a/flasher_stub/README.md b/flasher_stub/README.md index 455331b2f4..052909c3f5 100644 --- a/flasher_stub/README.md +++ b/flasher_stub/README.md @@ -34,7 +34,7 @@ Activating an ESP-IDF environment takes care of most of these steps (only the ES # To Test -To test the built stub, you can run `make embed` (or `make embed WITHOUT_ESP8266=1`), which will update the stubs in `esptool.py` to the newly compiled ones. Or there are some convenience wrappers to make testing quicker to iterate on: +To test the built stub, you can run `make install` (or `make install WITHOUT_ESP8266=1`), which will update the stubs in `esptool.py` to the newly compiled ones. Or there are some convenience wrappers to make testing quicker to iterate on: * Running `esptool_test_stub.py` is the same as running `esptool.py`, only it uses the just-compiled stubs from the build directory. diff --git a/flasher_stub/wrap_stub.py b/flasher_stub/wrap_stub.py index d206a9599a..fe063618b6 100755 --- a/flasher_stub/wrap_stub.py +++ b/flasher_stub/wrap_stub.py @@ -18,7 +18,6 @@ THIS_DIR = os.path.dirname(__file__) BUILD_DIR = os.path.join(THIS_DIR, "./build/") -STUBS_DIR = os.path.join(THIS_DIR, "../esptool/targets/stub_flasher/") def wrap_stub(elf_file): @@ -67,8 +66,7 @@ def default(self, obj): return json.JSONEncoder.default(self, obj) for filename, stub_data in stubs_dict.items(): - DIR = STUBS_DIR if args.embed else BUILD_DIR - with open(DIR + filename, "w") as outfile: + with open(BUILD_DIR + filename, "w") as outfile: json.dump(stub_data, outfile, cls=BytesEncoder, indent=4) @@ -79,9 +77,6 @@ def stub_name(filename): if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument( - "--embed", help="Embed stub json files into esptool.py", action="store_true" - ) parser.add_argument("elf_files", nargs="+", help="Stub ELF files to convert") args = parser.parse_args()