From d1ff741b28dc4369862dfa169ebe88a2329dc2c6 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Tue, 1 Nov 2016 16:05:16 -0600
Subject: [PATCH] Allow stage function

---
 cook.sh                       | 18 +++++++++++++++---
 recipes/pixelcannon/recipe.sh |  6 ++++++
 2 files changed, 21 insertions(+), 3 deletions(-)
 create mode 100644 recipes/pixelcannon/recipe.sh

diff --git a/cook.sh b/cook.sh
index f47f58549..875e78cb7 100755
--- a/cook.sh
+++ b/cook.sh
@@ -42,11 +42,23 @@ function op {
             popd > /dev/null
             ;;
         stage)
-            mkdir -p stage/bin
+            mkdir -p stage
             pushd build > /dev/null
+            if [ "$(type -t recipe_stage)" = "function" ]
+            then
+                recipe_stage ../stage
+            fi
             #TODO xargo install --root "../stage" $CARGOFLAGS
-            cp -v $(find target/x86_64-unknown-redox/debug/ -maxdepth 1 -type f ! -name "*.*") ../stage/bin
-            strip -v ../stage/bin/*
+            bins="$(find target/x86_64-unknown-redox/debug/ -maxdepth 1 -type f ! -name '*.*')"
+            if [ -n "$bins" ]
+            then
+                mkdir -p ../stage/bin
+                for bin in $bins
+                do
+                    cp -v "$bin" "../stage/bin/$(basename $bin)"
+                    strip -v "../stage/bin/$(basename $bin)"
+                done
+            fi
             popd > /dev/null
             ;;
         unstage)
diff --git a/recipes/pixelcannon/recipe.sh b/recipes/pixelcannon/recipe.sh
new file mode 100644
index 000000000..b4cc7bed2
--- /dev/null
+++ b/recipes/pixelcannon/recipe.sh
@@ -0,0 +1,6 @@
+GIT=https://github.com/jackpot51/pixelcannon.git
+
+function recipe_stage {
+    mkdir -pv "$1/apps/pixelcannon"
+    cp -Rv assets "$1/apps/pixelcannon"
+}
-- 
GitLab