From db83efd4d439ecd100c9b2400c00a68597444d89 Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 25 Jul 2025 22:38:51 +0200 Subject: tools: Remove deploy.py This prepares switching to deployment with only a single archive file. The deploy script will be re-written as soon as this transition is complete. --- tools/deploy.py | 58 --------------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100755 tools/deploy.py diff --git a/tools/deploy.py b/tools/deploy.py deleted file mode 100755 index 26048e8..0000000 --- a/tools/deploy.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python3 - - -import argparse -import subprocess -import pathlib - - -SCRIPT = pathlib.Path(__file__) -SOURCE_ROOT = SCRIPT.parent.parent.resolve() -ARTIFACTS_DEFAULT = SOURCE_ROOT / "build" / "artifacts" - - -def main() -> None: - parser = argparse.ArgumentParser( - description="Use OpenSSH and rsync to deploy artifacts", - ) - - parser.add_argument( - "-a", - "--artifacts", - default=ARTIFACTS_DEFAULT, - help="local path to artifacts folder", - ) - parser.add_argument( - "-H", "--host", default="cloud", help="target `Host` name from ~/.ssh/config" - ) - parser.add_argument( - "-p", - "--path", - default="/srv/http/deploy.xengineering.eu/public/git/iot-contact/main/", - help="remote path to destination folder on server", - ) - parser.add_argument( - "-d", - "--dry-run", - action="store_true", - help="do not execute command and instead print it", - ) - - args = parser.parse_args() - - command = [ - "rsync", - "-av", - "--delete", - f"{str(pathlib.Path(args.artifacts).resolve())}/", - f"{args.host}:{args.path}", - ] - - if args.dry_run: - print(command) - else: - subprocess.run(command, shell=False, check=True) - - -if __name__ == "__main__": - main() -- cgit v1.2.3-70-g09d2 From 834dacb9ffaead63b626489d22aab2f8263e9f16 Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 25 Jul 2025 22:46:44 +0200 Subject: artifacts: Remove this folder This was just a trick to provide a folder in the build tree where only artifacts are stored. These artifacts are moved to the root of the build tree. This has the disadvantage that they are mixed with other files inside this folder. Nevertheless they should soon be added by Meson to the file archive used for deployment which solves this issue because it contains by definition only artifacts. --- README.md | 12 ------------ artifacts/meson.build | 23 ----------------------- meson.build | 26 ++++++++++++++++++++++++-- 3 files changed, 24 insertions(+), 37 deletions(-) delete mode 100644 artifacts/meson.build diff --git a/README.md b/README.md index a6dfe0a..c8b6b1a 100644 --- a/README.md +++ b/README.md @@ -27,15 +27,3 @@ The project is built with the Meson build system. meson setup build ninja -C build ``` - -The resulting artifacts can be listed with `tree`. - -``` -tree build/artifacts -``` - -These artifacts are organized as static website. It can be opened with Firefox. - -``` -firefox build/artifacts/index.html -``` 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/meson.build b/meson.build index 9b7d7c1..dcc0fe2 100644 --- a/meson.build +++ b/meson.build @@ -4,10 +4,32 @@ cp = find_program('cp', required : true) fs = import('fs') -css = fs.copyfile(meson.current_source_dir() / 'simple.css' / 'simple.css') +fs.copyfile(meson.current_source_dir() / 'simple.css' / 'simple.css') subdir('tools') subdir('fw') subdir('pcb') subdir('web') -subdir('artifacts') + +artifacts = [ + index_html, + 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 -- cgit v1.2.3-70-g09d2 From f936bfd7176c23e71183317b4f8844d92b9e746e Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 26 Jul 2025 11:17:30 +0200 Subject: Provide tar archive as main build result This generates `build/iot-contact.tar.zst` as primary build artifact. It contains all artifacts which should be deployed. Providing this as file archive makes further handling more easy. --- meson.build | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index dcc0fe2..8e2d91c 100644 --- a/meson.build +++ b/meson.build @@ -1,10 +1,10 @@ project('iot-contact') -cp = find_program('cp', required : true) +tar = find_program('tar', required : true) fs = import('fs') -fs.copyfile(meson.current_source_dir() / 'simple.css' / 'simple.css') +css = fs.copyfile(meson.current_source_dir() / 'simple.css' / 'simple.css') subdir('tools') subdir('fw') @@ -13,6 +13,7 @@ subdir('web') artifacts = [ index_html, + css, schematic, bom, simulation, @@ -21,15 +22,20 @@ artifacts = [ 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 +custom_target( + output: meson.project_name() + '.tar.zst', + command: [ + tar, + '--zstd', + '--transform=s|^fw/app/||', + '--transform=s|^fw/sim/||', + '--transform=s|^fw/||', + '--transform=s|^pcb/||', + '--transform=s|^web/||', + '--transform=s|^|' + meson.project_name() + '/|', + '-cf', '@OUTPUT@', + artifacts, + ], + depends: artifacts, + build_by_default: true, +) -- cgit v1.2.3-70-g09d2 From 4f310831b3d052e4c1bd536c33139c3d20235a0c Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 26 Jul 2025 11:27:33 +0200 Subject: web: Remove unnecessary .gitignore --- web/.gitignore | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 web/.gitignore 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 -- cgit v1.2.3-70-g09d2 From aa5cd7b1e22f4165ad47d9042a0d6e8d1adee6e7 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 26 Jul 2025 11:29:10 +0200 Subject: Move HTML copy to root Meson file --- meson.build | 4 ++-- web/meson.build | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 web/meson.build diff --git a/meson.build b/meson.build index 8e2d91c..1840972 100644 --- a/meson.build +++ b/meson.build @@ -4,15 +4,15 @@ tar = find_program('tar', required : true) fs = import('fs') +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') artifacts = [ - index_html, + html, css, schematic, bom, 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') -- cgit v1.2.3-70-g09d2 From c2e22305d9af9c10f7f5e168088d62af360c8c2d Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 26 Jul 2025 11:35:32 +0200 Subject: Only build tar archive by default Everything else is implicitly build by default since it should contribute to the tar archive. --- fw/sim/meson.build | 1 - pcb/meson.build | 2 -- 2 files changed, 3 deletions(-) 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/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') -- cgit v1.2.3-70-g09d2 From 73d1db5dddbae00477c3ebfb25dd64db0a2a8ac8 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 26 Jul 2025 17:34:27 +0200 Subject: Same structure for source, build and deploy trees This commit removes the path transformations apart from project-prefixing from the deploy tree / artifact file archive. This gives the source tree, build tree and deploy tree the same directory hierarchy. The advantages are simple implementation and maintenance and a common structure for all parties (users, developers, producers, ...). The disadvantage is obviously that the deploy tree structure cannot be customized on its own. At least for now the approach "there is one right structure to rule them all" is taken. --- meson.build | 5 ----- web/index.html | 12 ++++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 1840972..4548f4d 100644 --- a/meson.build +++ b/meson.build @@ -27,11 +27,6 @@ custom_target( command: [ tar, '--zstd', - '--transform=s|^fw/app/||', - '--transform=s|^fw/sim/||', - '--transform=s|^fw/||', - '--transform=s|^pcb/||', - '--transform=s|^web/||', '--transform=s|^|' + meson.project_name() + '/|', '-cf', '@OUTPUT@', artifacts, 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 @@

Printed circuit board

Firmware

-- cgit v1.2.3-70-g09d2 From 0f8c729e691b450cc994e28d68eab8d3250d8457 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 26 Jul 2025 18:11:34 +0200 Subject: Add project version and use for deploy archive All build artifacts should be deployed in a single `*.tar.zst` file. This archive and the single top-level content (a directory called `*` in this case) should contain the project name and version in its name. The latter is added with this commit so that there is now an `iot-contact-v0.0.0-dev.tar.zst` instead of an `iot-contact.tar.zst`. --- meson.build | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 4548f4d..a6fd4a0 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,7 @@ -project('iot-contact') +project( + 'iot-contact', + version : '0.0.0-dev', +) tar = find_program('tar', required : true) @@ -22,12 +25,14 @@ artifacts = [ kicad_pcb, ] +project_version_string = meson.project_name() + '-v' + meson.project_version() + custom_target( - output: meson.project_name() + '.tar.zst', + output: project_version_string + '.tar.zst', command: [ tar, '--zstd', - '--transform=s|^|' + meson.project_name() + '/|', + '--transform=s|^|' + project_version_string + '/|', '-cf', '@OUTPUT@', artifacts, ], -- cgit v1.2.3-70-g09d2 From ce9b6c2d205b7d2559a49a36a8d7422ccd12a177 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 26 Jul 2025 18:59:33 +0200 Subject: tools: Re-introduce deploy.py script After the transition to tar archive based deployment it can now be re-introduced with small changes. --- meson.build | 4 ++-- tools/deploy.py.in | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/meson.build | 8 ++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100755 tools/deploy.py.in diff --git a/meson.build b/meson.build index a6fd4a0..7549940 100644 --- a/meson.build +++ b/meson.build @@ -7,6 +7,8 @@ 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') @@ -25,8 +27,6 @@ artifacts = [ kicad_pcb, ] -project_version_string = meson.project_name() + '-v' + meson.project_version() - custom_target( output: project_version_string + '.tar.zst', command: [ diff --git a/tools/deploy.py.in b/tools/deploy.py.in new file mode 100755 index 0000000..8eeecda --- /dev/null +++ b/tools/deploy.py.in @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 + + +import argparse +import subprocess +import pathlib + + +SCRIPT = pathlib.Path(__file__) +BUILD_ROOT = SCRIPT.parent.parent.resolve() +ARTIFACTS_DEFAULT = BUILD_ROOT / "@PROJECT_VERSION_STRING@.tar.zst" + + +def main() -> None: + parser = argparse.ArgumentParser( + description="Use OpenSSH and rsync to deploy artifacts", + ) + + parser.add_argument( + "-a", + "--artifacts", + default=ARTIFACTS_DEFAULT, + help="local path to artifacts archive file", + ) + parser.add_argument( + "-H", "--host", default="cloud", help="target `Host` name from ~/.ssh/config" + ) + parser.add_argument( + "-p", + "--path", + default="/srv/http/deploy.xengineering.eu/public/git/iot-contact/", + help="remote path to destination folder on server", + ) + parser.add_argument( + "-d", + "--dry-run", + action="store_true", + help="do not execute command and instead print it", + ) + + args = parser.parse_args() + + command = [ + "rsync", + "-av", + f"{str(pathlib.Path(args.artifacts).resolve())}", + f"{args.host}:{args.path}", + ] + + if args.dry_run: + print(command) + else: + subprocess.run(command, shell=False, check=True) + + +if __name__ == "__main__": + main() 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', +) -- cgit v1.2.3-70-g09d2 From 376a2f91964527bfb6b57661a9e81a4d5544f288 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 26 Jul 2025 19:08:56 +0200 Subject: README: Document tar archive and deploy script --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index c8b6b1a..356feeb 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,15 @@ The project is built with the Meson build system. meson setup build ninja -C build ``` + +All artifacts of the build are bundled in a tar archive file. + +``` +tar -tf build/iot-contact-v*.tar.zst +``` + +This archive file can be deployed with the `deploy.py` script. + +``` +./build/tools/deploy.py +``` -- cgit v1.2.3-70-g09d2