From d41054cda3db924c571fdf269ff2cdb26839e445 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Mon, 9 Jan 2017 17:03:31 -0700
Subject: [PATCH] Allow overriding of most recipe features. Add orbdata recipe

---
 cook.sh                    | 51 ++++++++++++++++++++++++++++++--------
 recipes/orbdata/recipe.sh  | 27 ++++++++++++++++++++
 recipes/orbutils/recipe.sh |  4 ---
 3 files changed, 68 insertions(+), 14 deletions(-)
 create mode 100644 recipes/orbdata/recipe.sh

diff --git a/cook.sh b/cook.sh
index e5ce05430..9db13abc7 100755
--- a/cook.sh
+++ b/cook.sh
@@ -46,36 +46,67 @@ function op {
             ;;
         update)
             pushd build > /dev/null
-            xargo update
+            skip="0"
+            if [ "$(type -t recipe_update)" = "function" ]
+            then
+                recipe_update || skip="1"
+            fi
+            if [ "$skip" -eq "0" ]
+            then
+                xargo update
+            fi
             popd > /dev/null
             ;;
         build)
             pushd build > /dev/null
-            cp -r "$ROOT/Xargo.toml" "$ROOT/.cargo" "$ROOT/libc-artifacts" .
-            xargo build --target "$TARGET" --release $CARGOFLAGS
+            skip="0"
+            if [ "$(type -t recipe_build)" = "function" ]
+            then
+                recipe_build || skip="1"
+            fi
+            if [ "$skip" -eq "0" ]
+            then
+                cp -r "$ROOT/Xargo.toml" "$ROOT/.cargo" "$ROOT/libc-artifacts" .
+                xargo build --target "$TARGET" --release $CARGOFLAGS
+            fi
             popd > /dev/null
             ;;
         test)
             pushd build > /dev/null
-            cp -r "$ROOT/Xargo.toml" "$ROOT/.cargo" "$ROOT/libc-artifacts" .
-            xargo test --no-run --target "$TARGET" --release $CARGOFLAGS
+            skip="0"
+            if [ "$(type -t recipe_test)" = "function" ]
+            then
+                recipe_test || skip="1"
+            fi
+            if [ "$skip" -eq "0" ]
+            then
+                cp -r "$ROOT/Xargo.toml" "$ROOT/.cargo" "$ROOT/libc-artifacts" .
+                xargo test --no-run --target "$TARGET" --release $CARGOFLAGS
+            fi
             popd > /dev/null
             ;;
         clean)
             pushd build > /dev/null
-            xargo clean
+            skip="0"
+            if [ "$(type -t recipe_clean)" = "function" ]
+            then
+                recipe_clean || skip="1"
+            fi
+            if [ "$skip" -eq "0" ]
+            then
+                xargo clean
+            fi
             popd > /dev/null
             ;;
         stage)
             mkdir -p stage
             pushd build > /dev/null
-            skip_bins="0"
+            skip="0"
             if [ "$(type -t recipe_stage)" = "function" ]
             then
-                recipe_stage ../stage
-                skip_bins="$?"
+                recipe_stage ../stage || skip="1"
             fi
-            if [ "$skip_bins" -eq "0" ]
+            if [ "$skip" -eq "0" ]
             then
                 #TODO xargo install --root "../stage" $CARGOFLAGS
                 bins="$(find target/$TARGET/release/ -maxdepth 1 -type f ! -name '*.*')"
diff --git a/recipes/orbdata/recipe.sh b/recipes/orbdata/recipe.sh
new file mode 100644
index 000000000..e7ecb8412
--- /dev/null
+++ b/recipes/orbdata/recipe.sh
@@ -0,0 +1,27 @@
+GIT=https://github.com/redox-os/orbdata.git
+
+function recipe_update {
+    echo "skipping update"
+    return 1
+}
+
+function recipe_build {
+    echo "skipping build"
+    return 1
+}
+
+function recipe_test {
+    echo "skipping test"
+    return 1
+}
+
+function recipe_clean {
+    echo "skipping clean"
+    return 1
+}
+
+function recipe_stage {
+    mkdir -pv "$1/ui"
+    cp -Rv ./* "$1/ui"
+    return 1
+}
diff --git a/recipes/orbutils/recipe.sh b/recipes/orbutils/recipe.sh
index f8bc489a5..e049cafdc 100644
--- a/recipes/orbutils/recipe.sh
+++ b/recipes/orbutils/recipe.sh
@@ -1,6 +1,2 @@
 GIT=https://github.com/redox-os/orbutils.git
 BINDIR=/ui/bin
-
-function recipe_stage {
-    cp -Rv ui "$1/ui"
-}
-- 
GitLab