From a6c6b8d25f389df3cd07acba345ddeb0fa68e141 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Mon, 1 Jan 2024 22:04:40 -0800 Subject: [PATCH] Adding publish, untested. --- BUILD | 1 - configure.py | 27 ++++++++++++++++++++- esp32/BUILD | 3 +-- site/BUILD | 63 +++++++++++++++++++++++++++++++++++++++++------- tools/publish.py | 41 +++++++++++++++++++++++++++++++ 5 files changed, 122 insertions(+), 13 deletions(-) create mode 100755 tools/publish.py diff --git a/BUILD b/BUILD index c73e2c1..3e5cdc0 100644 --- a/BUILD +++ b/BUILD @@ -24,4 +24,3 @@ Default('posix') Default('web') Default('esp32') Default('pico') -Default('site') diff --git a/configure.py b/configure.py index e942ac6..4c46f3f 100755 --- a/configure.py +++ b/configure.py @@ -18,7 +18,7 @@ import os import sys import subprocess -VERSION = '7.0.7.16' +VERSION = '7.0.7.17' STABLE_VERSION = '7.0.6.19' OLD_STABLE_VERSION = '7.0.5.4' @@ -266,6 +266,15 @@ rule forth_test deps = gcc command = $src/tools/importation.py -i $test -o $out --depsout $depfile --no-out && $interp $forth $test 2>&1 | cat >$out +rule publish + description = PUBLISH $pubpath + command = $src/tools/publish.py --src $in --dst $pubpath \ + -DVERSION=$VERSION \ + -DSTABLE_VERSION=$STABLE_VERSION \ + -DOLD_STABLE_VERSION=$OLD_STABLE_VERSION \ + -FREVISION=$dst/gen/REVISION \ + -FREVSHORT=$dst/gen/REVSHORT + rule clean description = CLEAN command = rm -rf $dst/ @@ -379,6 +388,10 @@ def Alias(target, source): return target +def Shortcut(target, source, command): + return Alias(target, Command('$dst/gen/' + target + '.not', source, command)) + + def Copy(target, source): global output output += f'build {target}: copy {source}\n' @@ -423,6 +436,18 @@ def Command(target, source, command, implicit=[]): return target +def Publish(target, source, pubpath): + global output + implicit = ' '.join([ + '$src/tools/publish.py', + '$dst/gen/REVISION', + '$dst/gen/REVSHORT', + ]) + output += f'build {target}: publish {source} | {implicit}\n' + output += f' pubpath = {pubpath}\n' + return target + + def Default(target): global output output += f'default {target}\n' diff --git a/esp32/BUILD b/esp32/BUILD index 357fe93..022d254 100644 --- a/esp32/BUILD +++ b/esp32/BUILD @@ -77,7 +77,7 @@ BOARDS = { } for board in BOARDS: options = BOARDS[board] - Command(f'$dst/esp32/{board}_build/flash.not', + Shortcut(f'{board}-flash', '$dst/esp32/ESP32forth/ESP32forth.ino', f"""\ rm -rf {WINTMP}/ueforth_esp32/ESP32forth/ && \ @@ -89,7 +89,6 @@ for board in BOARDS: --build-path ueforth_esp32/{board}_build \ --build-cache-path ueforth_esp32/{board}_cache \ ueforth_esp32/ESP32forth/ESP32forth.ino""") - Alias(f'{board}-flash', f'$dst/esp32/{board}_build/flash.not') Command(f'$dst/esp32/{board}_build/ESP32forth.ino.bin', '$dst/esp32/ESP32forth/ESP32forth.ino', f"""\ diff --git a/site/BUILD b/site/BUILD index 182cc14..d0ef855 100644 --- a/site/BUILD +++ b/site/BUILD @@ -12,14 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -REPLACE = [ - './tools/importation.py', - '-I', 'site', - '-DVERSION=' + VERSION, - '-DSTABLE_VERSION' + STABLE_VERSION, - '-DOLD_STABLE_VERSION=' + OLD_STABLE_VERSION, -] - OPTIONS = '-I $src/site' UE_OPTIONS = OPTIONS + ' -DFORTH=uEForth' ESP_OPTIONS = OPTIONS + ' -DFORTH=ESP32forth' @@ -60,4 +52,57 @@ DEPLOY_ITEMS += [ Copy('$dst/deploy/static/favicon.ico', '$dst/resources/eforth.ico'), ] -Alias('site', ' '.join(DEPLOY_ITEMS)) +Alias('deploy', ' '.join(DEPLOY_ITEMS)) + +Alias('publish', ' '.join([ + Alias('publish-esp32', ' '.join([ + Publish('publish-esp32-rev', + '$dst/esp32/ESP32forth.zip', + 'ESP32forth-{{VERSION}}-{{REVSHORT}}.zip'), + Shortcut('publish-esp32-ver', + '$dst/esp32/ESP32forth.zip', + 'ESP32forth-{{VERSION}}.zip'), + ])), + Alias('publish-pico-ice', ' '.join([ + Shortcut('publish-pico-ice-rev', + '$dst/pico-ice/ueforth-pico-ice.zip', + 'ueforth-pico-ice-{{VERSION}}-{{REVSHORT}}.zip'), + Shortcut('publish-pico-ice-ver', + '$dst/pico-ice/ueforth-pico-ice.zip', + 'ueforth-pico-ice-{{VERSION}}.zip'), + ])), + Alias('publish-linux', ' '.join([ + Shortcut('publish-linux-rev', + '$dst/posix/ueforth', + 'ueforth-{{VERSION}}-{{REVSHORT}}.linux'), + Shortcut('publish-linux-ver', + '$dst/posix/ueforth', + 'ueforth-{{VERSION}}.linux'), + ])), + Alias('publish-web', ' '.join([ + Shortcut('publish-web-rev', + '$dst/web/ueforth.js', + 'ueforth-{{VERSION}}-{{REVSHORT}}.js'), + Shortcut('publish-web-ver', + '$dst/web/ueforth.js', + 'ueforth-{{VERSION}}.js'), + ])), + Alias('publish-win', ' '.join([ + Alias('publish-win32', ' '.join([ + Shortcut('publish-win32-rev', + '$dst/windows/uEf32.exe', + 'uEf32-{{VERSION}}-{{REVSHORT}}.exe'), + Shortcut('publish-win32-ver', + '$dst/windows/uEf32.exe', + 'uEf32-{{VERSION}}.exe'), + ])), + Alias('publish-win64', ' '.join([ + Shortcut('publish-win64-rev', + '$dst/windows/uEf64.exe', + 'uEf64-{{VERSION}}-{{REVSHORT}}.exe'), + Shortcut('publish-win64-ver', + '$dst/windows/uEf64.exe', + 'uEf64-{{VERSION}}.exe'), + ])), + ])), +])) diff --git a/tools/publish.py b/tools/publish.py new file mode 100755 index 0000000..69b4da6 --- /dev/null +++ b/tools/publish.py @@ -0,0 +1,41 @@ +#! /usr/bin/env python3 +# 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. + +import argparse +import subprocess + +ARCHIVE = 'gs://eforth/releases' +GSUTIL = 'CLOUDSDK_CORE_PROJECT=eforth gsutil' +GSUTIL_CP = f'{GSUTIL} -h Cache-Control:public,max-age=60 cp -a public-read' + +parser = argparse.ArgumentParser( + prog='publish', + description='Publish with substitutions') +parser.add_argument('--src', required=True) +parser.add_argument('--dst', required=True) +parser.add_argument('-D', action='append') +parser.add_argument('-F', action='append') +args = parser.parse_args() + +dst = args.dst +for r in replacements: + name, value = r.split('=', 1) + dst = dst.replace('{{' + name + '}}', value) +for r in file_replacements: + name, filename = r.split('=', 1) + imported.add(os.path.abspath(filename)) + line = line.replace('{{' + name + '}}', open(filename).read()) + +subprocess.run(f'{GSUTIL_CP} {args.src} {args.dst}', shell=True, check=True)