Skip to content

Commit 158cdff

Browse files
authored
Merge pull request #73 from ids1024/debug-mode
Add --debug argument to cook.sh to build in debug mode, unstripped
2 parents d12d150 + f18c0f6 commit 158cdff

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

cook.sh

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,17 @@ function op {
169169
then
170170
recipe_build
171171
fi
172+
173+
release_flag="--release"
174+
if [ "$cargo_build_debug_mode" == 1 ]
175+
then
176+
release_flag=
177+
fi
178+
172179
if [ "$skip" -eq "0" ]
173180
then
174181
cp -r "$ROOT/Xargo.toml" .
175-
xargo build --target "$TARGET" --release $CARGOFLAGS
182+
xargo build --target "$TARGET" $release_flag $CARGOFLAGS
176183
fi
177184
popd > /dev/null
178185
;;
@@ -183,10 +190,17 @@ function op {
183190
then
184191
recipe_test
185192
fi
193+
194+
release_flag="--release"
195+
if [ "$cargo_build_debug_mode" == 1 ]
196+
then
197+
release_flag=
198+
fi
199+
186200
if [ "$skip" -eq "0" ]
187201
then
188202
cp -r "$ROOT/Xargo.toml" .
189-
xargo test --no-run --target "$TARGET" --release $CARGOFLAGS
203+
xargo test --no-run --target "$TARGET" $release_flag $CARGOFLAGS
190204
fi
191205
popd > /dev/null
192206
;;
@@ -215,13 +229,24 @@ function op {
215229
if [ "$skip" -eq "0" ]
216230
then
217231
#TODO xargo install --root "../stage" $CARGOFLAGS
218-
bins="$(find target/$TARGET/release/ -maxdepth 1 -type f ! -name '*.*')"
232+
if [ "$cargo_build_debug_mode" == 1 ]
233+
then
234+
build=debug
235+
else
236+
build=release
237+
fi
238+
bins="$(find target/$TARGET/$build/ -maxdepth 1 -type f ! -name '*.*')"
219239
if [ -n "$bins" ]
220240
then
221241
mkdir -p "../stage/$BINDIR"
222242
for bin in $bins
223243
do
224-
strip -v "$bin" -o "../stage/$BINDIR/$(basename $bin)"
244+
if [ "$cargo_build_debug_mode" == 1 ]
245+
then
246+
cp -v "$bin" "../stage/$BINDIR/$(basename $bin)"
247+
else
248+
strip -v "$bin" -o "../stage/$BINDIR/$(basename $bin)"
249+
fi
225250
done
226251
fi
227252
fi
@@ -262,9 +287,22 @@ then
262287
then
263288
cd "$ROOT/recipes/$1"
264289
source recipe.sh
290+
291+
ops=()
292+
cargo_build_debug_mode=
265293
for arg in "${@:2}"
266294
do
267-
op "$1" "$arg"
295+
if [ "$arg" == "--debug" ]
296+
then
297+
cargo_build_debug_mode=1
298+
else
299+
ops[${#ops[@]}]="$arg"
300+
fi
301+
done
302+
303+
for i in "${ops[@]}"
304+
do
305+
op "$1" "$i"
268306
done
269307
else
270308
echo "cook.sh: recipe '$1' not found" >&2

0 commit comments

Comments
 (0)