Adding publish, untested.

This commit is contained in:
Brad Nelson
2024-01-01 22:04:40 -08:00
parent 3a17582a8c
commit a6c6b8d25f
5 changed files with 122 additions and 13 deletions

1
BUILD
View File

@ -24,4 +24,3 @@ Default('posix')
Default('web')
Default('esp32')
Default('pico')
Default('site')

View File

@ -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'

View File

@ -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"""\

View File

@ -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'),
])),
])),
]))

41
tools/publish.py Executable file
View File

@ -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)