From 3ff91e9d31a79c889001e1655f0b0362c95f0178 Mon Sep 17 00:00:00 2001 From: matekelemen Date: Thu, 5 Oct 2023 01:20:25 +0200 Subject: [PATCH] improve bash build scripts --- build.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index 39a0e09..da80f77 100755 --- a/build.sh +++ b/build.sh @@ -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 @@ -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)" @@ -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 @@ -143,6 +144,7 @@ if [ $package -eq 1 ]; then ninja package ninja package_source else + echo make package make package make package_source fi