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. --- meson.build | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'meson.build') 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(-) (limited to 'meson.build') 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 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 (limited to '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 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(-) (limited to 'meson.build') 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(-) (limited to 'meson.build') 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 (limited to 'meson.build') 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