From ab95a71636d683f339375c9dc35ac5ea2dda4f51 Mon Sep 17 00:00:00 2001
From: jD91mZM2 <me@krake.one>
Date: Thu, 25 Apr 2019 17:09:57 +0200
Subject: [PATCH] New flag: Enable example binaries alongside using EXAMPLES=1

---
 cook.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/cook.sh b/cook.sh
index 6cd0bf228..bad288a48 100755
--- a/cook.sh
+++ b/cook.sh
@@ -10,6 +10,7 @@ export CARGO=(env RUSTFLAGS="$PREFIX_RUSTFLAGS" xargo)
 export CARGOBUILD=rustc
 export CARGOFLAGS=
 export DEBUG=
+export EXAMPLES=
 export PREPARE_COPY=1
 
 if [ ! "$(uname -s)" = "Redox" ]
@@ -355,6 +356,7 @@ function op {
             op $1 unstage
             mkdir -p stage
             stage="$(realpath stage)"
+            source="$(realpath source)"
             pushd build > /dev/null
             skip=0
             if [ "$(type -t recipe_stage)" = "function" ]
@@ -372,15 +374,15 @@ function op {
                 fi
 
                 bins="$(find target/$TARGET/$build/ -maxdepth 1 -type f ! -name '*.*')"
-                if [ -z "$bins" ]
+                if [ -z "$bins" ] || [ "$EXAMPLES" == 1 ]
                 then
                     example=true
-                    bins="$(find target/$TARGET/$build/examples/ -maxdepth 1 -type f ! -name '*.*' ! -name '*-*' \
+                    bins="$bins $(find target/$TARGET/$build/examples/ -maxdepth 1 -type f ! -name '*.*' ! -name '*-*' \
                             2> /dev/null || true)"
                 fi
                 if [ -n "$bins" ]
                 then
-                    if [ -n "$example" ]
+                    if [ -n "$example" ] && [ "$EXAMPLES" != 1 ]
                     then
                         echo "$(tput bold)Note$(tput sgr0): No binaries detected, using example binaries"
                     fi
@@ -398,7 +400,7 @@ function op {
                     echo "$(tput bold)Warning$(tput sgr0): Recipe does not have any binaries" >&2
                 fi
 
-                docgen ../source ../stage/ref
+                docgen "$source" "$stage/ref"
             fi
             popd > /dev/null
             ;;
-- 
GitLab