build(mk): updated auto build script
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -72,3 +72,4 @@ output/
|
|||||||
|
|
||||||
.boost_installed
|
.boost_installed
|
||||||
4DSSE_logs/
|
4DSSE_logs/
|
||||||
|
.last_build_flags
|
||||||
|
|||||||
104
mk
104
mk
@@ -5,9 +5,11 @@ set -e
|
|||||||
# --- Defaults ---
|
# --- Defaults ---
|
||||||
userFlag=0
|
userFlag=0
|
||||||
testsFlag=0
|
testsFlag=0
|
||||||
|
runTestsFlag=0
|
||||||
buildDir="build"
|
buildDir="build"
|
||||||
installDir="$HOME/.local/4DSSE"
|
installDir="$HOME/.local/4DSSE"
|
||||||
|
|
||||||
|
|
||||||
# --- Help Menu ---
|
# --- Help Menu ---
|
||||||
show_help() {
|
show_help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
@@ -15,7 +17,8 @@ Usage: $(basename "$0") [OPTIONS]
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
--user Build and Install as a release for. Intended for end users.
|
--user Build and Install as a release for. Intended for end users.
|
||||||
--tests Build and run tests.
|
--noBuildTest Do not build tests.
|
||||||
|
--runTest Run tests.
|
||||||
--buildDir Specify the build directory. Default is "${buildDir}".
|
--buildDir Specify the build directory. Default is "${buildDir}".
|
||||||
--installDir Specify the install directory. Default is "${installDir}".
|
--installDir Specify the install directory. Default is "${installDir}".
|
||||||
-h, --help Show this help message and exit
|
-h, --help Show this help message and exit
|
||||||
@@ -39,10 +42,14 @@ while [[ $# -gt 0 ]]; do
|
|||||||
userFlag=1
|
userFlag=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--tests)
|
--noTest)
|
||||||
testsFlag=1
|
testsFlag=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--runTest)
|
||||||
|
runTestsFlag=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--buildDir)
|
--buildDir)
|
||||||
buildDir=1
|
buildDir=1
|
||||||
shift
|
shift
|
||||||
@@ -67,6 +74,7 @@ RED="\033[0;31m"
|
|||||||
GREEN="\033[0;32m"
|
GREEN="\033[0;32m"
|
||||||
YELLOW="\033[0;33m"
|
YELLOW="\033[0;33m"
|
||||||
BLUE="\033[0;34m"
|
BLUE="\033[0;34m"
|
||||||
|
MAGENTA="\033[0;35m"
|
||||||
NC="\033[0m" # No Color
|
NC="\033[0m" # No Color
|
||||||
|
|
||||||
# Log file.
|
# Log file.
|
||||||
@@ -75,7 +83,7 @@ if [[ ! -d "$LOGDIR" ]]; then
|
|||||||
echo -e "${BLUE}[Info] Creating log directory...${NC}"
|
echo -e "${BLUE}[Info] Creating log directory...${NC}"
|
||||||
mkdir "$LOGDIR"
|
mkdir "$LOGDIR"
|
||||||
else
|
else
|
||||||
echo -e "${BLUE}[Info] Log directory already exists. Skipping...${NC}"
|
echo -e "${MAGENTA}[Succsess] Log directory already exists. Skipping...${NC}"
|
||||||
fi
|
fi
|
||||||
LOGFILE="${LOGDIR}/4DSSE-install-log.txt"
|
LOGFILE="${LOGDIR}/4DSSE-install-log.txt"
|
||||||
|
|
||||||
@@ -97,6 +105,16 @@ if [[ -f "$LOGFILE" ]]; then
|
|||||||
fi
|
fi
|
||||||
touch "$LOGFILE"
|
touch "$LOGFILE"
|
||||||
|
|
||||||
|
# --- Check if MESON is installed ---
|
||||||
|
log "${BLUE}[Info] Checking if Meson is installed...${NC}"
|
||||||
|
if ! command -v meson &> /dev/null; then
|
||||||
|
log "${RED}[Error] Meson is not installed. Exiting...${NC}"
|
||||||
|
log "${YELLOW}[Info] Please install Meson and try again.${NC}"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
log "${MAGENTA}[Success] Meson is installed. Continuing...${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
# --- Build 4DSSE ---
|
# --- Build 4DSSE ---
|
||||||
log "${BLUE}[Info] Building 4DSSE...${NC}"
|
log "${BLUE}[Info] Building 4DSSE...${NC}"
|
||||||
if [[ $userFlag -eq 1 ]]; then
|
if [[ $userFlag -eq 1 ]]; then
|
||||||
@@ -105,7 +123,7 @@ else
|
|||||||
log "${BLUE}[Info] Installing 4DSSE for developers...${NC}"
|
log "${BLUE}[Info] Installing 4DSSE for developers...${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $testsFlag -eq 1 ]]; then
|
if [[ $testsFlag -eq 0 ]]; then
|
||||||
log "${BLUE}[Info] Building with tests...${NC}"
|
log "${BLUE}[Info] Building with tests...${NC}"
|
||||||
else
|
else
|
||||||
log "${BLUE}[Info] Building without tests...${NC}"
|
log "${BLUE}[Info] Building without tests...${NC}"
|
||||||
@@ -115,7 +133,7 @@ fi
|
|||||||
log "${BLUE}[Info] Checking Boost status...${NC}"
|
log "${BLUE}[Info] Checking Boost status...${NC}"
|
||||||
# if the following script exists with anything other than a 0 status the script will exit
|
# if the following script exists with anything other than a 0 status the script will exit
|
||||||
if [[ -f ./build-config/boost/.boost_installed ]]; then
|
if [[ -f ./build-config/boost/.boost_installed ]]; then
|
||||||
log "${BLUE}[Info] Boost already installed. Skipping...${NC}"
|
log "${MAGENTA}[Succsess] Boost already installed. Skipping...${NC}"
|
||||||
else
|
else
|
||||||
log "${BLUE}[Info] Installing Boost...${NC}"
|
log "${BLUE}[Info] Installing Boost...${NC}"
|
||||||
if ! ./build-config/boost/install.sh; then
|
if ! ./build-config/boost/install.sh; then
|
||||||
@@ -127,21 +145,62 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Check if the build dir has been configured with the correct flags ---
|
#check if the last build flags are the same as the current build flags
|
||||||
log "${BLUE}[Info] Configuring build directory...${NC}"
|
# if the flags are the same skip the configuration step
|
||||||
if [ -f "$buildDir/build.ninja" ]; then
|
# if they are different then reconfigure the build directory
|
||||||
log "${BLUE}[Info] Build directory already configured. Skipping...${NC}"
|
|
||||||
else
|
# do not use grep -oP as it is not POSIX compliant
|
||||||
if [[ $userFlag -eq 1 ]]; then
|
|
||||||
meson setup "$buildDir" -Duser_mode=true --buildtype=release
|
doReconfigure=1
|
||||||
|
|
||||||
|
log "${BLUE}[Info] Checking last build flags...${NC}"
|
||||||
|
if [[ -f $buildDir/.last_build_flags ]]; then
|
||||||
|
lastUserFlag=$(grep -Eo 'userFlag=[0-9]+' $buildDir/.last_build_flags | cut -d'=' -f2)
|
||||||
|
lastTestsFlag=$(grep -Eo 'testsFlag=[0-9]+' $buildDir/.last_build_flags | cut -d'=' -f2)
|
||||||
|
if [[ $lastUserFlag -eq $userFlag && $lastTestsFlag -eq $testsFlag ]]; then
|
||||||
|
log "${MAGENTA}[Succsess] Last build flags match current build flags. Skipping configuration...${NC}"
|
||||||
|
doReconfigure=0
|
||||||
else
|
else
|
||||||
if [[ $testsFlag -eq 1 ]]; then
|
log "${YELLOW}[Info] Last build flags do not match current build flags. Reconfiguring...${NC}"
|
||||||
meson setup "$buildDir" --buildtype=debug
|
rm -rf $buildDir
|
||||||
else
|
|
||||||
meson setup "$buildDir" --buildtype=debug -Dbuild_tests=false
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
log "${GREEN}[Success] Build directory configured successfully.${NC}"
|
else
|
||||||
|
log "${BLUE}[Info] Last build flags not found. Reconfiguring...${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# --- Check if the build dir has been configured with the correct flags ---
|
||||||
|
if [[ $doReconfigure -eq 1 ]]; then
|
||||||
|
log "${BLUE}[Info] Configuring build directory...${NC}"
|
||||||
|
if [ -f "$buildDir/build.ninja" ]; then
|
||||||
|
log "${MAGENTA}[Succsess] Build directory already configured. Skipping...${NC}"
|
||||||
|
else
|
||||||
|
if [[ $userFlag -eq 1 ]]; then
|
||||||
|
meson setup "$buildDir" -Duser_mode=true --buildtype=release
|
||||||
|
else
|
||||||
|
if [[ $testsFlag -eq 0 ]]; then
|
||||||
|
meson setup "$buildDir" --buildtype=debug
|
||||||
|
else
|
||||||
|
meson setup "$buildDir" --buildtype=debug -Dbuild_tests=false
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
log "${GREEN}[Success] Build directory configured successfully.${NC}"
|
||||||
|
fi
|
||||||
|
log "${BLUE}[Info] Caching last build flags...${NC}"
|
||||||
|
|
||||||
|
# --- Cache the last build flags ---
|
||||||
|
if [[ $userFlag -eq 1 ]]; then
|
||||||
|
echo "userFlag=1" > $buildDir/.last_build_flags
|
||||||
|
else
|
||||||
|
echo "userFlag=0" > $buildDir/.last_build_flags
|
||||||
|
fi
|
||||||
|
if [[ $testsFlag -eq 1 ]]; then
|
||||||
|
echo "testsFlag=1" >> $buildDir/.last_build_flags
|
||||||
|
else
|
||||||
|
echo "testsFlag=0" >> $buildDir/.last_build_flags
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "${GREEN}[Success] Last build flags cached.${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "${BLUE}[Info] Building 4DSSE...${NC}"
|
log "${BLUE}[Info] Building 4DSSE...${NC}"
|
||||||
@@ -150,10 +209,10 @@ meson compile -C "$buildDir"
|
|||||||
# --- Install 4DSSE ---
|
# --- Install 4DSSE ---
|
||||||
if [[ $userFlag -eq 1 ]]; then
|
if [[ $userFlag -eq 1 ]]; then
|
||||||
log "${BLUE}[Info] Installing 4DSSE in user mode...${NC}"
|
log "${BLUE}[Info] Installing 4DSSE in user mode...${NC}"
|
||||||
meson install -C "$buildDir" --no-rebuild --prefix="$installDir"
|
meson install -C "$buildDir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $testsFlag -eq 1 ]]; then
|
if [[ $runTestsFlag -eq 1 ]]; then
|
||||||
log "${BLUE}[Info] Running tests...${NC}"
|
log "${BLUE}[Info] Running tests...${NC}"
|
||||||
meson test -C "$buildDir"
|
meson test -C "$buildDir"
|
||||||
fi
|
fi
|
||||||
@@ -162,4 +221,7 @@ if [[ $userFlag -eq 1 ]]; then
|
|||||||
log "${GREEN}[Success] 4DSSE built and installed successfully.${NC}"
|
log "${GREEN}[Success] 4DSSE built and installed successfully.${NC}"
|
||||||
else
|
else
|
||||||
log "${GREEN}[Success] 4DSSE built successfully.${NC}"
|
log "${GREEN}[Success] 4DSSE built successfully.${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
log "${GREEN}[Success] 4DSSE mk script complete.${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user