Switching more into importation.
This commit is contained in:
162
Makefile
162
Makefile
@ -239,107 +239,96 @@ sanity_test_web: $(WEB)/ueforth.js
|
|||||||
$(GEN):
|
$(GEN):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
$(GEN)/posix_boot_merged.fs: posix/posix_boot.fs | $(GEN)
|
$(GEN)/posix_boot.h: posix/posix_boot.fs | $(GEN)
|
||||||
./tools/importation.py $< $@ \
|
./tools/importation.py $< $@ \
|
||||||
-I . -I $(GEN) --depsout $@.dd \
|
-I . -I $(GEN) --name boot --header cpp --depsout $@.dd \
|
||||||
--set-version $(VERSION) \
|
--set-version $(VERSION) \
|
||||||
--set-revision $(REVISION)
|
--set-revision $(REVISION)
|
||||||
-include $(GEN)/posix_boot_merged.fs.dd
|
-include $(GEN)/posix_boot.h.dd
|
||||||
|
|
||||||
$(GEN)/posix_boot.h: tools/source_to_string.js $(GEN)/posix_boot_merged.fs | $(GEN)
|
$(GEN)/windows_boot_extra.h: windows/windows_boot_extra.fs | $(GEN)
|
||||||
$< boot $(VERSION) $(REVISION) $(GEN)/posix_boot_merged.fs >$@
|
|
||||||
|
|
||||||
$(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) --name boot_extra --header win --depsout $@.dd \
|
||||||
--set-version $(VERSION) \
|
--set-version $(VERSION) \
|
||||||
--set-revision $(REVISION)
|
--set-revision $(REVISION)
|
||||||
-include $(GEN)/windows_boot_extra_merged.fs.dd
|
-include $(GEN)/windows_boot_extra.h.dd
|
||||||
|
|
||||||
$(GEN)/windows_boot_extra.h: tools/source_to_string.js $(GEN)/windows_boot_extra_merged.fs | $(GEN)
|
$(GEN)/windows_boot.h: windows/windows_boot.fs | $(GEN)
|
||||||
$< -win boot_extra $(VERSION) $(REVISION) $(GEN)/windows_boot_extra_merged.fs >$@
|
|
||||||
|
|
||||||
$(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 >$@
|
|
||||||
|
|
||||||
$(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 >$@
|
|
||||||
|
|
||||||
$(GEN)/esp32_boot_merged.fs: esp32/esp32_boot.fs | $(GEN)
|
|
||||||
./tools/importation.py $< $@ \
|
./tools/importation.py $< $@ \
|
||||||
-I . -I $(GEN) --depsout $@.dd \
|
-I . -I $(GEN) --name boot --header win --depsout $@.dd \
|
||||||
--set-version $(VERSION) \
|
--set-version $(VERSION) \
|
||||||
--set-revision $(REVISION)
|
--set-revision $(REVISION)
|
||||||
-include $(GEN)/esp32_boot_merged.fs.dd
|
-include $(GEN)/windows_boot.h.dd
|
||||||
|
|
||||||
$(GEN)/esp32_boot.h: tools/source_to_string.js $(GEN)/esp32_boot_merged.fs | $(GEN)
|
$(GEN)/pico_ice_boot.h: pico-ice/pico_ice_boot.fs | $(GEN)
|
||||||
$< boot $(VERSION) $(REVISION) $(GEN)/esp32_boot_merged.fs >$@
|
./tools/importation.py $< $@ \
|
||||||
|
-I . -I $(GEN) --name boot --header cpp --depsout $@.dd \
|
||||||
|
--set-version $(VERSION) \
|
||||||
|
--set-revision $(REVISION)
|
||||||
|
-include $(GEN)/pico_ice_boot.h.dd
|
||||||
|
|
||||||
$(GEN)/esp32_assembler.h: \
|
$(GEN)/esp32_boot.h: esp32/esp32_boot.fs | $(GEN)
|
||||||
tools/source_to_string.js \
|
./tools/importation.py $< $@ \
|
||||||
common/assembler.fs | $(GEN)
|
-I . -I $(GEN) --name boot --header cpp --depsout $@.dd \
|
||||||
$< assembler_source $(VERSION) $(REVISION) \
|
--set-version $(VERSION) \
|
||||||
common/assembler.fs >$@
|
--set-revision $(REVISION)
|
||||||
|
-include $(GEN)/esp32_boot.h.dd
|
||||||
|
|
||||||
$(GEN)/esp32_xtensa-assembler.h: \
|
$(GEN)/esp32_assembler.h: common/assembler.fs | $(GEN)
|
||||||
tools/source_to_string.js \
|
./tools/importation.py $< $@ \
|
||||||
esp32/optional/assemblers/xtensa-assembler.fs | $(GEN)
|
-I . -I $(GEN) --name assembler_source --header cpp --depsout $@.dd \
|
||||||
$< xtensa_assembler_source $(VERSION) $(REVISION) \
|
--set-version $(VERSION) \
|
||||||
esp32/optional/assemblers/xtensa-assembler.fs >$@
|
--set-revision $(REVISION)
|
||||||
|
-include $(GEN)/esp32_assembler.h.dd
|
||||||
|
|
||||||
$(GEN)/esp32_riscv-assembler.h: \
|
$(GEN)/esp32_xtensa-assembler.h: esp32/optional/assemblers/xtensa-assembler.fs | $(GEN)
|
||||||
tools/source_to_string.js \
|
./tools/importation.py $< $@ \
|
||||||
esp32/optional/assemblers/riscv-assembler.fs | $(GEN)
|
-I . -I $(GEN) --name xtensa_assembler_source --header cpp --depsout $@.dd \
|
||||||
$< riscv_assembler_source $(VERSION) $(REVISION) \
|
--set-version $(VERSION) \
|
||||||
esp32/optional/assemblers/riscv-assembler.fs >$@
|
--set-revision $(REVISION)
|
||||||
|
-include $(GEN)/esp32_xtensa-assembler.h.dd
|
||||||
|
|
||||||
$(GEN)/esp32_camera.h: \
|
$(GEN)/esp32_riscv-assembler.h: esp32/optional/assemblers/riscv-assembler.fs | $(GEN)
|
||||||
tools/source_to_string.js \
|
./tools/importation.py $< $@ \
|
||||||
esp32/optional/camera/camera_server.fs \
|
-I . -I $(GEN) --name riscv_assembler_source --header cpp --depsout $@.dd \
|
||||||
esp32/optional/camera/camera.fs | $(GEN)
|
--set-version $(VERSION) \
|
||||||
$< camera_source $(VERSION) $(REVISION) \
|
--set-revision $(REVISION)
|
||||||
esp32/optional/camera/camera.fs \
|
-include $(GEN)/esp32_riscv-assembler.h.dd
|
||||||
esp32/optional/camera/camera_server.fs >$@
|
|
||||||
|
|
||||||
$(GEN)/esp32_interrupts.h: \
|
$(GEN)/esp32_camera.h: esp32/optional/camera/camera_server.fs | $(GEN)
|
||||||
tools/source_to_string.js \
|
./tools/importation.py $< $@ \
|
||||||
esp32/optional/interrupts/interrupts.fs \
|
-I . -I $(GEN) --name camera_source --header cpp --depsout $@.dd \
|
||||||
esp32/optional/interrupts/timers.fs | $(GEN)
|
--set-version $(VERSION) \
|
||||||
$< interrupts_source $(VERSION) $(REVISION) \
|
--set-revision $(REVISION)
|
||||||
esp32/optional/interrupts/interrupts.fs \
|
-include $(GEN)/esp32_camera.h.dd
|
||||||
esp32/optional/interrupts/timers.fs >$@
|
|
||||||
|
|
||||||
$(GEN)/esp32_oled.h: \
|
$(GEN)/esp32_interrupts.h: esp32/optional/interrupts/timers.fs | $(GEN)
|
||||||
tools/source_to_string.js esp32/optional/oled/oled.fs | $(GEN)
|
./tools/importation.py $< $@ \
|
||||||
$< oled_source $(VERSION) $(REVISION) \
|
-I . -I $(GEN) --name interrupts_source --header cpp --depsout $@.dd \
|
||||||
esp32/optional/oled/oled.fs >$@
|
--set-version $(VERSION) \
|
||||||
|
--set-revision $(REVISION)
|
||||||
|
-include $(GEN)/esp32_interrupts.h.dd
|
||||||
|
|
||||||
$(GEN)/esp32_spi-flash.h: \
|
$(GEN)/esp32_oled.h: esp32/optional/oled/oled.fs | $(GEN)
|
||||||
tools/source_to_string.js esp32/optional/spi-flash/spi-flash.fs | $(GEN)
|
./tools/importation.py $< $@ \
|
||||||
$< spi_flash_source $(VERSION) $(REVISION) \
|
-I . -I $(GEN) --name oled_source --header cpp --depsout $@.dd \
|
||||||
esp32/optional/spi-flash/spi-flash.fs >$@
|
--set-version $(VERSION) \
|
||||||
|
--set-revision $(REVISION)
|
||||||
|
-include $(GEN)/esp32_oled.h.dd
|
||||||
|
|
||||||
$(GEN)/esp32_serial-bluetooth.h: \
|
$(GEN)/esp32_spi-flash.h: esp32/optional/spi-flash/spi-flash.fs | $(GEN)
|
||||||
tools/source_to_string.js \
|
./tools/importation.py $< $@ \
|
||||||
esp32/optional/serial-bluetooth/bterm.fs \
|
-I . -I $(GEN) --name spi_flash_source --header cpp --depsout $@.dd \
|
||||||
esp32/optional/serial-bluetooth/serial-bluetooth.fs | $(GEN)
|
--set-version $(VERSION) \
|
||||||
$< serial_bluetooth_source $(VERSION) $(REVISION) \
|
--set-revision $(REVISION)
|
||||||
esp32/optional/serial-bluetooth/serial-bluetooth.fs \
|
-include $(GEN)/esp32_spi-flash.h.dd
|
||||||
esp32/optional/serial-bluetooth/bterm.fs >$@
|
|
||||||
|
$(GEN)/esp32_serial-bluetooth.h: esp32/optional/serial-bluetooth/serial-bluetooth.fs | $(GEN)
|
||||||
|
./tools/importation.py $< $@ \
|
||||||
|
-I . -I $(GEN) --name serial_blueooth_source --header cpp --depsout $@.dd \
|
||||||
|
--set-version $(VERSION) \
|
||||||
|
--set-revision $(REVISION)
|
||||||
|
-include $(GEN)/esp32_serial-bluetooth.h.dd
|
||||||
|
|
||||||
OPTIONAL_MODULES = \
|
OPTIONAL_MODULES = \
|
||||||
$(ESP32)/ESP32forth/assemblers.h \
|
$(ESP32)/ESP32forth/assemblers.h \
|
||||||
@ -371,15 +360,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 >$@
|
||||||
|
|
||||||
$(GEN)/web_boot_merged.fs: web/web_boot.fs | $(GEN)
|
$(GEN)/web_boot.js: web/web_boot.fs | $(GEN)
|
||||||
./tools/importation.py $^ $@ \
|
./tools/importation.py $< $@ \
|
||||||
-I . -I $(GEN) --depsout $@.dd \
|
-I . -I $(GEN) --name boot --header web --depsout $@.dd \
|
||||||
--set-version $(VERSION) \
|
--set-version $(VERSION) \
|
||||||
--set-revision $(REVISION)
|
--set-revision $(REVISION)
|
||||||
-include $(GEN)/web_boot_merged.fs.dd
|
-include $(GEN)/web_boot.js.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 >$@
|
|
||||||
|
|
||||||
# ---- RESOURCES ----
|
# ---- RESOURCES ----
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,8 @@
|
|||||||
\ See the License for the specific language governing permissions and
|
\ See the License for the specific language governing permissions and
|
||||||
\ limitations under the License.
|
\ limitations under the License.
|
||||||
|
|
||||||
|
needs camera.fs
|
||||||
|
|
||||||
( Lazy loaded Camera Server )
|
( Lazy loaded Camera Server )
|
||||||
: camera-server r~
|
: camera-server r~
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,8 @@
|
|||||||
\ See the License for the specific language governing permissions and
|
\ See the License for the specific language governing permissions and
|
||||||
\ limitations under the License.
|
\ limitations under the License.
|
||||||
|
|
||||||
|
needs interrupts.fs
|
||||||
|
|
||||||
internals definitions
|
internals definitions
|
||||||
transfer timers-builtins
|
transfer timers-builtins
|
||||||
forth definitions
|
forth definitions
|
||||||
|
|||||||
@ -12,6 +12,8 @@
|
|||||||
\ See the License for the specific language governing permissions and
|
\ See the License for the specific language governing permissions and
|
||||||
\ limitations under the License.
|
\ limitations under the License.
|
||||||
|
|
||||||
|
needs bterm.fs
|
||||||
|
|
||||||
DEFINED? SerialBT.new [IF]
|
DEFINED? SerialBT.new [IF]
|
||||||
vocabulary bluetooth bluetooth definitions
|
vocabulary bluetooth bluetooth definitions
|
||||||
transfer bluetooth-builtins
|
transfer bluetooth-builtins
|
||||||
|
|||||||
@ -94,14 +94,10 @@ rule mkdir
|
|||||||
description = mkdir
|
description = mkdir
|
||||||
command = mkdir -p $out
|
command = mkdir -p $out
|
||||||
|
|
||||||
rule source_to_string
|
|
||||||
description = source_to_string
|
|
||||||
command = ../tools/source_to_string.js $name $version $revision $in >$out
|
|
||||||
|
|
||||||
rule importation
|
rule importation
|
||||||
description = import
|
description = importation
|
||||||
depfile = $out.dd
|
depfile = $out.dd
|
||||||
command = ../tools/importation.py $in $out -I . -I .. --depsout $out.dd --set-version $version --set-revision $revision
|
command = ../tools/importation.py $in $out -I . -I .. --name $name --header $header_mode --depsout $out.dd --set-version $version --set-revision $revision
|
||||||
|
|
||||||
build gen: mkdir
|
build gen: mkdir
|
||||||
|
|
||||||
@ -113,23 +109,20 @@ build gen: mkdir
|
|||||||
'libs': ' '.join(LIBS),
|
'libs': ' '.join(LIBS),
|
||||||
}
|
}
|
||||||
|
|
||||||
def ForthHeader(target, name, source):
|
def ForthHeader(target, name, source, header_mode='cpp'):
|
||||||
|
source = '../' + source
|
||||||
global output
|
global output
|
||||||
output += """
|
output += f"""
|
||||||
build %(target)s: source_to_string %(target)s.merged | gen
|
build {target}: importation {source} | gen
|
||||||
name = %(name)s
|
name = {name}
|
||||||
|
header_mode = {header_mode}
|
||||||
build %(target)s.merged: importation %(source)s | gen
|
"""
|
||||||
""" % {
|
|
||||||
'target': target,
|
|
||||||
'source': os.path.join('..', source),
|
|
||||||
'name': name,
|
|
||||||
}
|
|
||||||
|
|
||||||
ForthHeader('gen/posix_boot.h', 'boot', 'posix/posix_boot.fs')
|
ForthHeader('gen/posix_boot.h', 'boot', 'posix/posix_boot.fs')
|
||||||
ForthHeader('gen/window_boot.h', 'boot', 'windows/windows_boot.fs')
|
ForthHeader('gen/window_boot.h', 'boot', 'windows/windows_boot.fs', header_mode='win')
|
||||||
ForthHeader('gen/window_boot_extra.h', 'boot_extra', 'windows/windows_boot_extra.fs')
|
ForthHeader('gen/window_boot_extra.h', 'boot_extra', 'windows/windows_boot_extra.fs', header_mode='win')
|
||||||
ForthHeader('gen/pico_ice_boot.h', 'boot', 'pico-ice/pico_ice_boot.fs')
|
ForthHeader('gen/pico_ice_boot.h', 'boot', 'pico-ice/pico_ice_boot.fs')
|
||||||
ForthHeader('gen/esp32_boot.h', 'boot', 'esp32/esp32_boot.fs')
|
ForthHeader('gen/esp32_boot.h', 'boot', 'esp32/esp32_boot.fs')
|
||||||
|
ForthHeader('gen/web_boot.js', 'boot', 'esp32/esp32_boot.fs', header_mode='web')
|
||||||
|
|
||||||
print(output)
|
print(output)
|
||||||
|
|||||||
@ -15,6 +15,8 @@ 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')
|
parser.add_argument('--keep-first-comment', action='store_true')
|
||||||
|
parser.add_argument('--name')
|
||||||
|
parser.add_argument('--header')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
bases = args.I or []
|
bases = args.I or []
|
||||||
|
|
||||||
@ -88,6 +90,25 @@ def Process():
|
|||||||
# Emit expanded file.
|
# 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(output) + '\n')
|
if args.header == 'web':
|
||||||
|
fh.write('const ' + args.name + ' = `\n' +
|
||||||
|
'\n'.join(output) + '\n`;\n')
|
||||||
|
elif args.header == 'cpp':
|
||||||
|
fh.write('const char ' + args.name + '[] = R"""(\n' +
|
||||||
|
'\n'.join(output) + '\n)""";\n')
|
||||||
|
elif args.header == 'win':
|
||||||
|
fixed = []
|
||||||
|
for line in output:
|
||||||
|
line = line.replace('\\', '\\\\')
|
||||||
|
line = line.replace('"', '\\"')
|
||||||
|
line = '"' + line + '\\n"'
|
||||||
|
if line.startswith('"(') and line.endswith(')\\n"'):
|
||||||
|
line = '// ' + line
|
||||||
|
if line:
|
||||||
|
fixed.append(line)
|
||||||
|
fh.write('const char ' + args.name + '[] =\n' +
|
||||||
|
'\n'.join(fixed) + '\n;\n')
|
||||||
|
else:
|
||||||
|
fh.write('\n'.join(output) + '\n')
|
||||||
|
|
||||||
Process()
|
Process()
|
||||||
|
|||||||
@ -1,69 +0,0 @@
|
|||||||
#! /usr/bin/env nodejs
|
|
||||||
// Copyright 2021 Bradley D. Nelson
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
function DropCopyright(source) {
|
|
||||||
var lines = source.split('\n');
|
|
||||||
var cleaned = [];
|
|
||||||
for (var i = 0; i < lines.length; ++i) {
|
|
||||||
if (lines[i].search('Copyright') >= 0) {
|
|
||||||
while (lines[i] != '') {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cleaned.push(lines[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cleaned.join('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
var is_windows = false;
|
|
||||||
var is_web = false;
|
|
||||||
|
|
||||||
var args = process.argv.slice(2);
|
|
||||||
if (args.length > 0 && args[0] == '-win') {
|
|
||||||
is_windows = true;
|
|
||||||
args.shift();
|
|
||||||
}
|
|
||||||
if (args.length > 0 && args[0] == '-web') {
|
|
||||||
is_web = true;
|
|
||||||
args.shift();
|
|
||||||
}
|
|
||||||
var name = args.shift();
|
|
||||||
var version = args.shift();
|
|
||||||
var revision = args.shift();
|
|
||||||
var source = '';
|
|
||||||
while (args.length > 0) {
|
|
||||||
source += DropCopyright(fs.readFileSync(args.shift()).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
source = source.replace('{{VERSION}}', version);
|
|
||||||
source = source.replace('{{REVISION}}', revision);
|
|
||||||
|
|
||||||
if (is_windows) {
|
|
||||||
source = source.replace(/\\/g, '\\\\');
|
|
||||||
source = source.replace(/["]/g, '\\"');
|
|
||||||
source = '"' + source.split('\n').join('\\n"\n"') + '\\n"';
|
|
||||||
source = source.replace(/["] ["]/g, '');
|
|
||||||
source = source.replace(/["] [(] ([^)]*)[)] ["]/g, '// $1');
|
|
||||||
source = 'const char ' + name + '[] =\n' + source + ';\n';
|
|
||||||
} else if (is_web) {
|
|
||||||
source = 'const ' + name + ' = `\n' + source + '`;\n';
|
|
||||||
} else {
|
|
||||||
source = 'const char ' + name + '[] = R"""(\n' + source + ')""";\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
process.stdout.write(source);
|
|
||||||
Reference in New Issue
Block a user