Improved.
This commit is contained in:
106
Makefile
106
Makefile
@ -234,57 +234,52 @@ sanity_test_web: $(WEB)/ueforth.js
|
||||
$(GEN):
|
||||
mkdir -p $@
|
||||
|
||||
-include $(GEN)/posix_boot_merged.fs.dd
|
||||
|
||||
$(GEN)/posix_boot_merged.fs: posix/posix_boot.fs | $(GEN)
|
||||
./tools/importation.py $< $@ \
|
||||
-I . -I $(GEN) --depsout $@.dd \
|
||||
--set-version $(VERSION) \
|
||||
--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)
|
||||
$< 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)
|
||||
./tools/importation.py $< $@ \
|
||||
-I . -I $(GEN) --depsout $@.dd \
|
||||
--set-version $(VERSION) \
|
||||
--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)
|
||||
$< -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)
|
||||
./tools/importation.py $^ $@ \
|
||||
-I . -I $(GEN) --depsout $@.dd \
|
||||
--set-version $(VERSION) \
|
||||
--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)
|
||||
$< -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)
|
||||
./tools/importation.py $^ $@ \
|
||||
-I . -I $(GEN) --depsout $@.dd \
|
||||
--set-version $(VERSION) \
|
||||
--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)
|
||||
$< 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)
|
||||
./tools/importation.py $^ $@ \
|
||||
-I . -I $(GEN) --depsout $@.dd \
|
||||
--set-version $(VERSION) \
|
||||
--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)
|
||||
$< boot $(VERSION) $(REVISION) $(GEN)/esp32_boot_merged.fs >$@
|
||||
@ -358,10 +353,9 @@ drop-optional:
|
||||
$(ESP32)/ESP32forth/%.h: $(ESP32)/ESP32forth/optional/%.h
|
||||
cp $< $@
|
||||
|
||||
-include $(GEN)/dump_web_opcodes.dd
|
||||
|
||||
$(GEN)/dump_web_opcodes: web/dump_web_opcodes.c | $(GEN)
|
||||
$(CXX) $(CFLAGS) $< -o $@ -MD -MF $@.dd
|
||||
-include $(GEN)/dump_web_opcodes.dd
|
||||
|
||||
$(GEN)/web_cases.js: $(GEN)/dump_web_opcodes | $(GEN)
|
||||
$< cases >$@
|
||||
@ -372,13 +366,12 @@ $(GEN)/web_dict.js: $(GEN)/dump_web_opcodes | $(GEN)
|
||||
$(GEN)/web_sys.js: $(GEN)/dump_web_opcodes | $(GEN)
|
||||
$< sys >$@
|
||||
|
||||
-include $(GEN)/web_boot_merged.fs.dd
|
||||
|
||||
$(GEN)/web_boot_merged.fs: web/web_boot.fs | $(GEN)
|
||||
./tools/importation.py $^ $@ \
|
||||
-I . -I $(GEN) --depsout $@.dd \
|
||||
--set-version $(VERSION) \
|
||||
--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)
|
||||
$< -web boot $(VERSION) $(REVISION) $(GEN)/web_boot_merged.fs >$@
|
||||
@ -460,12 +453,11 @@ posix_target: $(POSIX)/ueforth
|
||||
$(POSIX):
|
||||
mkdir -p $@
|
||||
|
||||
-include $(GEN)/ueforth_posix.dd
|
||||
|
||||
$(POSIX)/ueforth: \
|
||||
posix/main.c $(GEN)/posix_boot.h | $(POSIX)
|
||||
$(CXX) $(CFLAGS) $< -o $@ $(LIBS) -MD -MF $(GEN)/ueforth_posix.dd
|
||||
strip $(STRIP_ARGS) $@
|
||||
-include $(GEN)/ueforth_posix.dd
|
||||
|
||||
# ---- WINDOWS ----
|
||||
|
||||
@ -477,28 +469,26 @@ win64_target: $(WINDOWS)/uEf64.exe
|
||||
$(WINDOWS):
|
||||
mkdir -p $@
|
||||
|
||||
-include $(WINDOWS)/uEf32.obj.dd
|
||||
|
||||
$(WINDOWS)/uEf32.obj: \
|
||||
windows/main.c \
|
||||
$(GEN)/windows_boot_extra.h \
|
||||
$(GEN)/windows_boot.h | $(WINDOWS)
|
||||
./tools/importation.py $< $@ --no-out -I . -I $(GEN) --depsout $@.dd
|
||||
$(CL32) /c /Fo$@ $(WIN_CFLAGS) $<
|
||||
-include $(WINDOWS)/uEf32.obj.dd
|
||||
|
||||
$(WINDOWS)/uEf32.exe: \
|
||||
$(WINDOWS)/uEf32.obj \
|
||||
$(RES)/ueforth_res32.res | $(WINDOWS)
|
||||
$(LINK32) /OUT:$@ $(WIN_LFLAGS32) $^
|
||||
|
||||
-include $(WINDOWS)/uEf64.obj.dd
|
||||
|
||||
$(WINDOWS)/uEf64.obj: \
|
||||
windows/main.c \
|
||||
$(GEN)/windows_boot_extra.h \
|
||||
$(GEN)/windows_boot.h | $(WINDOWS)
|
||||
./tools/importation.py $< $@ --no-out -I . -I $(GEN) --depsout $@.dd
|
||||
$(CL64) /c /Fo$@ $(WIN_CFLAGS) $<
|
||||
-include $(WINDOWS)/uEf64.obj.dd
|
||||
|
||||
$(WINDOWS)/uEf64.exe: \
|
||||
$(WINDOWS)/uEf64.obj \
|
||||
@ -513,22 +503,20 @@ esp32_sim_target: $(ESP32_SIM)/Esp32forth-sim
|
||||
$(ESP32_SIM):
|
||||
mkdir -p $@
|
||||
|
||||
-include $(GEN)/print-esp32-builtins.dd
|
||||
|
||||
$(GEN)/print-esp32-builtins: esp32/print-builtins.cpp | $(GEN)
|
||||
$(CXX) $(CFLAGS) $< -o $@ -MD -MF $@.dd
|
||||
-include $(GEN)/print-esp32-builtins.dd
|
||||
|
||||
$(GEN)/esp32_sim_opcodes.h: $(GEN)/print-esp32-builtins | $(GEN)
|
||||
$< >$@
|
||||
|
||||
-include $(GEN)/esp32_sim.dd
|
||||
|
||||
$(ESP32_SIM)/Esp32forth-sim: \
|
||||
esp32/sim_main.cpp \
|
||||
$(GEN)/esp32_boot.h \
|
||||
$(GEN)/esp32_sim_opcodes.h | $(ESP32_SIM)
|
||||
$(CXX) $(CFLAGS) $< -o $@ -MD -MF $(GEN)/esp32_sim.dd
|
||||
strip $(STRIP_ARGS) $@
|
||||
-include $(GEN)/esp32_sim.dd
|
||||
|
||||
# ---- ESP32 ----
|
||||
|
||||
@ -541,46 +529,15 @@ $(ESP32)/ESP32forth:
|
||||
$(ESP32)/ESP32forth/optional:
|
||||
mkdir -p $@
|
||||
|
||||
ESP32_PARTS = tools/replace.js \
|
||||
esp32/ESP32forth.ino \
|
||||
common/tier0_opcodes.h \
|
||||
common/tier1_opcodes.h \
|
||||
common/tier2_opcodes.h \
|
||||
common/floats.h \
|
||||
common/calls.h \
|
||||
common/calling.h \
|
||||
common/bits.h \
|
||||
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/ESP32forth.ino: \
|
||||
esp32/ESP32forth.ino \
|
||||
$(GEN)/esp32_boot.h | $(ESP32)/ESP32forth
|
||||
./tools/importation.py $< $@ \
|
||||
--keep-first-comment \
|
||||
-I . -I $(GEN) --depsout $(GEN)/esp32.dd \
|
||||
--set-version $(VERSION) \
|
||||
--set-revision $(REVISION)
|
||||
-include $(GEN)/esp32.dd
|
||||
|
||||
$(ESP32)/ESP32forth/README.txt: esp32/README.txt | $(ESP32)/ESP32forth
|
||||
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
|
||||
cp $< $@
|
||||
|
||||
.FORCE:
|
||||
$(PICO_ICE)/ueforth_pico_ice.uf2: \
|
||||
$(PICO_ICE)/build.ninja \
|
||||
pico-ice/main.c \
|
||||
pico-ice/builtins.h \
|
||||
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
|
||||
.FORCE \
|
||||
$(GEN)/pico_ice_boot.h \
|
||||
$(PICO_ICE)/build.ninja
|
||||
ninja -C $(PICO_ICE) ueforth_pico_ice
|
||||
|
||||
$(PICO_ICE)/build.ninja: \
|
||||
@ -788,11 +735,10 @@ pico_ice_sim_target: $(PICO_ICE_SIM)/ueforth_pico_ice_sim
|
||||
$(PICO_ICE_SIM):
|
||||
mkdir -p $@
|
||||
|
||||
-include $(GEN)/pico_ice_sim.dd
|
||||
|
||||
$(PICO_ICE_SIM)/ueforth_pico_ice_sim: \
|
||||
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
|
||||
-include $(GEN)/pico_ice_sim.dd
|
||||
|
||||
# ---- PACKAGE ESP32 ----
|
||||
|
||||
|
||||
@ -19,14 +19,14 @@
|
||||
* Revision: {{REVISION}}
|
||||
*/
|
||||
|
||||
{{platform}}
|
||||
{{options}}
|
||||
{{tier0_opcodes}}
|
||||
{{tier1_opcodes}}
|
||||
{{tier2_opcodes}}
|
||||
{{floats}}
|
||||
{{calls}}
|
||||
{{bits}}
|
||||
{{builtins.h}}
|
||||
{{builtins.cpp}}
|
||||
{{main.cpp}}
|
||||
#include "esp32/platform.h"
|
||||
#include "esp32/options.h"
|
||||
#include "common/tier0_opcodes.h"
|
||||
#include "common/tier1_opcodes.h"
|
||||
#include "common/tier2_opcodes.h"
|
||||
#include "common/floats.h"
|
||||
#include "common/calls.h"
|
||||
#include "common/bits.h"
|
||||
#include "esp32/builtins.h"
|
||||
#include "esp32/builtins.cpp"
|
||||
#include "esp32/main.cpp"
|
||||
|
||||
@ -15,11 +15,11 @@
|
||||
static char filename[PATH_MAX];
|
||||
static char filename2[PATH_MAX];
|
||||
|
||||
{{core}}
|
||||
{{faults}}
|
||||
{{calling}}
|
||||
{{interp}}
|
||||
{{boot}}
|
||||
#include "common/core.h"
|
||||
#include "esp32/faults.h"
|
||||
#include "common/calling.h"
|
||||
#include "common/interp.h"
|
||||
#include "esp32_boot.h"
|
||||
|
||||
// Work around lack of ftruncate
|
||||
static cell_t ResizeFile(cell_t fd, cell_t size) {
|
||||
|
||||
@ -14,6 +14,7 @@ parser.add_argument('--set-version')
|
||||
parser.add_argument('--set-revision')
|
||||
parser.add_argument('--depsout')
|
||||
parser.add_argument('--no-out', action='store_true')
|
||||
parser.add_argument('--keep-first-comment', action='store_true')
|
||||
args = parser.parse_args()
|
||||
bases = args.I or []
|
||||
|
||||
@ -33,6 +34,7 @@ def Import(filename):
|
||||
sfilename = os.path.join(os.path.dirname(filename), sfilename)
|
||||
Import(sfilename)
|
||||
elif (filename.endswith('.h') or
|
||||
filename.endswith('.ino') or
|
||||
filename.endswith('.cc') or
|
||||
filename.endswith('.c')) and line.startswith('#include "'):
|
||||
sfilename = line.split('"')[1]
|
||||
@ -50,17 +52,41 @@ def Import(filename):
|
||||
|
||||
def Process():
|
||||
Import(args.input)
|
||||
# Conversion version tags.
|
||||
output = []
|
||||
for line in results:
|
||||
if args.set_version:
|
||||
line = line.replace('{{VERSION}}', args.set_version)
|
||||
if 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:
|
||||
with open(args.depsout, 'w') as fh:
|
||||
fh.write(args.output + ': ' +
|
||||
' '.join([os.path.relpath(i) for i in imported]) + '\n')
|
||||
# Emit expanded file.
|
||||
if not args.no_out:
|
||||
with open(args.output, 'w') as fh:
|
||||
fh.write('\n'.join(results) + '\n')
|
||||
fh.write('\n'.join(output) + '\n')
|
||||
|
||||
Process()
|
||||
|
||||
Reference in New Issue
Block a user