From 352a3fe5472dedc39fed4e6bf7bf43257de7c0f9 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 24 Sep 2020 12:20:25 +0200 Subject: [PATCH] kaleidoscope-builder: Allow overriding CXX, CC, AR, etc Signed-off-by: Gergely Nagy --- bin/kaleidoscope-builder | 10 ++++++++-- etc/kaleidoscope-builder.conf | 20 ++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index 6d254ce7..3cc695be 100755 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -379,6 +379,10 @@ compile () { fi fi + _CMD_CXX="${CXX:-${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}${COMPILER_SUFFIX}}" + _CMD_CC="${CC:-${COMPILER_PREFIX}${C_COMPILER_BASENAME}${COMPILER_SUFFIX}}" + _CMD_AR="${AR:-${COMPILER_PREFIX}${AR_BASENAME}${COMPILER_SUFFIX}}" + # SC2091: We do not care if quotes or backslashes are not respected. # SC2086: We want word splitting. # shellcheck disable=SC2086,SC2090 @@ -401,8 +405,10 @@ compile () { -built-in-libraries "${ARDUINO_PATH}/libraries" \ -prefs "compiler.cpp.extra_flags=${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}" \ + -prefs "compiler.c.cmd=${_CMD_CC}" \ + -prefs "compiler.cpp.cmd=${_CMD_CXX}" \ + -prefs "compiler.ar.cmd=${_CMD_AR}" \ + -prefs "compiler.c.elf.cmd=${_CMD_CXX}" \ $CCACHE_ENABLE \ -warnings all \ ${ARDUINO_VERBOSE} \ diff --git a/etc/kaleidoscope-builder.conf b/etc/kaleidoscope-builder.conf index 05326307..72cedfa3 100644 --- a/etc/kaleidoscope-builder.conf +++ b/etc/kaleidoscope-builder.conf @@ -23,9 +23,10 @@ if [ "${ARCH}" = "virtual" ]; then # Set the compiler path for virtual builds # if [ -z "${COMPILER_PATH}" ]; then - COMPILER_PATH="/usr/bin" - COMPILER_PREFIX="" + COMPILER_PATH="/usr/bin/" fi + + COMPILER_PREFIX="" else ARCH="avr" fi @@ -150,6 +151,12 @@ if [ "${uname_S}" = "Darwin" ]; then fi } + if [ "${ARCH}" = "virtual" ]; then + COMPILER_PREFIX="x86_64-apple-darwin19-" + COMPILER_SUFFIX="-10" + AR_BASENAME="gcc-ar" + fi + elif [ "${uname_S}" = "FreeBSD" ]; then find_device_port() { @@ -168,6 +175,7 @@ elif [ "${uname_S}" = "FreeBSD" ]; then AVR_OBJDUMP="${AVR_OBJDUMP:-/usr/local/bin/avr-objdump}" AVRDUDE="${AVRDUDE:-/usr/local/bin/avrdude}" AVRDUDE_CONF="${AVRDUDE_CONF:-/usr/local/etc/avrdude.conf}" + ARDUINO_BUILDER="${ARDUINO_BUILDER:-/usr/local/bin/arduino-builder}" find_bootloader_ports() { DIR=$(dirname "$0") @@ -175,6 +183,10 @@ elif [ "${uname_S}" = "FreeBSD" ]; then DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER})" } + if [ "${ARCH}" = "virtual" ]; then + COMPILER_PATH="${COMPILER_PATH:-/usr/local/bin/}" + fi + elif [ "${uname_O}" = "Cygwin" ]; then # The Windows arduino-builder.exe doesn't understand being told to exec against Cygwin symlinks CCACHE_NOT_SUPPORTED=1 @@ -248,8 +260,12 @@ ARDUINO_IDE_VERSION="10607" # Allow the compiler path to be empty for virtual builds COMPILER_PATH="${COMPILER_PATH-${ARDUINO_TOOLS_PATH}/avr/bin/}" +COMPILER_SUFFIX="" + C_COMPILER_BASENAME=$(basename ${CC:-gcc}) CXX_COMPILER_BASENAME=$(basename ${CXX:-g++}) +AR_BASENAME=$(basename ${AR:-ar}) +OBJCOPY_BASENAME=$(basename ${OBJCOPY:-objcopy}) # Allow the compiler prefix to be empty for virtual builds COMPILER_PREFIX="${COMPILER_PREFIX-avr-}"