Skip to content

Commit

Permalink
improve bash build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
matekelemen committed Oct 4, 2023
1 parent e49d589 commit 3ff91e9
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ while getopts "hpt:b:i:c:o:" arg; do
cmakeArguments="$cmakeArguments;$OPTARG"
;;
\?) # Unrecognized argument
echo "Error: unrecognized argument $arg"
exit 1;;
print_help
echo "Error: unrecognized argument -$OPTARG"
exit 1
;;
esac
done

Expand All @@ -85,8 +87,8 @@ case "$(uname -s)" in
toolchainBin="${toolchainRoot}/bin"
toolchainLib="${toolchainRoot}/lib"
toolchainInclude="${toolchainRoot}/include"
cc="$toolchainBin/clang"
cxx="$toolchainBin/clang++"
export cc="$toolchainBin/clang"
export cxx="$toolchainBin/clang++"
;;
\?)
echo "Error: unsupported OS $(uname -s)"
Expand Down Expand Up @@ -120,19 +122,18 @@ if ! cmake \
"-G${generator}" \
"-DCMAKE_C_COMPILER:STRING=$cc" \
"-DCMAKE_CXX_COMPILER:STRING=$cxx" \
"-DCMAKE_BUILD_TYPE:STRING=$buildType" \
"-DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON" \
"-D${projectNameUpper}_BUILD_SHARED_LIBRARY:BOOL=ON" \
"-D${projectNameUpper}_BUILD_TESTS:BOOL=ON" \
"$cCacheFlag" \
$(echo $cmakeArguments | tr '\;' '\n') \
; then
exit $?
exit 1
fi

# Build and install
if ! cmake --build "$buildDir" --target install -j; then
exit $?
if ! cmake --build "$buildDir" --config "$buildType" --target install -j; then
exit 1
fi

# Package
Expand All @@ -143,6 +144,7 @@ if [ $package -eq 1 ]; then
ninja package
ninja package_source
else
echo make package
make package
make package_source
fi
Expand Down

0 comments on commit 3ff91e9

Please sign in to comment.