summary refs log tree commit diff stats
path: root/build.sh
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-09 19:43:04 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-09 19:43:04 +0100
commit5afb50b1e8a737a4b906d2cdda22888eca8468a7 (patch)
tree4e0372adb28d4185bf25472d377fd53d38d013e6 /build.sh
downloadqmk_layout-5afb50b1e8a737a4b906d2cdda22888eca8468a7.zip
build: Add infrastructure
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh85
1 files changed, 85 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..51ecb7a
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,85 @@
+#!/usr/bin/env sh
+
+set -e
+
+# Moonlander Layout
+#
+# Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
+# This file is part of Moonlander Layout.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/agpl.txt>.
+
+LAYOUT_ID="KWBYA"
+LAYOUT_GEOMETRY="moonlander"
+
+# # Download layout source
+# data="$(mktemp)"
+# echo
+# cat <<EOF >"$data"
+# { "query": "query getLayout(\$hashId: String!, \$revisionId: String!, \$geometry: String) {layout(hashId: \$hashId, geometry: \$geometry, revisionId: \$revisionId) {  revision { hashId, qmkVersion, title }}}","variables":{"hashId":"$LAYOUT_ID","geometry":"$LAYOUT_GEOMETRY","revisionId":"latest"}}
+# EOF
+#
+# response="$(curl --location 'https://oryx.zsa.io/graphql' --header 'Content-Type: application/json' --data "$(cat "$data")" | jq '.data.layout.revision | [.hashId, .qmkVersion, .title]')"
+#
+# hash_id="$(echo "${response}" | jq -r '.[0]')"
+# firmware_version=$(printf "%.0f" "$(echo "${response}" | jq -r '.[1]')")
+# change_description=$(echo "${response}" | jq -r '.[2]')
+# if [ -z "${change_description}" ]; then
+#     change_description="latest layout modification made with Oryx"
+# fi
+#
+# curl -L "https://oryx.zsa.io/source/${hash_id}" -o source.zip
+#
+# # Unzip the source file
+# unzip -oj source.zip '*_source/*' -d "$LAYOUT_ID"
+# rm source.zip
+#
+# # Commit and Push changes
+# git config --local user.name "github-actions"
+# git config --local user.email "github-actions@github.com"
+# git add .
+# git commit -m "✨(oryx): $change_description" || echo "No layout change"
+# git push
+#
+# # Merge Oryx with custom QMK
+# git fetch origin main
+# git checkout -B main origin/main
+# git merge -Xignore-all-space oryx
+# git push
+#
+# # Checkout the right firmware branch
+# cd qmk_firmware
+# git submodule update --init --remote
+# git fetch origin "firmware$firmware_version"
+# git checkout -B "firmware$firmware_version" "origin/firmware$firmware_version"
+# git submodule update --init --recursive
+#
+# # Build qmk docker image
+# docker build -t qmk .
+
+# # Build the layout
+# ## Set keyboard directory and make prefix based on firmware version
+# if [ "$firmware_version" -ge 24 ]; then
+#     keyboard_directory="qmk_firmware/keyboards/zsa"
+#     make_prefix="zsa/"
+# else
+#     keyboard_directory="qmk_firmware/keyboards"
+#     make_prefix=""
+# fi
+#
+# ## Copy layout files to the qmk folder
+# rm -rf ${keyboard_directory}/$LAYOUT_GEOMETRY/keymaps/$LAYOUT_ID
+# mkdir -p ${keyboard_directory}/$LAYOUT_GEOMETRY/keymaps && cp -r $LAYOUT_ID ${keyboard_directory}/$LAYOUT_GEOMETRY/keymaps
+
+## Build the layout
+docker run -v ./qmk_firmware:/root --rm qmk /bin/sh -c "
+  qmk setup zsa/qmk_firmware -b 'firmware$firmware_version' -y
+  make ${make_prefix}$LAYOUT_GEOMETRY:$LAYOUT_ID
+"
+
+## Find and export built layout
+normalized_layout_geometry="$(echo "$LAYOUT_GEOMETRY" | sed 's/\//_/g')"
+built_layout_file="$(find ./qmk_firmware -maxdepth 1 -type f -regex ".*${normalized_layout_geometry}.*\.\(bin\|hex\)$")"