kaleidoscope-builder fixed for builds of virtual hardware

This commit induces the following changes:

bin/kaleidoscope-builder

  * ccache dummy compiler and executables are now generated in a way
    that allows using the same CCACHE_WRAPPER_PATH for virtual and
    non-virtual builds

  * virtual builds are now triggered by either specifying the full FQBN with x86
    as architecture or by defining ARCH=x86

etc/kaleidoscope-builder.conf

  * COMPILER_PREFIX and COMPILER_PATH are now determined (if not predefined)
    based on ARCH or FQBN

Signed-off-by: Florian Fleissner <florian.fleissner@inpartik.de>
pull/640/head
Florian Fleissner 6 years ago committed by Jesse Vincent
parent 4ecf5f795e
commit 7326be589f

@ -58,23 +58,42 @@ build_filenames () {
enable_ccache () {
if [ "$(command -v ccache)" ]; then
if ! [ -d "$CCACHE_WRAPPER_PATH" ]; then
mkdir -p "$CCACHE_WRAPPER_PATH"
ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}gcc"
ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}g++"
ln -s "${AVR_NM}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}nm"
ln -s "${AVR_OBJCOPY}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}objcopy"
ln -s "${AVR_AR}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}ar"
ln -s "${AVR_SIZE}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}size"
fi
export CCACHE_PATH=${COMPILER_PATH}/
CCACHE_ENABLE="-prefs compiler.path=${CCACHE_WRAPPER_PATH}/"
if ! [ -d "$CCACHE_WRAPPER_PATH" ]; then
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"
fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}g++" ]; then
ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}g++"
fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}nm" ]; then
ln -s "${AVR_NM}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}nm"
fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}objcopy" ]; then
ln -s "${AVR_OBJCOPY}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}objcopy"
fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}ar" ]; then
ln -s "${AVR_AR}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}ar"
fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}size" ]; then
ln -s "${AVR_SIZE}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}size"
fi
export CCACHE_PATH=${COMPILER_PATH}/
CCACHE_ENABLE="-prefs compiler.path=${CCACHE_WRAPPER_PATH}/"
fi
}
firmware_size () {
if [ "${BOARD}" = "virtual" ]; then
if [ "${ARCH}" = "x86" ]; then
echo "[Size not computed for virtual build]"
return
fi
@ -245,7 +264,7 @@ compile () {
# We want literal backslashes here, not arrays.
ARDUINO_PACKAGES="-hardware \"${ARDUINO_PACKAGE_PATH}\""
fi
SAVED_BOARD="${BOARD}"
SAVED_FQBN="${FQBN}"
if [ -e "${SKETCH_DIR}/.kaleidoscope-builder.conf" ]; then
@ -253,8 +272,12 @@ compile () {
BOARD="$(. "${SKETCH_DIR}"/.kaleidoscope-builder.conf && echo "${BOARD}")"
# shellcheck disable=SC1090
FQBN="$(. "${SKETCH_DIR}"/.kaleidoscope-builder.conf && echo "${FQBN}")"
if [ "${SAVED_FQBN}" = "${FQBN}" ] || [ -z "${FQBN}" ]; then
FQBN="keyboardio:avr:${BOARD}"
if [ -n "${BOARD}" ]; then
if [ -z "${ARCH}" ]; then
FQBN="keyboardio:avr:${BOARD}"
else
FQBN="keyboardio:${ARCH}:${BOARD}"
fi
fi
fi

@ -12,10 +12,26 @@ LIBRARY="${LIBRARY:-${SKETCH}}"
BOARD="${BOARD:-model01}"
MCU="${MCU:-atmega32u4}"
if [ "${BOARD}" = "virtual" ]; then
if [ -z "${ARCH}" ]; then
ARCH=$(echo "${FQBN}" | sed -n -e 's/^[^:]\+:\([^:]\+\).*/\1/p')
fi
if [ "${ARCH}" = "x86" ]; then
FQBN="${FQBN:-keyboardio:x86:${BOARD}}"
# Set the compiler path for virtual builds (x86)
#
if [ -z "${COMPILER_PATH}" ]; then
COMPILER_PATH="/usr/bin"
COMPILER_PREFIX=""
fi
else
FQBN="${FQBN:-keyboardio:avr:${BOARD}}"
ARCH="avr"
fi
if [ -z "${FQBN}" ]; then
FQBN="${FQBN:-keyboardio:avr:${BOARD}}"
fi
########
@ -141,9 +157,11 @@ ARDUINO_IDE_VERSION="10607"
###### Executable paths
######
# Allow the compiler path to be empty for x86 builds
COMPILER_PATH="${COMPILER_PATH-${ARDUINO_TOOLS_PATH}/avr/bin/}"
COMPILER_PATH="${COMPILER_PATH:-${ARDUINO_TOOLS_PATH}/avr/bin/}"
COMPILER_PREFIX="${COMPILER_PREFIX:-avr-}"
# Allow the compiler prefix to be empty for x86 builds
COMPILER_PREFIX="${COMPILER_PREFIX-avr-}"
AVR_SIZE="${AVR_SIZE:-${COMPILER_PATH}/${COMPILER_PREFIX}size}"
AVR_SIZE_FLAGS="${AVR_SIZE_FLAGS:--C --mcu=${MCU}}"
AVR_OBJDUMP="${AVR_OBJDUMP:-${COMPILER_PATH}/${COMPILER_PREFIX}objdump}"

Loading…
Cancel
Save