From 5376b67a9df63d2b30cac415cb827e6b4c1674e9 Mon Sep 17 00:00:00 2001
From: xengineering <me@xengineering.eu>
Date: Sun, 6 Apr 2025 14:24:06 +0200
Subject: Build bootloader and add to website

Meson makes this relatively easy. The current approach is nevertheless a
bit hacky. For the first attempt it is still way better than CMake
ExternalProject.
---
 fw/btl/build.py    | 29 +++++++++++++++++++++++++++++
 fw/btl/meson.build | 11 +++++++++++
 2 files changed, 40 insertions(+)
 create mode 100755 fw/btl/build.py

(limited to 'fw')

diff --git a/fw/btl/build.py b/fw/btl/build.py
new file mode 100755
index 0000000..6478701
--- /dev/null
+++ b/fw/btl/build.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+
+import multiprocessing
+import shutil
+import subprocess
+import sys
+import pathlib
+
+
+build_tree = pathlib.Path(sys.argv[1])
+output_dir = build_tree.parent
+
+
+subprocess.run(
+    [
+        "make",
+        f"-j{multiprocessing.cpu_count()}",
+        "-C",
+        f"{str(build_tree)}",
+    ],
+    shell=False,
+    check=True,
+)
+
+shutil.copy(
+    build_tree / "zephyr" / "zephyr.bin",
+    output_dir / "bootloader.bin"
+)
diff --git a/fw/btl/meson.build b/fw/btl/meson.build
index b783191..37c8c25 100644
--- a/fw/btl/meson.build
+++ b/fw/btl/meson.build
@@ -12,3 +12,14 @@ bootloader_project = external_project.add_project('configure.py',
   ],
   verbose: true,
 )
+
+bootloader = custom_target('bootloader',
+  output: ['bootloader.bin'],
+  command: [
+    meson.current_source_dir() / 'build.py',
+    meson.current_build_dir() / 'build',
+  ],
+  build_by_default: true,
+  install: true,
+  install_dir: 'website/static',
+)
-- 
cgit v1.2.3-70-g09d2