From c0e0ca10346fc3c92f2e76c19085f7a1d4e3318a Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Thu, 5 Dec 2019 11:17:55 +0100 Subject: [PATCH] Enable compiler specification via env. var. CC/CXX Many build systems allow C and C++ compilers to be specified via environment variables C and CXX. This commit enables this for kaleidoscope-builder. Furtheron, on unixoid systems virtual builds are possible through a command line similar to CXX= C= ARCH=virtual make Signed-off-by: Florian Fleissner --- bin/kaleidoscope-builder | 10 ++++++---- etc/kaleidoscope-builder.conf | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index 2a9829d1..45fa1873 100755 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -62,12 +62,12 @@ enable_ccache () { mkdir -p "$CCACHE_WRAPPER_PATH" fi - if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}gcc" ]; then - ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}gcc" + if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${C_COMPILER_BASENAME}" ]; then + ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${C_COMPILER_BASENAME}" fi - if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}g++" ]; then - ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}g++" + if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}" ]; then + ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}" fi if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}nm" ]; then @@ -305,6 +305,8 @@ compile () { -built-in-libraries "${ARDUINO_PATH}/libraries" \ -prefs "compiler.cpp.extra_flags=-std=c++11 -Woverloaded-virtual -Wno-unused-parameter -Wno-unused-variable -Wno-ignored-qualifiers ${ARDUINO_CFLAGS} ${LOCAL_CFLAGS}" \ -prefs compiler.path=${COMPILER_PATH} \ + -prefs "compiler.c.cmd=${COMPILER_PREFIX}${C_COMPILER_BASENAME}" \ + -prefs "compiler.cpp.cmd=${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}" \ $CCACHE_ENABLE \ -warnings all \ ${ARDUINO_VERBOSE} \ diff --git a/etc/kaleidoscope-builder.conf b/etc/kaleidoscope-builder.conf index 9dd94561..b1f180b6 100644 --- a/etc/kaleidoscope-builder.conf +++ b/etc/kaleidoscope-builder.conf @@ -234,6 +234,9 @@ ARDUINO_IDE_VERSION="10607" # Allow the compiler path to be empty for virtual builds COMPILER_PATH="${COMPILER_PATH-${ARDUINO_TOOLS_PATH}/avr/bin/}" +C_COMPILER_BASENAME=$(basename ${CC:-gcc}) +CXX_COMPILER_BASENAME=$(basename ${CXX:-g++}) + # Allow the compiler prefix to be empty for virtual builds COMPILER_PREFIX="${COMPILER_PREFIX-avr-}" AVR_SIZE="${AVR_SIZE:-${COMPILER_PATH}/${COMPILER_PREFIX}size}" @@ -242,8 +245,8 @@ AVR_OBJDUMP="${AVR_OBJDUMP:-${COMPILER_PATH}/${COMPILER_PREFIX}objdump}" AVR_OBJCOPY="${AVR_OBJCOPY:-${COMPILER_PATH}/${COMPILER_PREFIX}objcopy}" AVR_NM="${AVR_NM:-${COMPILER_PATH}/${COMPILER_PREFIX}nm}" AVR_AR="${AVR_AR:-${COMPILER_PATH}/${COMPILER_PREFIX}ar}" -AVR_GCC="${AVR_GCC:-${COMPILER_PATH}/${COMPILER_PREFIX}gcc}" -AVR_GPLUSPLUS="${AVR_GCC:-${COMPILER_PATH}/${COMPILER_PREFIX}g++}" +AVR_GCC="${AVR_GCC:-${COMPILER_PATH}/${COMPILER_PREFIX}${C_COMPILER_BASENAME}}" +AVR_GPLUSPLUS="${AVR_GCC:-${COMPILER_PATH}/${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}}"