From 7d31150e21d1ae62ca33a4015b0f74d217c3ba73 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Thu, 8 Dec 2022 09:15:15 -0700
Subject: [PATCH] Migrate glutin to new recipe format

---
 recipes/glutin/recipe.sh   | 22 ----------------------
 recipes/glutin/recipe.toml | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 22 deletions(-)
 delete mode 100644 recipes/glutin/recipe.sh
 create mode 100644 recipes/glutin/recipe.toml

diff --git a/recipes/glutin/recipe.sh b/recipes/glutin/recipe.sh
deleted file mode 100644
index 41fc5a100..000000000
--- a/recipes/glutin/recipe.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-GIT=https://gitlab.redox-os.org/redox-os/glutin.git
-GIT_UPSTREAM=https://github.com/rust-windowing/glutin.git
-BUILD_DEPENDS=(llvm mesa zlib)
-BRANCH=redox-0.29
-
-function recipe_build {
-    sysroot="$(realpath ../sysroot)"
-    set -x
-    cargo rustc --target "$TARGET" --release --package glutin_examples --example window \
-        -- \
-        -L "${sysroot}/lib" \
-        -C link-args="-Wl,-Bstatic $("${PKG_CONFIG}" --libs osmesa) -lz -lstdc++ -lc -lgcc"
-    set +x
-    skip=1
-}
-
-function recipe_stage {
-    dest="$(realpath $1)"
-    mkdir -pv "$dest/bin"
-    cp -v "target/${TARGET}/release/examples/window" "$dest/bin/glutin"
-    skip=1
-}
diff --git a/recipes/glutin/recipe.toml b/recipes/glutin/recipe.toml
new file mode 100644
index 000000000..18fed532d
--- /dev/null
+++ b/recipes/glutin/recipe.toml
@@ -0,0 +1,32 @@
+[source]
+git = "https://gitlab.redox-os.org/redox-os/glutin.git"
+branch = "redox-0.29"
+upstream = "https://github.com/rust-windowing/glutin.git"
+
+[build]
+template = "custom"
+dependencies = [
+    "llvm",
+    "mesa",
+    "zlib"
+]
+script = """
+EXAMPLES=(
+    multiwindow
+    transparent
+    window
+)
+for example in "${EXAMPLES[@]}"
+do
+    cargo rustc \
+        --target "$TARGET" \
+        --release \
+        --manifest-path "${COOKBOOK_SOURCE}/glutin_examples/Cargo.toml" \
+        --example "${example}" \
+        -- \
+        -L "${COOKBOK_SYSROOT}/lib" \
+        -C link-args="-Wl,-Bstatic $("${TARGET}-pkg-config" --libs osmesa) -lz -lstdc++ -lc -lgcc"
+    mkdir -pv "${COOKBOOK_STAGE}/bin"
+    cp -v "target/${TARGET}/release/examples/${example}" "${COOKBOOK_STAGE}/bin/glutin_${example}"
+done
+"""
-- 
GitLab