Newer
Older

Jeremy Soller
committed
#!/bin/bash
export CC="$ROOT/libc-artifacts/gcc.sh"
# Variables to be overriden by recipes

Jeremy Soller
committed
export BINDIR=bin
export CARGOFLAGS=
function usage {
echo "cook.sh $1 <op>" >&2
echo " dist" >&2
echo " distclean" >&2
echo " build" >&2
echo " clean" >&2
echo " fetch" >&2
echo " unfetch" >&2
echo " publish" >&2
echo " unpublish" >&2
echo " stage" >&2
echo " unstage" >&2
echo " tar" >&2
echo " untar" >&2
echo " update" >&2
echo " version" >&2
}
echo -e "\033[01;38;5;215mcook - $1 $2\033[0m" >&2
dist)
op $1 fetch
op $1 update
op $1 build
op $1 stage
op $1 tar
;;
distclean)
op $1 untar
op $1 unstage
op $1 unfetch
;;
wget "$TAR" -O source.tar
fi
if [ ! -d source ]
then
mkdir source
tar xvf source.tar -C source --strip-components 1
fi
rm -rf build
cp -r source build
elif [ -n "$GIT" ]
then
if [ ! -d source ]
git pull
git submodule sync
git submodule update --init --recursive
popd > /dev/null
if [ "$(type -t recipe_version)" = "function" ]
fi
if [ "$skip" -eq "0" ]
cargo config package.version | tr -d '"'
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
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
test)
pushd build > /dev/null
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
skip="0"
if [ "$(type -t recipe_clean)" = "function" ]
then
recipe_clean || skip="1"
fi
if [ "$skip" -eq "0" ]
then
xargo clean
fi
if [ "$(type -t recipe_stage)" = "function" ]
then
recipe_stage ../stage || skip="1"

Jeremy Soller
committed
fi
if [ "$skip" -eq "0" ]

Jeremy Soller
committed
then
#TODO xargo install --root "../stage" $CARGOFLAGS
bins="$(find target/$TARGET/release/ -maxdepth 1 -type f ! -name '*.*')"
if [ -n "$bins" ]
then

Jeremy Soller
committed
mkdir -p "../stage/$BINDIR"

Jeremy Soller
committed
cp -v "$bin" "../stage/$BINDIR/$(basename $bin)"
strip -v "../stage/$BINDIR/$(basename $bin)"
rm -rfv stage.tar
;;
publish)
mkdir -p "$REPO"
cp -v stage.tar "$REPO/$1.tar"
;;
unpublish)
rm -rfv "$REPO/$1.tar"