From a69961d90d7419a684794a103b26e857da2585c5 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Mon, 1 Jan 2024 15:50:27 -0800 Subject: [PATCH] Reroot. --- Makefile | 2 +- build.ninja | 2 ++ esp32/BUILD | 20 +++++++++---------- pico-ice/BUILD | 17 ++++++++-------- posix/BUILD | 13 +++++++------ site/BUILD | 26 ++++++++++++------------- tools/configure.py | 15 ++++++++------- web/BUILD | 28 +++++++++++++-------------- windows/BUILD | 48 ++++++++++++++++++++++++++-------------------- 9 files changed, 91 insertions(+), 80 deletions(-) create mode 100644 build.ninja diff --git a/Makefile b/Makefile index d326c7d..ab03a3c 100644 --- a/Makefile +++ b/Makefile @@ -169,7 +169,7 @@ tests: $(TESTS) n: mkdir -p out tools/configure.py >out/build.ninja - ninja -C out/ + ninja clean-esp32: rm -rf $(ESP32)/esp32*_build $(ESP32)/esp32*_cache diff --git a/build.ninja b/build.ninja new file mode 100644 index 0000000..dd65e91 --- /dev/null +++ b/build.ninja @@ -0,0 +1,2 @@ +builddir = out +include out/build.ninja diff --git a/esp32/BUILD b/esp32/BUILD index fa6f6c4..5253b43 100644 --- a/esp32/BUILD +++ b/esp32/BUILD @@ -17,17 +17,17 @@ ESP32_ZIP_FILES = [] # Main .ino file. ESP32_ZIP_FILES += [ - Importation('esp32/ESP32forth/README.txt', + Importation('$dst/esp32/ESP32forth/README.txt', '$src/esp32/README.txt'), - Importation('esp32/ESP32forth/ESP32forth.ino', + Importation('$dst/esp32/ESP32forth/ESP32forth.ino', '$src/esp32/ESP32forth.ino', - implicit=['gen/esp32_boot.h'], keep=True), + implicit=['$dst/gen/esp32_boot.h'], keep=True), ] -Importation('gen/esp32_boot.h', '$src/esp32/esp32_boot.fs', name='boot') +Importation('$dst/gen/esp32_boot.h', '$src/esp32/esp32_boot.fs', name='boot') # Optional Compontents. ESP32_ZIP_FILES += [ - Importation('esp32/ESP32forth/optional/README-optional.txt', + Importation('$dst/esp32/ESP32forth/optional/README-optional.txt', '$src/esp32/optional/README-optional.txt'), Esp32Optional('rmt', '$src/esp32/optional/rmt.h', []), Esp32Optional('assemblers', '$src/esp32/optional/assemblers/assemblers.h', @@ -48,16 +48,16 @@ ESP32_ZIP_FILES += [ # Zip it. ESP32_FILES += [ - Zip('esp32/ESP32forth.zip', ESP32_ZIP_FILES, base='esp32/ESP32forth'), + Zip('$dst/esp32/ESP32forth.zip', ESP32_ZIP_FILES, base='$dst/esp32/ESP32forth'), ] # Simulator. ESP32_FILES += [ - Compile('esp32-sim/esp32-sim', '$src/esp32/sim_main.cpp', - implicit=['gen/esp32_boot.h', 'gen/esp32_sim_opcodes.h']) + Compile('$dst/esp32-sim/esp32-sim', '$src/esp32/sim_main.cpp', + implicit=['$dst/gen/esp32_boot.h', '$dst/gen/esp32_sim_opcodes.h']) ] -Compile('gen/print-esp32-builtins', '$src/esp32/print-builtins.cpp'), -Run('gen/esp32_sim_opcodes.h', 'gen/print-esp32-builtins') +Compile('$dst/gen/print-esp32-builtins', '$src/esp32/print-builtins.cpp'), +Run('$dst/gen/esp32_sim_opcodes.h', '$dst/gen/print-esp32-builtins') # Main Alias. Alias('esp32', ' '.join(ESP32_FILES)) diff --git a/pico-ice/BUILD b/pico-ice/BUILD index 1ff8b60..6765c66 100644 --- a/pico-ice/BUILD +++ b/pico-ice/BUILD @@ -17,27 +17,28 @@ PICO_ICE_ZIP_FILES = [] # Main .ino file. PICO_ICE_ZIP_FILES += [ - Importation('pico-ice/ueforth-pico-ice/README.txt', + Importation('$dst/pico-ice/ueforth-pico-ice/README.txt', '$src/pico-ice/README.txt'), # TODO: .uf2 - Copy('pico-ice/ueforth-pice-ice/LICENSE', '$src/LICENSE'), - Copy('pico-ice/ueforth-pice-ice/pico-ice-sdk-LICENSE.md', + Copy('$dst/pico-ice/ueforth-pice-ice/LICENSE', '$src/LICENSE'), + Copy('$dst/pico-ice/ueforth-pice-ice/pico-ice-sdk-LICENSE.md', '$src/pico-ice/pico-ice-sdk/LICENSE.md'), - Copy('pico-ice/ueforth-pice-ice/pico-sdk-LICENSE.TXT', + Copy('$dst/pico-ice/ueforth-pice-ice/pico-sdk-LICENSE.TXT', '$src/pico-ice/pico-sdk/LICENSE.TXT'), ] # Zip it. PICO_ICE_FILES += [ - Zip('pico-ice/ueforth-pico-ice.zip', PICO_ICE_ZIP_FILES, base='pico-ice/ueforth-pico-ice'), + Zip('$dst/pico-ice/ueforth-pico-ice.zip', PICO_ICE_ZIP_FILES, + base='$dst/pico-ice/ueforth-pico-ice'), ] # Simulator. PICO_ICE_FILES += [ - CompileSim('pico-ice-sim/ueforth_pico_ice_sim', '$src/pico-ice/main.c', - implicit=['gen/pico_ice_boot.h']) + CompileSim('$dst/pico-ice-sim/ueforth_pico_ice_sim', '$src/pico-ice/main.c', + implicit=['$dst/gen/pico_ice_boot.h']) ] -Importation('gen/pico_ice_boot.h', '$src/pico-ice/pico_ice_boot.fs', name='boot') +Importation('$dst/gen/pico_ice_boot.h', '$src/pico-ice/pico_ice_boot.fs', name='boot') # Main Alias. Alias('pico', ' '.join(PICO_ICE_FILES)) diff --git a/posix/BUILD b/posix/BUILD index 69ee1bf..5130d66 100644 --- a/posix/BUILD +++ b/posix/BUILD @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -Importation('gen/posix_boot.h', '$src/posix/posix_boot.fs', name='boot') -Compile('posix/ueforth', '$src/posix/main.c', - implicit=['gen/posix_boot.h']) +Importation('$dst/gen/posix_boot.h', '$src/posix/posix_boot.fs', name='boot') +Compile('$dst/posix/ueforth', '$src/posix/main.c', + implicit=['$dst/gen/posix_boot.h']) Alias('posix', ' '.join([ - ForthTest('tests/posix_all_tests.out', 'posix/ueforth', '$src/common/all_tests.fs'), + ForthTest('$dst/tests/posix_all_tests.out', + '$dst/posix/ueforth', '$src/common/all_tests.fs'), ])) -OneShot('install', 'sudo cp posix/ueforth /usr/bin/ueforth', - 'posix/ueforth', pool='console') +OneShot('install', 'sudo cp $dst/posix/ueforth /usr/bin/ueforth', + '$dst/posix/ueforth', pool='console') diff --git a/site/BUILD b/site/BUILD index df56603..f12e519 100644 --- a/site/BUILD +++ b/site/BUILD @@ -26,22 +26,22 @@ ESP_REPLACE = REPLACE + ['-DFORTH=ESP32forth'] DEPLOY_ITEMS = [] DEPLOY_ITEMS += [ - Copy('deploy/.gcloudignore', '$src/site/.gcloudignore'), - Copy('deploy/ueforth.js', 'web/ueforth.js'), - Importation('deploy/index.html', '$src/site/index.html'), - Importation('deploy/linux.html', '$src/site/linux.html'), - Importation('deploy/windows.html', '$src/site/windows.html'), - Importation('deploy/web.html', '$src/site/web.html'), - Importation('deploy/ESP32forth.html', '$src/site/ESP32forth.html'), - Importation('deploy/pico-ice.html', '$src/site/pico-ice.html'), - Importation('deploy/internals.html', '$src/site/internals.html'), - Importation('deploy/classic.html', '$src/site/classic.html'), - Copy('deploy/eforth.go', '$src/site/eforth.go'), - Copy('deploy/app.yaml', '$src/site/app.yaml'), + Copy('$dst/deploy/.gcloudignore', '$src/site/.gcloudignore'), + Copy('$dst/deploy/ueforth.js', '$dst/web/ueforth.js'), + Importation('$dst/deploy/index.html', '$src/site/index.html'), + Importation('$dst/deploy/linux.html', '$src/site/linux.html'), + Importation('$dst/deploy/windows.html', '$src/site/windows.html'), + Importation('$dst/deploy/web.html', '$src/site/web.html'), + Importation('$dst/deploy/ESP32forth.html', '$src/site/ESP32forth.html'), + Importation('$dst/deploy/pico-ice.html', '$src/site/pico-ice.html'), + Importation('$dst/deploy/internals.html', '$src/site/internals.html'), + Importation('$dst/deploy/classic.html', '$src/site/classic.html'), + Copy('$dst/deploy/eforth.go', '$src/site/eforth.go'), + Copy('$dst/deploy/app.yaml', '$src/site/app.yaml'), ] DEPLOY_ITEMS += [ - Copy('deploy/static/' + i, '$src/site/static/' + i) for i in [ + Copy('$dst/deploy/static/' + i, '$src/site/static/' + i) for i in [ 'eforth.css', 'robots.txt', 'esp32-c3-wroom-02.jpg', diff --git a/tools/configure.py b/tools/configure.py index 5a8d6a6..351b5b7 100755 --- a/tools/configure.py +++ b/tools/configure.py @@ -30,8 +30,8 @@ REVISION = 'TODO' CFLAGS_COMMON = [ '-O2', - '-I', '$src/', - '-I', './', + '-I', '$src', + '-I', '$dst', ] CFLAGS_MINIMIZE = [ @@ -128,7 +128,8 @@ NODEJS = LSQ('/usr/bin/nodejs') output = f""" ninja_required_version = 1.1 -src = .. +src = . +dst = out VERSION = {VERSION} REVISION = {REVISION} CFLAGS = {' '.join(CFLAGS)} @@ -154,7 +155,7 @@ rule importation description = importation depfile = $out.d deps = gcc - command = $src/tools/importation.py -i $in -o $out -I . -I $src $options --depsout $depfile -DVERSION=$VERSION -DREVISION=$REVERSION + command = $src/tools/importation.py -i $in -o $out -I $dst -I $src $options --depsout $depfile -DVERSION=$VERSION -DREVISION=$REVERSION rule compile description = CXX @@ -256,12 +257,12 @@ def Importation(target, source, header_mode='cpp', name=None, keep=False, deps=N def Esp32Optional(main_name, main_source, parts): parts = [] for name, source in parts: - parts.append(Importation('gen/esp32_' + name + '.h', + parts.append(Importation('$dst/gen/esp32_' + name + '.h', source, name=name.replace('-', '_') + '_source')) - return Importation('esp32/ESP32forth/optional/' + main_name + '.h', + return Importation('$dst/esp32/ESP32forth/optional/' + main_name + '.h', main_source, keep=True, - deps='gen/esp32_optional_' + main_name + '.h.d', + deps='$dst/gen/esp32_optional_' + main_name + '.h.d', implicit=parts) diff --git a/web/BUILD b/web/BUILD index 67b4b8a..013624f 100644 --- a/web/BUILD +++ b/web/BUILD @@ -12,24 +12,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -Importation('gen/web_boot.js', '$src/web/web_boot.fs', header_mode='web', name='boot') -Compile('gen/dump_web_opcodes', '$src/web/dump_web_opcodes.c') -GenRun('gen/web_cases.js', 'gen/dump_web_opcodes', 'cases', []) -GenRun('gen/web_dict.js', 'gen/dump_web_opcodes', 'dict', []) -GenRun('gen/web_sys.js', 'gen/dump_web_opcodes', 'sys', []) +Importation('$dst/gen/web_boot.js', '$src/web/web_boot.fs', header_mode='web', name='boot') +Compile('$dst/gen/dump_web_opcodes', '$src/web/dump_web_opcodes.c') +GenRun('$dst/gen/web_cases.js', '$dst/gen/dump_web_opcodes', 'cases', []) +GenRun('$dst/gen/web_dict.js', '$dst/gen/dump_web_opcodes', 'dict', []) +GenRun('$dst/gen/web_sys.js', '$dst/gen/dump_web_opcodes', 'sys', []) WEB_ITEMS = [ - GenRun('web/ueforth.js', '$src/web/fuse_web.js', '', [ + GenRun('$dst/web/ueforth.js', '$src/web/fuse_web.js', '', [ '$src/web/web.template.js', - 'gen/web_boot.js', - 'gen/web_dict.js', - 'gen/web_cases.js', - 'gen/web_sys.js', + '$dst/gen/web_boot.js', + '$dst/gen/web_dict.js', + '$dst/gen/web_cases.js', + '$dst/gen/web_sys.js', ]), - Copy('web/terminal.html', '$src/web/terminal.html'), - Copy('web/lazy_terminal.html', '$src/web/lazy_terminal.html'), - Copy('web/script_lite_test.html', '$src/web/script_lite_test.html'), - Copy('web/script_test.fs', '$src/web/script_test.fs'), + Copy('$dst/web/terminal.html', '$src/web/terminal.html'), + Copy('$dst/web/lazy_terminal.html', '$src/web/lazy_terminal.html'), + Copy('$dst/web/script_lite_test.html', '$src/web/script_lite_test.html'), + Copy('$dst/web/script_test.fs', '$src/web/script_test.fs'), ] Alias('web', ' '.join(WEB_ITEMS)) diff --git a/windows/BUILD b/windows/BUILD index 6100738..3294ebe 100644 --- a/windows/BUILD +++ b/windows/BUILD @@ -15,40 +15,46 @@ Alias('windows', 'win32 win64') # Create boot. -Importation('gen/windows_boot.h', '$src/windows/windows_boot.fs', +Importation('$dst/gen/windows_boot.h', '$src/windows/windows_boot.fs', header_mode='win', name='boot') -Importation('gen/windows_boot_extra.h', '$src/windows/windows_boot_extra.fs', +Importation('$dst/gen/windows_boot_extra.h', '$src/windows/windows_boot_extra.fs', header_mode='win', name='boot_extra') # Compile Win32. Alias('win32', ' '.join([ - ForthTest('tests/win32_all_tests.out', 'windows/uEf32.exe', '$src/common/all_tests.fs', + ForthTest('$dst/tests/win32_all_tests.out', + '$dst/windows/uEf32.exe', '$src/common/all_tests.fs', interp='wine'), ])) -CompileW32('windows/uEf32.obj', '$src/windows/main.c', - implicit=['gen/windows_boot.h', 'gen/windows_boot_extra.h']) -LinkW32('windows/uEf32.exe', - ' '.join(['windows/uEf32.obj', 'resources/ueforth_res32.res'])) +CompileW32('$dst/windows/uEf32.obj', '$src/windows/main.c', + implicit=['$dst/gen/windows_boot.h', + '$dst/gen/windows_boot_extra.h']) +LinkW32('$dst/windows/uEf32.exe', + ' '.join(['$dst/windows/uEf32.obj', + '$dst/resources/ueforth_res32.res'])) # Compile Win64. Alias('win64', ' '.join([ - ForthTest('tests/win64_all_tests.out', 'windows/uEf64.exe', '$src/common/all_tests.fs', + ForthTest('$dst/tests/win64_all_tests.out', + '$dst/windows/uEf64.exe', '$src/common/all_tests.fs', interp='wine'), ])) -CompileW64('windows/uEf64.obj', '$src/windows/main.c', - implicit=['gen/windows_boot.h', 'gen/windows_boot_extra.h']) -LinkW64('windows/uEf64.exe', - ' '.join(['windows/uEf64.obj', 'resources/ueforth_res64.res'])) +CompileW64('$dst/windows/uEf64.obj', '$src/windows/main.c', + implicit=['$dst/gen/windows_boot.h', + '$dst/gen/windows_boot_extra.h']) +LinkW64('$dst/windows/uEf64.exe', + ' '.join(['$dst/windows/uEf64.obj', + '$dst/resources/ueforth_res64.res'])) # Create icon. ICON_SIZES = [ - ResizeImage('resources/eforth16x16.png', '$src/images/eforth.png', '16x16'), - ResizeImage('resources/eforth32x32.png', '$src/images/eforth.png', '32x32'), - ResizeImage('resources/eforth48x48.png', '$src/images/eforth.png', '48x48'), - ResizeImage('resources/eforth256x256.png', '$src/images/eforth.png', '256x256'), + ResizeImage('$dst/resources/eforth16x16.png', '$src/images/eforth.png', '16x16'), + ResizeImage('$dst/resources/eforth32x32.png', '$src/images/eforth.png', '32x32'), + ResizeImage('$dst/resources/eforth48x48.png', '$src/images/eforth.png', '48x48'), + ResizeImage('$dst/resources/eforth256x256.png', '$src/images/eforth.png', '256x256'), ] -ConvertImage('resources/eforth.ico', ' '.join(ICON_SIZES)) -CompileResource32('resources/ueforth_res32.res', '$src/windows/ueforth.rc', - implicit=['resources/eforth.ico']) -CompileResource64('resources/ueforth_res64.res', '$src/windows/ueforth.rc', - implicit=['resources/eforth.ico']) +ConvertImage('$dst/resources/eforth.ico', ' '.join(ICON_SIZES)) +CompileResource32('$dst/resources/ueforth_res32.res', '$src/windows/ueforth.rc', + implicit=['$dst/resources/eforth.ico']) +CompileResource64('$dst/resources/ueforth_res64.res', '$src/windows/ueforth.rc', + implicit=['$dst/resources/eforth.ico'])