Make sure that script copied out of tree is smallest possible

This commit is contained in:
deadwood 2020-12-03 20:57:56 +01:00
parent 8eb1d9ff31
commit b28f1e8848
2 changed files with 75 additions and 69 deletions

73
scripts/rebuild-inc Normal file
View File

@ -0,0 +1,73 @@
# Variables
# TOOLCHAIN_DIR -> directory where toolchain will be installed or used from
# TOOLCHAIN_BUILD -> if yes, we are building toolchain
# PORTS_DIR -> directory where ports sources will be placed for re-use
# CONFIGURE_OPTS -> additional options passed to "configure"
# CONFIGURE_TARGET -> AROS build system style target
# BUILD_DIR -> directory where build output will be placed
# MAKE_TARGET -> "make" target to build
# MAKE_TARGET_2 -> second "make" target to build
# Note: each valid selection has to set TOOLCHAIN_DIR, BUILD_DIR and
# CONFIGURE_TARGET at minimum in process_selection()
TOOLCHAIN_BUILD=no
PORTS_DIR=$(pwd)/portssources
CONFIGURE_OPTS=""
source $(pwd)/AROS/scripts/rebuild-conf
main ()
{
printf "rebuild v1.8, select an option:\n"
printf " 0) exit\n"
show_selection
read input
if [[ $input = 0 ]]; then
exit 0
fi
process_selection $input
if [ -z $TOOLCHAIN_DIR ]; then
printf "Toolchain directory not set. Exiting\n"
exit 0
fi
# Listing directories
printf "Toolchain : "
printf $TOOLCHAIN_DIR
printf "\nBuild : "
printf $BUILD_DIR
printf "\nPorts sources : "
printf $PORTS_DIR
printf "\n"
sleep 3
rm -rf $BUILD_DIR
mkdir $BUILD_DIR
# Delete toolchain directory only if toolchain is being build
if [ $TOOLCHAIN_BUILD = yes ]; then
rm -rf $TOOLCHAIN_DIR
mkdir $TOOLCHAIN_DIR
fi
# Main build
cd $BUILD_DIR
../AROS/configure --target=$CONFIGURE_TARGET --with-aros-toolchain-install=$TOOLCHAIN_DIR --with-portssources=$PORTS_DIR $CONFIGURE_OPTS
make $MAKE_TARGET -j 3
local MAKE_STATUS=$?
if [[ $MAKE_STATUS = 0 ]] && [[ -n $MAKE_TARGET_2 ]]; then
make $MAKE_TARGET_2 -j 3
MAKE_STATUS=$?
fi
cd ..
# Delete build directory if toolchain is being build and there were no errors
if [[ $MAKE_STATUS = 0 ]] && [[ $TOOLCHAIN_BUILD = yes ]]; then
rm -rf $BUILD_DIR
fi
}

View File

@ -1,22 +1,5 @@
#!/bin/bash
# Variables
# TOOLCHAIN_DIR -> directory where toolchain will be installed or used from
# TOOLCHAIN_BUILD -> if yes, we are building toolchain
# PORTS_DIR -> directory where ports sources will be placed for re-use
# CONFIGURE_OPTS -> additional options passed to "configure"
# CONFIGURE_TARGET -> AROS build system style target
# BUILD_DIR -> directory where build output will be placed
# MAKE_TARGET -> "make" target to build
# MAKE_TARGET_2 -> second "make" target to build
# Note: each valid selection has to set TOOLCHAIN_DIR, BUILD_DIR and
# CONFIGURE_TARGET at minimum in process_selection()
TOOLCHAIN_BUILD=no
PORTS_DIR=$(pwd)/portssources
CONFIGURE_OPTS=""
check_location ()
{
if [[ ! -d $(pwd)/AROS/scripts ]]; then
@ -26,58 +9,8 @@ check_location ()
fi
}
source $(pwd)/AROS/scripts/rebuild-conf
source $(pwd)/AROS/scripts/rebuild-inc
check_location
printf "rebuild.sh v1.6, select an option:\n"
printf " 0) exit\n"
show_selection
read input
if [[ $input = 0 ]]; then
exit 0
fi
process_selection $input
if [ -z $TOOLCHAIN_DIR ]; then
printf "Toolchain directory not set. Exiting\n"
exit 0
fi
# Listing directories
printf "Toolchain : "
printf $TOOLCHAIN_DIR
printf "\nBuild : "
printf $BUILD_DIR
printf "\nPorts sources : "
printf $PORTS_DIR
printf "\n"
sleep 3
rm -rf $BUILD_DIR
mkdir $BUILD_DIR
# Delete toolchain directory only if toolchain is being build
if [ $TOOLCHAIN_BUILD = yes ]; then
rm -rf $TOOLCHAIN_DIR
mkdir $TOOLCHAIN_DIR
fi
# Main build
cd $BUILD_DIR
../AROS/configure --target=$CONFIGURE_TARGET --with-aros-toolchain-install=$TOOLCHAIN_DIR --with-portssources=$PORTS_DIR $CONFIGURE_OPTS
make $MAKE_TARGET -j 3
MAKE_STATUS=$?
if [[ $MAKE_STATUS = 0 ]] && [[ -n $MAKE_TARGET_2 ]]; then
make $MAKE_TARGET_2 -j 3
MAKE_STATUS=$?
fi
cd ..
# Delete build directory if toolchain is being build and there were no errors
if [[ $MAKE_STATUS = 0 ]] && [[ $TOOLCHAIN_BUILD = yes ]]; then
rm -rf $BUILD_DIR
fi
main