From f47cc034bd5811dda053464a85453a2c2a87f99e Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Tue, 20 May 2025 13:24:36 -0400 Subject: [PATCH] improve build ergonomics for consumers This allows consumers to directly set a few key env variables, which are necessary for producing usable binary builds. --- CMakeLists.txt | 2 +- build.sh | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0190c0..6488376 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ add_test( ) #-- spectator library -add_library(spectator +add_library(spectator SHARED "spectator/logger.cc" "spectator/publisher.cc" "spectator/config.h" diff --git a/build.sh b/build.sh index fcedf35..af7998f 100755 --- a/build.sh +++ b/build.sh @@ -4,16 +4,21 @@ set -e # usage: ./build.sh [clean|clean --confirm|skiptest] -BUILD_DIR=cmake-build -# Choose: Debug, Release, RelWithDebInfo and MinSizeRel. Use Debug for asan checking locally. -BUILD_TYPE=Debug +if [[ -z "$BUILD_DIR" ]]; then + BUILD_DIR="cmake-build" +fi + +if [[ -z "$BUILD_TYPE" ]]; then + # Choose: Debug, Release, RelWithDebInfo and MinSizeRel. Use Debug for asan checking locally. + BUILD_TYPE="Debug" +fi BLUE="\033[0;34m" NC="\033[0m" if [[ "$1" == "clean" ]]; then echo -e "${BLUE}==== clean ====${NC}" - rm -rf $BUILD_DIR + rm -rf "$BUILD_DIR" rm -f spectator/*.inc if [[ "$2" == "--confirm" ]]; then # remove all packages from the conan cache, to allow swapping between Release/Debug builds @@ -22,8 +27,10 @@ if [[ "$1" == "clean" ]]; then fi if [[ "$OSTYPE" == "linux-gnu"* ]]; then - export CC=gcc-13 - export CXX=g++-13 + if [[ -z "$CC" || -z "$CXX" ]]; then + export CC=gcc-13 + export CXX=g++-13 + fi fi if [[ ! -f "$HOME/.conan2/profiles/default" ]]; then