diff options
author | xengineering <me@xengineering.eu> | 2025-07-26 19:15:06 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2025-07-26 19:15:06 +0200 |
commit | 11078651756014631166cb8f0bf2d8bce18e56d1 (patch) | |
tree | d2e7e262d5f7dbbec4a41b5d86c1955b73b6a1c2 | |
parent | d3e7f19f1f87b03e9a7c8a170b9c4351ac565268 (diff) | |
parent | 376a2f91964527bfb6b57661a9e81a4d5544f288 (diff) | |
download | iot-contact-11078651756014631166cb8f0bf2d8bce18e56d1.tar iot-contact-11078651756014631166cb8f0bf2d8bce18e56d1.tar.zst iot-contact-11078651756014631166cb8f0bf2d8bce18e56d1.zip |
Merge implementation of tar archive deployment
Deploying all build artifacts in a single tar archive file makes
deployment easier. The bundle stays consistent, GPG signatures can later
easily provided too, the archive and its top-level directory can have
the same and long name and the further paths in the archive can stay
short.
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | artifacts/meson.build | 23 | ||||
-rw-r--r-- | fw/sim/meson.build | 1 | ||||
-rw-r--r-- | meson.build | 36 | ||||
-rw-r--r-- | pcb/meson.build | 2 | ||||
-rwxr-xr-x | tools/deploy.py.in (renamed from tools/deploy.py) | 11 | ||||
-rw-r--r-- | tools/meson.build | 8 | ||||
-rw-r--r-- | web/.gitignore | 2 | ||||
-rw-r--r-- | web/index.html | 12 | ||||
-rw-r--r-- | web/meson.build | 1 |
10 files changed, 55 insertions, 49 deletions
@@ -28,14 +28,14 @@ meson setup build ninja -C build ``` -The resulting artifacts can be listed with `tree`. +All artifacts of the build are bundled in a tar archive file. ``` -tree build/artifacts +tar -tf build/iot-contact-v*.tar.zst ``` -These artifacts are organized as static website. It can be opened with Firefox. +This archive file can be deployed with the `deploy.py` script. ``` -firefox build/artifacts/index.html +./build/tools/deploy.py ``` diff --git a/artifacts/meson.build b/artifacts/meson.build deleted file mode 100644 index ac15661..0000000 --- a/artifacts/meson.build +++ /dev/null @@ -1,23 +0,0 @@ -artifacts = [ - index_html, - css, - schematic, - bom, - simulation, - update_image, - factory_image, - kicad_pcb, -] - -foreach artifact : artifacts - custom_target( - output: [fs.name(artifact.full_path())], - command: [ - cp, - artifact.full_path(), - meson.current_build_dir(), - ], - depends: artifact, - build_by_default: true, - ) -endforeach diff --git a/fw/sim/meson.build b/fw/sim/meson.build index 5edcad9..2e0b4fa 100644 --- a/fw/sim/meson.build +++ b/fw/sim/meson.build @@ -20,5 +20,4 @@ simulation = custom_target( '--binary-name', 'zephyr.exe', '--target-name', 'simulation-linux-amd64.exe', ], - build_by_default: true, ) diff --git a/meson.build b/meson.build index 9b7d7c1..7549940 100644 --- a/meson.build +++ b/meson.build @@ -1,13 +1,41 @@ -project('iot-contact') +project( + 'iot-contact', + version : '0.0.0-dev', +) -cp = find_program('cp', required : true) +tar = find_program('tar', required : true) fs = import('fs') +project_version_string = meson.project_name() + '-v' + meson.project_version() + +html = fs.copyfile(meson.current_source_dir() / 'web' / 'index.html') css = fs.copyfile(meson.current_source_dir() / 'simple.css' / 'simple.css') subdir('tools') subdir('fw') subdir('pcb') -subdir('web') -subdir('artifacts') + +artifacts = [ + html, + css, + schematic, + bom, + simulation, + update_image, + factory_image, + kicad_pcb, +] + +custom_target( + output: project_version_string + '.tar.zst', + command: [ + tar, + '--zstd', + '--transform=s|^|' + project_version_string + '/|', + '-cf', '@OUTPUT@', + artifacts, + ], + depends: artifacts, + build_by_default: true, +) diff --git a/pcb/meson.build b/pcb/meson.build index 4feecce..7483cd0 100644 --- a/pcb/meson.build +++ b/pcb/meson.build @@ -18,7 +18,6 @@ schematic = custom_target( meson.current_source_dir() / 'iot-contact.kicad_sch', ], depend_files: schematic_files, - build_by_default: true, ) bom = custom_target( @@ -34,7 +33,6 @@ bom = custom_target( meson.current_source_dir() / 'iot-contact.kicad_sch', ], depend_files: schematic_files, - build_by_default: true, ) fs = import('fs') diff --git a/tools/deploy.py b/tools/deploy.py.in index 26048e8..8eeecda 100755 --- a/tools/deploy.py +++ b/tools/deploy.py.in @@ -7,8 +7,8 @@ import pathlib SCRIPT = pathlib.Path(__file__) -SOURCE_ROOT = SCRIPT.parent.parent.resolve() -ARTIFACTS_DEFAULT = SOURCE_ROOT / "build" / "artifacts" +BUILD_ROOT = SCRIPT.parent.parent.resolve() +ARTIFACTS_DEFAULT = BUILD_ROOT / "@PROJECT_VERSION_STRING@.tar.zst" def main() -> None: @@ -20,7 +20,7 @@ def main() -> None: "-a", "--artifacts", default=ARTIFACTS_DEFAULT, - help="local path to artifacts folder", + help="local path to artifacts archive file", ) parser.add_argument( "-H", "--host", default="cloud", help="target `Host` name from ~/.ssh/config" @@ -28,7 +28,7 @@ def main() -> None: parser.add_argument( "-p", "--path", - default="/srv/http/deploy.xengineering.eu/public/git/iot-contact/main/", + default="/srv/http/deploy.xengineering.eu/public/git/iot-contact/", help="remote path to destination folder on server", ) parser.add_argument( @@ -43,8 +43,7 @@ def main() -> None: command = [ "rsync", "-av", - "--delete", - f"{str(pathlib.Path(args.artifacts).resolve())}/", + f"{str(pathlib.Path(args.artifacts).resolve())}", f"{args.host}:{args.path}", ] diff --git a/tools/meson.build b/tools/meson.build index f58c54b..2a33d0e 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -1,3 +1,11 @@ configure_zephyr = meson.current_source_dir() / 'configure_zephyr.py' build_zephyr = meson.current_source_dir() / 'build_zephyr.py' make_factory_image = meson.current_source_dir() / 'make_factory_image.py' + +configure_file( + configuration : { + 'PROJECT_VERSION_STRING': project_version_string, + }, + input : 'deploy.py.in', + output : 'deploy.py', +) diff --git a/web/.gitignore b/web/.gitignore deleted file mode 100644 index 07b5637..0000000 --- a/web/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -public -.hugo_build.lock diff --git a/web/index.html b/web/index.html index f8d76ed..d353cb7 100644 --- a/web/index.html +++ b/web/index.html @@ -12,16 +12,16 @@ <h4>Printed circuit board</h4> <ul> - <li><a href="iot-contact.kicad_pcb">iot-contact.kicad_pcb</a></li> - <li><a href="schematic.pdf">schematic.pdf</a></li> - <li><a href="bill-of-materials.csv">bill-of-materials.csv</a></li> + <li><a href="pcb/iot-contact.kicad_pcb">iot-contact.kicad_pcb</a></li> + <li><a href="pcb/schematic.pdf">schematic.pdf</a></li> + <li><a href="pcb/bill-of-materials.csv">bill-of-materials.csv</a></li> </ul> <h4>Firmware</h4> <ul> - <li><a href="factory-image.bin">factory-image.bin</a></li> - <li><a href="update-image.bin">update-image.bin</a></li> - <li><a href="simulation-linux-amd64.exe">simulation-linux-amd64.exe</a></li> + <li><a href="fw/factory-image.bin">factory-image.bin</a></li> + <li><a href="fw/app/update-image.bin">update-image.bin</a></li> + <li><a href="fw/sim/simulation-linux-amd64.exe">simulation-linux-amd64.exe</a></li> </ul> </main> </body> diff --git a/web/meson.build b/web/meson.build deleted file mode 100644 index 19551a5..0000000 --- a/web/meson.build +++ /dev/null @@ -1 +0,0 @@ -index_html = fs.copyfile(meson.current_source_dir() / 'index.html') |