From ca05d3b6b0b7cec99476af34d136fad52f1a07bc Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Fri, 22 Dec 2023 14:00:17 -0800 Subject: [PATCH] Switch to importation tool, regression. Regresses proper depedencies temporarily. --- Makefile | 85 ++++++++++++++++------------------- common/phase1.fs | 21 +++++++++ common/phase2.fs | 18 ++++++++ common/phase_desktop.fs | 18 ++++++++ common/phase_filetools.fs | 21 +++++++++ esp32/esp32_boot.fs | 28 ++++++++++++ pico-ice/pico_ice_boot.fs | 22 +++++++++ posix/posix_boot.fs | 29 ++++++++++++ tools/importation.py | 57 +++++++++++++++++++++++ tools/webindex.py | 2 +- windows/windows_boot.fs | 25 +++++++++++ windows/windows_boot_extra.fs | 18 ++++++++ 12 files changed, 296 insertions(+), 48 deletions(-) create mode 100644 common/phase1.fs create mode 100644 common/phase2.fs create mode 100644 common/phase_desktop.fs create mode 100644 common/phase_filetools.fs create mode 100644 esp32/esp32_boot.fs create mode 100644 pico-ice/pico_ice_boot.fs create mode 100644 posix/posix_boot.fs create mode 100755 tools/importation.py create mode 100644 windows/windows_boot.fs create mode 100644 windows/windows_boot_extra.fs diff --git a/Makefile b/Makefile index 503dba2..0bc0c62 100644 --- a/Makefile +++ b/Makefile @@ -261,57 +261,48 @@ COMMON_FILETOOLS = common/tasks.fs common/streams.fs \ COMMON_DESKTOP = common/desktop.fs \ common/graphics.fs common/graphics_utils.fs common/heart.fs -POSIX_BOOT = $(COMMON_PHASE1) \ - posix/posix.fs posix/allocation.fs posix/termios.fs \ - $(COMMON_PHASE2) $(COMMON_FILETOOLS) $(COMMON_DESKTOP) \ - posix/x11.fs \ - posix/graphics.fs \ - posix/sockets.fs posix/telnetd.fs posix/httpd.fs posix/web_interface.fs \ - posix/autoboot.fs \ - common/fini.fs -$(GEN)/posix_boot.h: tools/source_to_string.js $(POSIX_BOOT) | $(GEN) - $< boot $(VERSION) $(REVISION) $(POSIX_BOOT) >$@ +$(GEN)/posix_boot_merged.fs: tools/importation.py posix/posix_boot.fs | $(GEN) + $^ -I . -I $(GEN) \ + --set-version $(VERSION) \ + --set-revision $(REVISION) >$@ -WINDOWS_BOOT_EXTRA = windows/windows_user.fs \ - windows/windows_gdi.fs \ - windows/windows_messages.fs \ - windows/graphics.fs -$(GEN)/windows_boot_extra.h: tools/source_to_string.js $(WINDOWS_BOOT_EXTRA) | $(GEN) - $< -win boot_extra $(VERSION) $(REVISION) $(WINDOWS_BOOT_EXTRA) >$@ +$(GEN)/posix_boot.h: tools/source_to_string.js $(GEN)/posix_boot_merged.fs | $(GEN) + $< boot $(VERSION) $(REVISION) $(GEN)/posix_boot_merged.fs >$@ -WINDOWS_BOOT = $(COMMON_PHASE1) \ - windows/windows_core.fs \ - windows/windows_files.fs \ - windows/windows_console.fs \ - windows/allocation.fs \ - $(COMMON_PHASE2) $(COMMON_FILETOOLS) $(COMMON_DESKTOP) \ - windows/load_extra.fs \ - posix/autoboot.fs \ - common/fini.fs -$(GEN)/windows_boot.h: tools/source_to_string.js $(WINDOWS_BOOT) | $(GEN) - $< -win boot $(VERSION) $(REVISION) $(WINDOWS_BOOT) >$@ +$(GEN)/windows_boot_extra_merged.fs: \ + tools/importation.py windows/windows_boot_extra.fs | $(GEN) + $^ -I . -I $(GEN) \ + --set-version $(VERSION) \ + --set-revision $(REVISION) >$@ -PICO_ICE_BOOT = $(COMMON_PHASE1) \ - pico-ice/allocation.fs \ - $(COMMON_PHASE2) \ - common/tasks.fs common/streams.fs \ - pico-ice/platform.fs \ - pico-ice/autoboot.fs \ - common/fini.fs -$(GEN)/pico_ice_boot.h: tools/source_to_string.js $(PICO_ICE_BOOT) | $(GEN) - $< boot $(VERSION) $(REVISION) $(PICO_ICE_BOOT) >$@ +$(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 >$@ -ESP32_BOOT = $(COMMON_PHASE1) \ - esp32/allocation.fs esp32/bindings.fs \ - $(COMMON_PHASE2) $(COMMON_FILETOOLS) \ - esp32/platform.fs \ - posix/httpd.fs posix/web_interface.fs esp32/web_interface.fs \ - esp32/registers.fs \ - posix/telnetd.fs \ - esp32/optionals.fs \ - esp32/autoboot.fs common/fini.fs -$(GEN)/esp32_boot.h: tools/source_to_string.js $(ESP32_BOOT) | $(GEN) - $< boot $(VERSION) $(REVISION) $(ESP32_BOOT) >$@ +$(GEN)/windows_boot_merged.fs: tools/importation.py windows/windows_boot.fs | $(GEN) + $^ -I . -I $(GEN) \ + --set-version $(VERSION) \ + --set-revision $(REVISION) >$@ + +$(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: \ + tools/importation.py pico-ice/pico_ice_boot.fs | $(GEN) + $^ -I . -I $(GEN) \ + --set-version $(VERSION) \ + --set-revision $(REVISION) >$@ + +$(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: \ + tools/importation.py esp32/esp32_boot.fs | $(GEN) + $^ -I . -I $(GEN) \ + --set-version $(VERSION) \ + --set-revision $(REVISION) >$@ + +$(GEN)/esp32_boot.h: tools/source_to_string.js $(GEN)/esp32_boot_merged.fs | $(GEN) + $< boot $(VERSION) $(REVISION) $(GEN)/esp32_boot_merged.fs >$@ $(GEN)/esp32_assembler.h: \ tools/source_to_string.js \ diff --git a/common/phase1.fs b/common/phase1.fs new file mode 100644 index 0000000..528475b --- /dev/null +++ b/common/phase1.fs @@ -0,0 +1,21 @@ +\ Copyright 2023 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. + +needs comments.fs +needs boot.fs +needs io.fs +needs conditionals.fs +needs vocabulary.fs +needs floats.fs +needs structures.fs diff --git a/common/phase2.fs b/common/phase2.fs new file mode 100644 index 0000000..e59c77c --- /dev/null +++ b/common/phase2.fs @@ -0,0 +1,18 @@ +\ Copyright 2023 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. + +needs utils.fs +needs code.fs +needs locals.fs +needs case.fs diff --git a/common/phase_desktop.fs b/common/phase_desktop.fs new file mode 100644 index 0000000..136a404 --- /dev/null +++ b/common/phase_desktop.fs @@ -0,0 +1,18 @@ +\ Copyright 2023 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. + +needs desktop.fs +needs graphics.fs +needs graphics_utils.fs +needs heart.fs diff --git a/common/phase_filetools.fs b/common/phase_filetools.fs new file mode 100644 index 0000000..04e7eeb --- /dev/null +++ b/common/phase_filetools.fs @@ -0,0 +1,21 @@ +\ Copyright 2023 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. + +needs tasks.fs +needs streams.fs +needs filetools.fs +needs including.fs +needs blocks.fs +needs ansi.fs +needs visual.fs diff --git a/esp32/esp32_boot.fs b/esp32/esp32_boot.fs new file mode 100644 index 0000000..8b9ce1b --- /dev/null +++ b/esp32/esp32_boot.fs @@ -0,0 +1,28 @@ +\ Copyright 2023 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. + +needs ../common/phase1.fs +needs allocation.fs +needs bindings.fs +needs ../common/phase2.fs +needs ../common/phase_filetools.fs +needs platform.fs +needs ../posix/httpd.fs +needs ../posix/web_interface.fs +needs web_interface.fs +needs registers.fs +needs ../posix/telnetd.fs +needs optionals.fs +needs autoboot.fs +needs ../common/fini.fs diff --git a/pico-ice/pico_ice_boot.fs b/pico-ice/pico_ice_boot.fs new file mode 100644 index 0000000..b2686b1 --- /dev/null +++ b/pico-ice/pico_ice_boot.fs @@ -0,0 +1,22 @@ +\ Copyright 2023 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. + +needs ../common/phase1.fs +needs allocation.fs +needs ../common/phase2.fs +needs ../common/tasks.fs +needs ../common/streams.fs +needs platform.fs +needs autoboot.fs +needs ../common/fini.fs diff --git a/posix/posix_boot.fs b/posix/posix_boot.fs new file mode 100644 index 0000000..502e2da --- /dev/null +++ b/posix/posix_boot.fs @@ -0,0 +1,29 @@ +\ Copyright 2023 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. + +needs ../common/phase1.fs +needs posix.fs +needs allocation.fs +needs termios.fs +needs ../common/phase2.fs +needs ../common/phase_filetools.fs +needs ../common/phase_desktop.fs +needs x11.fs +needs graphics.fs +needs sockets.fs +needs telnetd.fs +needs httpd.fs +needs web_interface.fs +needs autoboot.fs +needs ../common/fini.fs diff --git a/tools/importation.py b/tools/importation.py new file mode 100755 index 0000000..467ff06 --- /dev/null +++ b/tools/importation.py @@ -0,0 +1,57 @@ +#! /usr/bin/env python3 + +import argparse +import os +import sys + +parser = argparse.ArgumentParser( + prog='importation', + description='Imports header / fs files') +parser.add_argument('filename') +parser.add_argument('-I', action='append') +parser.add_argument('--set-version') +parser.add_argument('--set-revision') +args = parser.parse_args() +bases = args.I or [] + +results = [] +imported = set() + +def Import(filename): + filename = os.path.abspath(filename) + if filename in imported: + return + imported.add(filename) + with open(filename, 'r') as fh: + data = fh.read().splitlines() + for line in data: + if filename.endswith('.fs') and line.startswith('needs '): + sfilename = line.split(' ')[1] + sfilename = os.path.join(os.path.dirname(filename), sfilename) + Import(sfilename) + elif (filename.endswith('.h') or + filename.endswith('.cc') or + filename.endswith('.c')) and line.startswith('#include "'): + sfilename = line.split('"')[1] + done = False + for base in bases: + sfilename = os.path.join(base, sfilename) + if os.path.exists(sfilename): + Import(sfilename) + done = True + break + if not done: + results.append(line) + else: + results.append(line) + +def Process(): + Import(args.filename) + 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) + print('\n'.join(results)) + +Process() diff --git a/tools/webindex.py b/tools/webindex.py index 09de2cb..e534aeb 100755 --- a/tools/webindex.py +++ b/tools/webindex.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Copyright 2021 Bradley D. Nelson # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/windows/windows_boot.fs b/windows/windows_boot.fs new file mode 100644 index 0000000..3c5ee5f --- /dev/null +++ b/windows/windows_boot.fs @@ -0,0 +1,25 @@ +\ Copyright 2023 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. + +needs ../common/phase1.fs +needs windows_core.fs \ +needs windows_files.fs \ +needs windows_console.fs \ +needs allocation.fs \ +needs ../common/phase2.fs +needs ../common/phase_filetools.fs +needs ../common/phase_desktop.fs +needs load_extra.fs \ +needs ../posix/autoboot.fs \ +needs ../common/fini.fs diff --git a/windows/windows_boot_extra.fs b/windows/windows_boot_extra.fs new file mode 100644 index 0000000..cf0dfaa --- /dev/null +++ b/windows/windows_boot_extra.fs @@ -0,0 +1,18 @@ +\ Copyright 2023 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. + +needs windows_user.fs +needs windows_gdi.fs +needs windows_messages.fs +needs graphics.fs