Newer
Older

Jeremy Soller
committed
source config.sh

Jeremy Soller
committed
export BINDIR=bin
export CARGOFLAGS=
if [ ! "$(uname -s)" = "Redox" ]
then
function pkg {
CC=cc cargo run --release --manifest-path "$ROOT/pkgutils/Cargo.toml" --bin pkg -- $@
}
fi
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
}
then
echo -e "\033[01;38;5;215mcook - $1 $2\033[0m" >&2
fi
op $1 build
op $1 stage
op $1 tar
;;
distclean)
op $1 untar
op $1 unstage
skip=0
if [ "$(type -t recipe_fetch)" = "function" ]
then
recipe_fetch
fi
if [ "$skip" -eq "0" ]
if [ ! -f source.tar ]
then
wget "$TAR" -O source.tar
fi
if [ ! -d source ]
then
mkdir source
tar xvf source.tar -C source --strip-components 1
fi
elif [ -n "$GIT" ]
if [ -n "$BRANCH" ]
then
git clone --recursive "$GIT" -b "$BRANCH" source
else
git clone --recursive "$GIT" source
fi
pushd source > /dev/null
git pull
git submodule sync
git submodule update --init --recursive
popd > /dev/null
fi
update)
pushd source > /dev/null
skip=0
if [ "$(type -t recipe_update)" = "function" ]
then
recipe_update
fi
if [ "$skip" -eq "0" ]
then
xargo update
fi
popd > /dev/null
;;
rm -rf sysroot
mkdir sysroot
if [ ${#BUILD_DEPENDS} -gt 0 ]
then
./repo.sh "${BUILD_DEPENDS[@]}"
popd
for i in "${BUILD_DEPENDS[@]}"
pkg --target=$TARGET install --root sysroot "$REPO/$i.tar.gz"
cp -rp source build
for patch in *.patch
do
patch -p1 -d build < "$patch"
done
if [ "$(type -t recipe_version)" = "function" ]
fi
if [ "$skip" -eq "0" ]
cargo config package.version | tr -d '"'
gitversion)
if [ -d build/.git ]
then
echo "$(op $1 version)-$(git -C build rev-parse --short HEAD)"
else
op $1 version
fi
;;
if [ "$(type -t recipe_build)" = "function" ]
then
release_flag="--release"
then
release_flag=
fi
if [ "$skip" -eq "0" ]
then
xargo build --target "$TARGET" $release_flag $CARGOFLAGS
test)
pushd build > /dev/null
if [ "$(type -t recipe_test)" = "function" ]
then
release_flag="--release"
then
release_flag=
fi
if [ "$skip" -eq "0" ]
then
xargo test --no-run --target "$TARGET" $release_flag $CARGOFLAGS
if [ "$(type -t recipe_clean)" = "function" ]
then
fi
if [ "$skip" -eq "0" ]
then
xargo clean
fi
if [ "$(type -t recipe_stage)" = "function" ]
then

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

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

Jeremy Soller
committed
mkdir -p "../stage/$BINDIR"
if [ "$DEBUG" == 1 ]
then
cp -v "$bin" "../stage/$BINDIR/$(basename $bin)"
strip -v "$bin" -o "../stage/$BINDIR/$(basename $bin)"
echo "name = \"$1\"" > "stage.toml"
echo "version = \"$(op $1 version)\"" >> "stage.toml"
echo "target = \"$TARGET\"" >> "stage.toml"
mkdir -p stage/pkg
cp -v stage.toml "stage/pkg/$1.toml"
pkg --target=$TARGET create stage
cp -v stage.sig "$REPO/$1.sig"
cp -v stage.toml "$REPO/$1.toml"
rm -rfv "$REPO/$1.tar.gz" "$REPO/$1.sig" "$REPO/$1.toml"
if [ -d "$ROOT/recipes/$1" ]
if [ "$arg" == "--debug" ]
then
else
ops[${#ops[@]}]="$arg"
fi
done
for i in "${ops[@]}"
do
op "$1" "$i"