wip: build tools stuff

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/851/head
Gergely Nagy 4 years ago
parent 637579b346
commit 0774f3fc2f
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -61,31 +61,31 @@ enable_ccache () {
if ! [ -d "$CCACHE_WRAPPER_PATH" ]; then if ! [ -d "$CCACHE_WRAPPER_PATH" ]; then
mkdir -p "$CCACHE_WRAPPER_PATH" mkdir -p "$CCACHE_WRAPPER_PATH"
fi fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${C_COMPILER_BASENAME}" ]; then if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${C_COMPILER_BASENAME}" ]; then
ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${C_COMPILER_BASENAME}" ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${C_COMPILER_BASENAME}"
fi fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}" ]; then if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}" ]; then
ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}" ln -s "$(command -v ccache)" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}"
fi fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}nm" ]; then if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}nm" ]; then
ln -s "${AVR_NM}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}nm" ln -s "${AVR_NM}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}nm"
fi fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}objcopy" ]; then if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}objcopy" ]; then
ln -s "${AVR_OBJCOPY}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}objcopy" ln -s "${AVR_OBJCOPY}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}objcopy"
fi fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}ar" ]; then if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}ar" ]; then
ln -s "${AVR_AR}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}ar" ln -s "${AVR_AR}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}ar"
fi fi
if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}size" ]; then if ! [ -h "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}size" ]; then
ln -s "${AVR_SIZE}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}size" ln -s "${AVR_SIZE}" "${CCACHE_WRAPPER_PATH}/${COMPILER_PREFIX}size"
fi fi
export CCACHE_PATH=${COMPILER_PATH}/ export CCACHE_PATH=${COMPILER_PATH}/
CCACHE_ENABLE="-prefs compiler.path=${CCACHE_WRAPPER_PATH}/" CCACHE_ENABLE="-prefs compiler.path=${CCACHE_WRAPPER_PATH}/"
fi fi
@ -163,16 +163,16 @@ prompt_before_flashing () {
flash () { flash () {
maybe_build "$@" maybe_build "$@"
# Check to see if we can see a keyboard bootloader port. # Check to see if we can see a keyboard bootloader port.
# If we -can-, then we should skip over the "reset to bootloader" thing # If we -can-, then we should skip over the "reset to bootloader" thing
find_bootloader_ports find_bootloader_ports
if [ -z "${DEVICE_PORT_BOOTLOADER}" ]; then if [ -z "${DEVICE_PORT_BOOTLOADER}" ]; then
prompt_before_flashing prompt_before_flashing
# This is defined in the (optional) user config. # This is defined in the (optional) user config.
# shellcheck disable=SC2154 # shellcheck disable=SC2154
${preFlash_HOOKS} ${preFlash_HOOKS}
# If we're -not- doing a manual reset, then try to do it automatically # If we're -not- doing a manual reset, then try to do it automatically
if [ -z "${MANUAL_RESET}" ]; then if [ -z "${MANUAL_RESET}" ]; then
reset_device reset_device
@ -195,7 +195,7 @@ flash () {
wait_for_bootloader_port() { wait_for_bootloader_port() {
declare -i tries declare -i tries
tries=15 tries=15
while [ "$tries" -gt 0 ] && [ -z "${DEVICE_PORT_BOOTLOADER}" ]; do while [ "$tries" -gt 0 ] && [ -z "${DEVICE_PORT_BOOTLOADER}" ]; do
sleep 1 sleep 1
printf "." printf "."
@ -204,12 +204,12 @@ wait_for_bootloader_port() {
# shellcheck disable=SC2004 # shellcheck disable=SC2004
tries=$(($tries-1)) tries=$(($tries-1))
done done
if [ "$tries" -gt 0 ]; then if [ "$tries" -gt 0 ]; then
echo "Found." echo "Found."
else else
echo "Timed out." echo "Timed out."
fi fi
} }
check_bootloader_port () { check_bootloader_port () {
@ -227,11 +227,11 @@ check_bootloader_port_and_flash () {
if ! check_bootloader_port; then if ! check_bootloader_port; then
return 1 return 1
fi fi
echo "Flashing your keyboard:" echo "Flashing your keyboard:"
# If the flash fails, try a second time # If the flash fails, try a second time
if ! flash_over_usb; then if ! flash_over_usb; then
sleep 2 sleep 2
if ! flash_over_usb; then if ! flash_over_usb; then
if [ "${ARDUINO_VERBOSE}" != "-verbose" ]; then if [ "${ARDUINO_VERBOSE}" != "-verbose" ]; then
@ -341,7 +341,7 @@ compile () {
enable_ccache enable_ccache
install -d "${OUTPUT_PATH}" install -d "${OUTPUT_PATH}"
SKETCH_DIR="$(find_sketch)" SKETCH_DIR="$(find_sketch)"
echo "Building ${SKETCH_DIR}/${SKETCH} ${LIB_VERSION} into ${OUTPUT_PATH}" echo "Building ${SKETCH_DIR}/${SKETCH} ${LIB_VERSION} into ${OUTPUT_PATH}"
@ -362,7 +362,7 @@ compile () {
# We want literal backslashes here, not arrays. # We want literal backslashes here, not arrays.
ARDUINO_PACKAGES="-hardware \"${ARDUINO_PACKAGE_PATH}\"" ARDUINO_PACKAGES="-hardware \"${ARDUINO_PACKAGE_PATH}\""
fi fi
SAVED_BOARD="${BOARD}" SAVED_BOARD="${BOARD}"
SAVED_FQBN="${FQBN}" SAVED_FQBN="${FQBN}"
if [ -e "${SKETCH_DIR}/.kaleidoscope-builder.conf" ]; then if [ -e "${SKETCH_DIR}/.kaleidoscope-builder.conf" ]; then
@ -379,6 +379,10 @@ compile () {
fi fi
fi fi
_CMD_CXX="${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}${COMPILER_SUFFIX}"
_CMD_CC="${COMPILER_PREFIX}${C_COMPILER_BASENAME}${COMPILER_SUFFIX}"
_CMD_AR="${COMPILER_PREFIX}${AR_BASENAME}${COMPILER_SUFFIX}"
# SC2091: We do not care if quotes or backslashes are not respected. # SC2091: We do not care if quotes or backslashes are not respected.
# SC2086: We want word splitting. # SC2086: We want word splitting.
# shellcheck disable=SC2086,SC2090 # shellcheck disable=SC2086,SC2090
@ -401,8 +405,9 @@ compile () {
-built-in-libraries "${ARDUINO_PATH}/libraries" \ -built-in-libraries "${ARDUINO_PATH}/libraries" \
-prefs "compiler.cpp.extra_flags=${ARDUINO_CFLAGS} ${LOCAL_CFLAGS}" \ -prefs "compiler.cpp.extra_flags=${ARDUINO_CFLAGS} ${LOCAL_CFLAGS}" \
-prefs "compiler.path=${COMPILER_PATH}" \ -prefs "compiler.path=${COMPILER_PATH}" \
-prefs "compiler.c.cmd=${COMPILER_PREFIX}${C_COMPILER_BASENAME}" \ -prefs "compiler.c.cmd=${_CMD_CC}" \
-prefs "compiler.cpp.cmd=${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}" \ -prefs "compiler.cpp.cmd=${_CMD_CXX}" \
-prefs "compiler.ar.cmd=${_CMD_AR}" \
$CCACHE_ENABLE \ $CCACHE_ENABLE \
-warnings all \ -warnings all \
${ARDUINO_VERBOSE} \ ${ARDUINO_VERBOSE} \
@ -605,7 +610,7 @@ usage () {
build-all build-all
Build all Sketches we can find. Build all Sketches we can find.
run-simulator-tests run-simulator-tests
Builds and runs all simulator tests. Builds and runs all simulator tests.
EOF EOF

@ -151,6 +151,12 @@ if [ "${uname_S}" = "Darwin" ]; then
fi fi
} }
if [ "${ARCH}" = "virtual" ]; then
COMPILER_PREFIX="x86_64-apple-darwin19-"
COMPILER_SUFFIX="-10"
AR_BASENAME="gcc-ar"
fi
elif [ "${uname_S}" = "FreeBSD" ]; then elif [ "${uname_S}" = "FreeBSD" ]; then
find_device_port() { find_device_port() {
@ -169,6 +175,7 @@ elif [ "${uname_S}" = "FreeBSD" ]; then
AVR_OBJDUMP="${AVR_OBJDUMP:-/usr/local/bin/avr-objdump}" AVR_OBJDUMP="${AVR_OBJDUMP:-/usr/local/bin/avr-objdump}"
AVRDUDE="${AVRDUDE:-/usr/local/bin/avrdude}" AVRDUDE="${AVRDUDE:-/usr/local/bin/avrdude}"
AVRDUDE_CONF="${AVRDUDE_CONF:-/usr/local/etc/avrdude.conf}" AVRDUDE_CONF="${AVRDUDE_CONF:-/usr/local/etc/avrdude.conf}"
ARDUINO_BUILDER="${ARDUINO_BUILDER:-/usr/local/bin/arduino-builder}"
find_bootloader_ports() { find_bootloader_ports() {
DIR=$(dirname "$0") DIR=$(dirname "$0")
@ -176,6 +183,10 @@ elif [ "${uname_S}" = "FreeBSD" ]; then
DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER})" DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER})"
} }
if [ "${ARCH}" = "virtual" ]; then
COMPILER_PATH="${COMPILER_PATH:-/usr/local/bin/}"
fi
elif [ "${uname_O}" = "Cygwin" ]; then elif [ "${uname_O}" = "Cygwin" ]; then
# The Windows arduino-builder.exe doesn't understand being told to exec against Cygwin symlinks # The Windows arduino-builder.exe doesn't understand being told to exec against Cygwin symlinks
CCACHE_NOT_SUPPORTED=1 CCACHE_NOT_SUPPORTED=1
@ -249,8 +260,12 @@ ARDUINO_IDE_VERSION="10607"
# Allow the compiler path to be empty for virtual builds # Allow the compiler path to be empty for virtual builds
COMPILER_PATH="${COMPILER_PATH-${ARDUINO_TOOLS_PATH}/avr/bin/}" COMPILER_PATH="${COMPILER_PATH-${ARDUINO_TOOLS_PATH}/avr/bin/}"
COMPILER_SUFFIX=""
C_COMPILER_BASENAME=$(basename ${CC:-gcc}) C_COMPILER_BASENAME=$(basename ${CC:-gcc})
CXX_COMPILER_BASENAME=$(basename ${CXX:-g++}) 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 # Allow the compiler prefix to be empty for virtual builds
COMPILER_PREFIX="${COMPILER_PREFIX-avr-}" COMPILER_PREFIX="${COMPILER_PREFIX-avr-}"

Loading…
Cancel
Save