Improved.

This commit is contained in:
Brad Nelson
2023-12-22 16:13:15 -08:00
parent e92130391c
commit d73d340271
4 changed files with 69 additions and 97 deletions

104
Makefile
View File

@ -234,57 +234,52 @@ sanity_test_web: $(WEB)/ueforth.js
$(GEN): $(GEN):
mkdir -p $@ mkdir -p $@
-include $(GEN)/posix_boot_merged.fs.dd
$(GEN)/posix_boot_merged.fs: posix/posix_boot.fs | $(GEN) $(GEN)/posix_boot_merged.fs: posix/posix_boot.fs | $(GEN)
./tools/importation.py $< $@ \ ./tools/importation.py $< $@ \
-I . -I $(GEN) --depsout $@.dd \ -I . -I $(GEN) --depsout $@.dd \
--set-version $(VERSION) \ --set-version $(VERSION) \
--set-revision $(REVISION) --set-revision $(REVISION)
-include $(GEN)/posix_boot_merged.fs.dd
$(GEN)/posix_boot.h: tools/source_to_string.js $(GEN)/posix_boot_merged.fs | $(GEN) $(GEN)/posix_boot.h: tools/source_to_string.js $(GEN)/posix_boot_merged.fs | $(GEN)
$< boot $(VERSION) $(REVISION) $(GEN)/posix_boot_merged.fs >$@ $< boot $(VERSION) $(REVISION) $(GEN)/posix_boot_merged.fs >$@
-include $(GEN)/windows_boot_extra_merged.fs.dd
$(GEN)/windows_boot_extra_merged.fs: windows/windows_boot_extra.fs | $(GEN) $(GEN)/windows_boot_extra_merged.fs: windows/windows_boot_extra.fs | $(GEN)
./tools/importation.py $< $@ \ ./tools/importation.py $< $@ \
-I . -I $(GEN) --depsout $@.dd \ -I . -I $(GEN) --depsout $@.dd \
--set-version $(VERSION) \ --set-version $(VERSION) \
--set-revision $(REVISION) --set-revision $(REVISION)
-include $(GEN)/windows_boot_extra_merged.fs.dd
$(GEN)/windows_boot_extra.h: tools/source_to_string.js $(GEN)/windows_boot_extra_merged.fs | $(GEN) $(GEN)/windows_boot_extra.h: tools/source_to_string.js $(GEN)/windows_boot_extra_merged.fs | $(GEN)
$< -win boot_extra $(VERSION) $(REVISION) $(GEN)/windows_boot_extra_merged.fs >$@ $< -win boot_extra $(VERSION) $(REVISION) $(GEN)/windows_boot_extra_merged.fs >$@
-include $(GEN)/windows_boot_merged.fs.dd
$(GEN)/windows_boot_merged.fs: windows/windows_boot.fs | $(GEN) $(GEN)/windows_boot_merged.fs: windows/windows_boot.fs | $(GEN)
./tools/importation.py $^ $@ \ ./tools/importation.py $^ $@ \
-I . -I $(GEN) --depsout $@.dd \ -I . -I $(GEN) --depsout $@.dd \
--set-version $(VERSION) \ --set-version $(VERSION) \
--set-revision $(REVISION) --set-revision $(REVISION)
-include $(GEN)/windows_boot_merged.fs.dd
$(GEN)/windows_boot.h: tools/source_to_string.js $(GEN)/windows_boot_merged.fs | $(GEN) $(GEN)/windows_boot.h: tools/source_to_string.js $(GEN)/windows_boot_merged.fs | $(GEN)
$< -win boot $(VERSION) $(REVISION) $(GEN)/windows_boot_merged.fs >$@ $< -win boot $(VERSION) $(REVISION) $(GEN)/windows_boot_merged.fs >$@
-include $(GEN)/pico_ice_boot_merged.fs.dd
$(GEN)/pico_ice_boot_merged.fs: pico-ice/pico_ice_boot.fs | $(GEN) $(GEN)/pico_ice_boot_merged.fs: pico-ice/pico_ice_boot.fs | $(GEN)
./tools/importation.py $^ $@ \ ./tools/importation.py $^ $@ \
-I . -I $(GEN) --depsout $@.dd \ -I . -I $(GEN) --depsout $@.dd \
--set-version $(VERSION) \ --set-version $(VERSION) \
--set-revision $(REVISION) --set-revision $(REVISION)
-include $(GEN)/pico_ice_boot_merged.fs.dd
$(GEN)/pico_ice_boot.h: tools/source_to_string.js $(GEN)/pico_ice_boot_merged.fs | $(GEN) $(GEN)/pico_ice_boot.h: tools/source_to_string.js $(GEN)/pico_ice_boot_merged.fs | $(GEN)
$< boot $(VERSION) $(REVISION) $(GEN)/pico_ice_boot_merged.fs >$@ $< boot $(VERSION) $(REVISION) $(GEN)/pico_ice_boot_merged.fs >$@
-include $(GEN)/esp32_boot_merged.fs.dd
$(GEN)/esp32_boot_merged.fs: esp32/esp32_boot.fs | $(GEN) $(GEN)/esp32_boot_merged.fs: esp32/esp32_boot.fs | $(GEN)
./tools/importation.py $^ $@ \ ./tools/importation.py $^ $@ \
-I . -I $(GEN) --depsout $@.dd \ -I . -I $(GEN) --depsout $@.dd \
--set-version $(VERSION) \ --set-version $(VERSION) \
--set-revision $(REVISION) --set-revision $(REVISION)
-include $(GEN)/esp32_boot_merged.fs.dd
$(GEN)/esp32_boot.h: tools/source_to_string.js $(GEN)/esp32_boot_merged.fs | $(GEN) $(GEN)/esp32_boot.h: tools/source_to_string.js $(GEN)/esp32_boot_merged.fs | $(GEN)
$< boot $(VERSION) $(REVISION) $(GEN)/esp32_boot_merged.fs >$@ $< boot $(VERSION) $(REVISION) $(GEN)/esp32_boot_merged.fs >$@
@ -358,10 +353,9 @@ drop-optional:
$(ESP32)/ESP32forth/%.h: $(ESP32)/ESP32forth/optional/%.h $(ESP32)/ESP32forth/%.h: $(ESP32)/ESP32forth/optional/%.h
cp $< $@ cp $< $@
-include $(GEN)/dump_web_opcodes.dd
$(GEN)/dump_web_opcodes: web/dump_web_opcodes.c | $(GEN) $(GEN)/dump_web_opcodes: web/dump_web_opcodes.c | $(GEN)
$(CXX) $(CFLAGS) $< -o $@ -MD -MF $@.dd $(CXX) $(CFLAGS) $< -o $@ -MD -MF $@.dd
-include $(GEN)/dump_web_opcodes.dd
$(GEN)/web_cases.js: $(GEN)/dump_web_opcodes | $(GEN) $(GEN)/web_cases.js: $(GEN)/dump_web_opcodes | $(GEN)
$< cases >$@ $< cases >$@
@ -372,13 +366,12 @@ $(GEN)/web_dict.js: $(GEN)/dump_web_opcodes | $(GEN)
$(GEN)/web_sys.js: $(GEN)/dump_web_opcodes | $(GEN) $(GEN)/web_sys.js: $(GEN)/dump_web_opcodes | $(GEN)
$< sys >$@ $< sys >$@
-include $(GEN)/web_boot_merged.fs.dd
$(GEN)/web_boot_merged.fs: web/web_boot.fs | $(GEN) $(GEN)/web_boot_merged.fs: web/web_boot.fs | $(GEN)
./tools/importation.py $^ $@ \ ./tools/importation.py $^ $@ \
-I . -I $(GEN) --depsout $@.dd \ -I . -I $(GEN) --depsout $@.dd \
--set-version $(VERSION) \ --set-version $(VERSION) \
--set-revision $(REVISION) --set-revision $(REVISION)
-include $(GEN)/web_boot_merged.fs.dd
$(GEN)/web_boot.js: tools/source_to_string.js $(GEN)/web_boot_merged.fs | $(GEN) $(GEN)/web_boot.js: tools/source_to_string.js $(GEN)/web_boot_merged.fs | $(GEN)
$< -web boot $(VERSION) $(REVISION) $(GEN)/web_boot_merged.fs >$@ $< -web boot $(VERSION) $(REVISION) $(GEN)/web_boot_merged.fs >$@
@ -460,12 +453,11 @@ posix_target: $(POSIX)/ueforth
$(POSIX): $(POSIX):
mkdir -p $@ mkdir -p $@
-include $(GEN)/ueforth_posix.dd
$(POSIX)/ueforth: \ $(POSIX)/ueforth: \
posix/main.c $(GEN)/posix_boot.h | $(POSIX) posix/main.c $(GEN)/posix_boot.h | $(POSIX)
$(CXX) $(CFLAGS) $< -o $@ $(LIBS) -MD -MF $(GEN)/ueforth_posix.dd $(CXX) $(CFLAGS) $< -o $@ $(LIBS) -MD -MF $(GEN)/ueforth_posix.dd
strip $(STRIP_ARGS) $@ strip $(STRIP_ARGS) $@
-include $(GEN)/ueforth_posix.dd
# ---- WINDOWS ---- # ---- WINDOWS ----
@ -477,28 +469,26 @@ win64_target: $(WINDOWS)/uEf64.exe
$(WINDOWS): $(WINDOWS):
mkdir -p $@ mkdir -p $@
-include $(WINDOWS)/uEf32.obj.dd
$(WINDOWS)/uEf32.obj: \ $(WINDOWS)/uEf32.obj: \
windows/main.c \ windows/main.c \
$(GEN)/windows_boot_extra.h \ $(GEN)/windows_boot_extra.h \
$(GEN)/windows_boot.h | $(WINDOWS) $(GEN)/windows_boot.h | $(WINDOWS)
./tools/importation.py $< $@ --no-out -I . -I $(GEN) --depsout $@.dd ./tools/importation.py $< $@ --no-out -I . -I $(GEN) --depsout $@.dd
$(CL32) /c /Fo$@ $(WIN_CFLAGS) $< $(CL32) /c /Fo$@ $(WIN_CFLAGS) $<
-include $(WINDOWS)/uEf32.obj.dd
$(WINDOWS)/uEf32.exe: \ $(WINDOWS)/uEf32.exe: \
$(WINDOWS)/uEf32.obj \ $(WINDOWS)/uEf32.obj \
$(RES)/ueforth_res32.res | $(WINDOWS) $(RES)/ueforth_res32.res | $(WINDOWS)
$(LINK32) /OUT:$@ $(WIN_LFLAGS32) $^ $(LINK32) /OUT:$@ $(WIN_LFLAGS32) $^
-include $(WINDOWS)/uEf64.obj.dd
$(WINDOWS)/uEf64.obj: \ $(WINDOWS)/uEf64.obj: \
windows/main.c \ windows/main.c \
$(GEN)/windows_boot_extra.h \ $(GEN)/windows_boot_extra.h \
$(GEN)/windows_boot.h | $(WINDOWS) $(GEN)/windows_boot.h | $(WINDOWS)
./tools/importation.py $< $@ --no-out -I . -I $(GEN) --depsout $@.dd ./tools/importation.py $< $@ --no-out -I . -I $(GEN) --depsout $@.dd
$(CL64) /c /Fo$@ $(WIN_CFLAGS) $< $(CL64) /c /Fo$@ $(WIN_CFLAGS) $<
-include $(WINDOWS)/uEf64.obj.dd
$(WINDOWS)/uEf64.exe: \ $(WINDOWS)/uEf64.exe: \
$(WINDOWS)/uEf64.obj \ $(WINDOWS)/uEf64.obj \
@ -513,22 +503,20 @@ esp32_sim_target: $(ESP32_SIM)/Esp32forth-sim
$(ESP32_SIM): $(ESP32_SIM):
mkdir -p $@ mkdir -p $@
-include $(GEN)/print-esp32-builtins.dd
$(GEN)/print-esp32-builtins: esp32/print-builtins.cpp | $(GEN) $(GEN)/print-esp32-builtins: esp32/print-builtins.cpp | $(GEN)
$(CXX) $(CFLAGS) $< -o $@ -MD -MF $@.dd $(CXX) $(CFLAGS) $< -o $@ -MD -MF $@.dd
-include $(GEN)/print-esp32-builtins.dd
$(GEN)/esp32_sim_opcodes.h: $(GEN)/print-esp32-builtins | $(GEN) $(GEN)/esp32_sim_opcodes.h: $(GEN)/print-esp32-builtins | $(GEN)
$< >$@ $< >$@
-include $(GEN)/esp32_sim.dd
$(ESP32_SIM)/Esp32forth-sim: \ $(ESP32_SIM)/Esp32forth-sim: \
esp32/sim_main.cpp \ esp32/sim_main.cpp \
$(GEN)/esp32_boot.h \ $(GEN)/esp32_boot.h \
$(GEN)/esp32_sim_opcodes.h | $(ESP32_SIM) $(GEN)/esp32_sim_opcodes.h | $(ESP32_SIM)
$(CXX) $(CFLAGS) $< -o $@ -MD -MF $(GEN)/esp32_sim.dd $(CXX) $(CFLAGS) $< -o $@ -MD -MF $(GEN)/esp32_sim.dd
strip $(STRIP_ARGS) $@ strip $(STRIP_ARGS) $@
-include $(GEN)/esp32_sim.dd
# ---- ESP32 ---- # ---- ESP32 ----
@ -541,46 +529,15 @@ $(ESP32)/ESP32forth:
$(ESP32)/ESP32forth/optional: $(ESP32)/ESP32forth/optional:
mkdir -p $@ mkdir -p $@
ESP32_PARTS = tools/replace.js \ $(ESP32)/ESP32forth/ESP32forth.ino: \
esp32/ESP32forth.ino \ esp32/ESP32forth.ino \
common/tier0_opcodes.h \ $(GEN)/esp32_boot.h | $(ESP32)/ESP32forth
common/tier1_opcodes.h \ ./tools/importation.py $< $@ \
common/tier2_opcodes.h \ --keep-first-comment \
common/floats.h \ -I . -I $(GEN) --depsout $(GEN)/esp32.dd \
common/calls.h \ --set-version $(VERSION) \
common/calling.h \ --set-revision $(REVISION)
common/bits.h \ -include $(GEN)/esp32.dd
common/core.h \
common/interp.h \
esp32/faults.h \
esp32/platform.h \
esp32/options.h \
esp32/builtins.h \
esp32/builtins.cpp \
esp32/main.cpp \
$(GEN)/esp32_boot.h
$(ESP32)/ESP32forth/ESP32forth.ino: $(ESP32_PARTS) | $(ESP32)/ESP32forth
cat esp32/ESP32forth.ino | tools/replace.js \
VERSION=$(VERSION) \
REVISION=$(REVISION) \
tier0_opcodes=@common/tier0_opcodes.h \
tier1_opcodes=@common/tier1_opcodes.h \
tier2_opcodes=@common/tier2_opcodes.h \
calls=@common/calls.h \
calling=@common/calling.h \
floats=@common/floats.h \
bits=@common/bits.h \
core=@common/core.h \
interp=@common/interp.h \
faults=@esp32/faults.h \
platform=@esp32/platform.h \
options=@esp32/options.h \
builtins.h=@esp32/builtins.h \
builtins.cpp=@esp32/builtins.cpp \
main.cpp=@esp32/main.cpp \
boot=@$(GEN)/esp32_boot.h \
>$@
$(ESP32)/ESP32forth/README.txt: esp32/README.txt | $(ESP32)/ESP32forth $(ESP32)/ESP32forth/README.txt: esp32/README.txt | $(ESP32)/ESP32forth
cat esp32/README.txt | tools/replace.js \ cat esp32/README.txt | tools/replace.js \
@ -733,21 +690,11 @@ $(PICO_ICE)/ueforth-pico-ice/ueforth-pico-ice.uf2: \
$(PICO_ICE)/ueforth_pico_ice.uf2 | $(PICO_ICE)/ueforth-pico-ice $(PICO_ICE)/ueforth_pico_ice.uf2 | $(PICO_ICE)/ueforth-pico-ice
cp $< $@ cp $< $@
.FORCE:
$(PICO_ICE)/ueforth_pico_ice.uf2: \ $(PICO_ICE)/ueforth_pico_ice.uf2: \
$(PICO_ICE)/build.ninja \ .FORCE \
pico-ice/main.c \ $(GEN)/pico_ice_boot.h \
pico-ice/builtins.h \ $(PICO_ICE)/build.ninja
common/tier0_opcodes.h \
common/tier1_opcodes.h \
common/tier2_opcodes.h \
common/floats.h \
common/calls.h \
common/calling.h \
common/floats.h \
common/bits.h \
common/core.h \
common/interp.h \
$(GEN)/pico_ice_boot.h
ninja -C $(PICO_ICE) ueforth_pico_ice ninja -C $(PICO_ICE) ueforth_pico_ice
$(PICO_ICE)/build.ninja: \ $(PICO_ICE)/build.ninja: \
@ -788,11 +735,10 @@ pico_ice_sim_target: $(PICO_ICE_SIM)/ueforth_pico_ice_sim
$(PICO_ICE_SIM): $(PICO_ICE_SIM):
mkdir -p $@ mkdir -p $@
-include $(GEN)/pico_ice_sim.dd
$(PICO_ICE_SIM)/ueforth_pico_ice_sim: \ $(PICO_ICE_SIM)/ueforth_pico_ice_sim: \
pico-ice/main.c $(GEN)/pico_ice_boot.h | $(PICO_ICE_SIM) $(GEN) pico-ice/main.c $(GEN)/pico_ice_boot.h | $(PICO_ICE_SIM) $(GEN)
$(CXX) $(CFLAGS) -DUEFORTH_SIM=1 $< -o $@ -MD -MF $(GEN)/pico_ice_sim.dd $(CXX) $(CFLAGS) -DUEFORTH_SIM=1 $< -o $@ -MD -MF $(GEN)/pico_ice_sim.dd
-include $(GEN)/pico_ice_sim.dd
# ---- PACKAGE ESP32 ---- # ---- PACKAGE ESP32 ----

View File

@ -19,14 +19,14 @@
* Revision: {{REVISION}} * Revision: {{REVISION}}
*/ */
{{platform}} #include "esp32/platform.h"
{{options}} #include "esp32/options.h"
{{tier0_opcodes}} #include "common/tier0_opcodes.h"
{{tier1_opcodes}} #include "common/tier1_opcodes.h"
{{tier2_opcodes}} #include "common/tier2_opcodes.h"
{{floats}} #include "common/floats.h"
{{calls}} #include "common/calls.h"
{{bits}} #include "common/bits.h"
{{builtins.h}} #include "esp32/builtins.h"
{{builtins.cpp}} #include "esp32/builtins.cpp"
{{main.cpp}} #include "esp32/main.cpp"

View File

@ -15,11 +15,11 @@
static char filename[PATH_MAX]; static char filename[PATH_MAX];
static char filename2[PATH_MAX]; static char filename2[PATH_MAX];
{{core}} #include "common/core.h"
{{faults}} #include "esp32/faults.h"
{{calling}} #include "common/calling.h"
{{interp}} #include "common/interp.h"
{{boot}} #include "esp32_boot.h"
// Work around lack of ftruncate // Work around lack of ftruncate
static cell_t ResizeFile(cell_t fd, cell_t size) { static cell_t ResizeFile(cell_t fd, cell_t size) {

View File

@ -14,6 +14,7 @@ parser.add_argument('--set-version')
parser.add_argument('--set-revision') parser.add_argument('--set-revision')
parser.add_argument('--depsout') parser.add_argument('--depsout')
parser.add_argument('--no-out', action='store_true') parser.add_argument('--no-out', action='store_true')
parser.add_argument('--keep-first-comment', action='store_true')
args = parser.parse_args() args = parser.parse_args()
bases = args.I or [] bases = args.I or []
@ -33,6 +34,7 @@ def Import(filename):
sfilename = os.path.join(os.path.dirname(filename), sfilename) sfilename = os.path.join(os.path.dirname(filename), sfilename)
Import(sfilename) Import(sfilename)
elif (filename.endswith('.h') or elif (filename.endswith('.h') or
filename.endswith('.ino') or
filename.endswith('.cc') or filename.endswith('.cc') or
filename.endswith('.c')) and line.startswith('#include "'): filename.endswith('.c')) and line.startswith('#include "'):
sfilename = line.split('"')[1] sfilename = line.split('"')[1]
@ -50,17 +52,41 @@ def Import(filename):
def Process(): def Process():
Import(args.input) Import(args.input)
# Conversion version tags.
output = []
for line in results: for line in results:
if args.set_version: if args.set_version:
line = line.replace('{{VERSION}}', args.set_version) line = line.replace('{{VERSION}}', args.set_version)
if args.set_revision: if args.set_revision:
line = line.replace('{{REVISION}}', args.set_revision) line = line.replace('{{REVISION}}', args.set_revision)
output.append(line)
# Drop comments.
comment1 = False
comment2 = False
counter = 0
old_output = output
output = []
for line in old_output:
if line == '<!--':
comment1 = True
elif comment1 and line == '-->':
comment1 = False
elif 'Copyright' in line:
if counter != 0 or not args.keep_first_comment:
comment2 = True
counter += 1
elif comment2 and line == '':
comment2 = False
elif not comment1 and not comment2:
output.append(line)
# Emit deps.
if args.depsout: if args.depsout:
with open(args.depsout, 'w') as fh: with open(args.depsout, 'w') as fh:
fh.write(args.output + ': ' + fh.write(args.output + ': ' +
' '.join([os.path.relpath(i) for i in imported]) + '\n') ' '.join([os.path.relpath(i) for i in imported]) + '\n')
# Emit expanded file.
if not args.no_out: if not args.no_out:
with open(args.output, 'w') as fh: with open(args.output, 'w') as fh:
fh.write('\n'.join(results) + '\n') fh.write('\n'.join(output) + '\n')
Process() Process()