From 6a45e03470eedb4689b8e318758ed5c9427e5a24 Mon Sep 17 00:00:00 2001
From: Stefan Hansson <newbyte@postmarketos.org>
Date: Thu, 10 Oct 2024 20:27:07 +0200
Subject: [PATCH] CI: Build native libraries for mrhlpr and mrtest via mypyc

Mostly for fun. Not sure if there's any real practical benefit. It might
be useful for pmbootstrap later, but adopting it to be compatible with
mypyc would likely be more work, so I'm using this as a playground to
learn how it works.
---
 .ci/native-build.sh | 17 +++++++++++++++++
 .gitlab-ci.yml      |  5 +++++
 2 files changed, 22 insertions(+)
 create mode 100755 .ci/native-build.sh

diff --git a/.ci/native-build.sh b/.ci/native-build.sh
new file mode 100755
index 0000000..2519530
--- /dev/null
+++ b/.ci/native-build.sh
@@ -0,0 +1,17 @@
+#!/bin/sh -e
+# Description: Build native libraries of mrhlpr and mrtest using mypyc
+# https://postmarketos.org/pmb-ci
+
+if [ "$(id -u)" = 0 ]; then
+	set -x
+	apk -q add gcc musl-dev py3-argcomplete py3-gitlab py3-pip python3-dev
+	exec su "${TESTUSER:-build}" -c "sh -e $0"
+fi
+
+set -x
+
+# mypyc from Alpine may be an old version. Given mypyc's early development
+# status, install it from pypi instead to ensure we don't have to deal with
+# working around bugs that already have been fixed in newer versions.
+pip install --break-system-packages --no-warn-script-location mypy
+python -m mypyc mrtest mrhlpr
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index aed4e1a..098fc3f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,3 +11,8 @@ mypy:
   - adduser -D build
   script:
   - .ci/mypy.sh
+native-build:
+  before_script:
+  - adduser -D build
+  script:
+  - .ci/native-build.sh
\ No newline at end of file
-- 
GitLab