diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/docker_build.sh | 26 | ||||
-rw-r--r-- | util/drivers.txt | 37 | ||||
-rwxr-xr-x | util/freebsd_install.sh | 2 | ||||
-rwxr-xr-x | util/linux_install.sh | 42 | ||||
-rwxr-xr-x | util/macos_install.sh | 25 | ||||
-rwxr-xr-x | util/msys2_install.sh | 5 | ||||
-rwxr-xr-x | util/new_keyboard.sh | 6 | ||||
-rwxr-xr-x | util/rules_cleaner.sh | 40 | ||||
-rwxr-xr-x | util/travis_build.sh | 78 | ||||
-rwxr-xr-x | util/travis_compiled_push.sh | 10 | ||||
-rwxr-xr-x | util/travis_docs.sh | 1 | ||||
-rwxr-xr-x | util/travis_push.sh | 5 | ||||
-rw-r--r-- | util/travis_test.sh | 31 | ||||
-rwxr-xr-x | util/travis_utils.sh | 24 | ||||
-rw-r--r-- | util/vagrant/Dockerfile | 33 | ||||
-rw-r--r-- | util/vagrant/readme.md | 12 | ||||
-rwxr-xr-x | util/win_shared_install.sh | 2 | ||||
-rwxr-xr-x | util/wsl_install.sh | 5 |
18 files changed, 249 insertions, 135 deletions
diff --git a/util/docker_build.sh b/util/docker_build.sh index c573ebcae2..99d59d1696 100755 --- a/util/docker_build.sh +++ b/util/docker_build.sh @@ -1,6 +1,10 @@ #!/bin/sh # NOTE: This script uses tabs for indentation +errcho() { + echo "$@" >&2 +} + USAGE="Usage: $0 [keyboard[:keymap[:target]]]" # Check preconditions @@ -11,11 +15,11 @@ for arg; do fi done if [ $# -gt 1 ]; then - echo "$USAGE" >&2 + errcho "$USAGE" exit 1 elif ! command -v docker >/dev/null 2>&1; then - echo "Error: docker not found" >&2 - echo "See https://docs.docker.com/install/#supported-platforms for installation instructions" >&2 + errcho "Error: docker not found" + errcho "See https://docs.docker.com/install/#supported-platforms for installation instructions" exit 2 fi @@ -29,7 +33,7 @@ else $1 EOF if [ -n "$x" ]; then - echo "$USAGE" >&2 + errcho "$USAGE" exit 1 fi fi @@ -37,14 +41,20 @@ if [ -n "$target" ]; then if [ "$(uname)" = "Linux" ] || docker-machine active >/dev/null 2>&1; then usb_args="--privileged -v /dev:/dev" else - echo "Error: target requires docker-machine to work on your platform" >&2 - echo "See http://gw.tnode.com/docker/docker-machine-with-usb-support-on-windows-macos" >&2 - echo "Consider flashing with QMK Toolbox (https://github.com/qmk/qmk_toolbox) instead" >&2 + errcho "Error: target requires docker-machine to work on your platform" + errcho "See http://gw.tnode.com/docker/docker-machine-with-usb-support-on-windows-macos" + errcho "Consider flashing with QMK Toolbox (https://github.com/qmk/qmk_toolbox) instead" exit 3 fi fi dir=$(pwd -W 2>/dev/null) || dir=$PWD # Use Windows path if on Windows # Run container and build firmware -docker run --rm -it $usb_args -v "$dir":/qmk_firmware qmkfm/qmk_firmware \ +docker run --rm -it $usb_args \ + -w /qmk_firmware \ + -v "$dir":/qmk_firmware \ + -e ALT_GET_KEYBOARDS=true \ + -e SKIP_GIT="$SKIP_GIT" \ + -e MAKEFLAGS="$MAKEFLAGS" \ + qmkfm/base_container \ make "$keyboard${keymap:+:$keymap}${target:+:$target}" diff --git a/util/drivers.txt b/util/drivers.txt index 4e5439c39b..71d99eaa90 100644 --- a/util/drivers.txt +++ b/util/drivers.txt @@ -3,45 +3,12 @@ # Use a comma as a separator without spaces # Driver can be one of winusb,libusb,libusbk # Use Windows Powershell and type [guid]::NewGuid() to generate guids +winusb,STM32 Bootloader,0483,DF11,6d98a87f-4ecf-464d-89ed-8c684d857a75 +libusb,USBaspLoader,16C0,05DC,e69affdc-0ef0-427c-aefb-4e593c9d2724 winusb,Kiibohd DFU Bootloader,1C11,B007,aa5a3f86-b81e-4416-89ad-0c1ea1ed63af -winusb,STM32 Bootloader,0483,df11,6d98a87f-4ecf-464d-89ed-8c684d857a75 -libusb,ATxmega16C4,03EB,2FD8,23266ee7-5423-4cc4-993b-034571c43a90 -libusb,ATxmega32C4,03EB,2FD9,d4b62886-2ac8-4534-aa24-eae0a2c3ce43 -libusb,ATxmega64C3,03EB,2FD6,08467ca7-9b5a-41d2-8d8a-4a26d0b5285b -libusb,ATxmega128C3,03EB,2FD7,1ca69799-6d95-46cf-be69-5b3d0eb915e6 -libusb,ATxmega256C3,03EB,2FDA,216ddc8b-6c67-4cc0-b934-482829a483a0 -libusb,ATxmega384C3,03EB,2FDB,0e4e3347-6025-4d49-ba80-2375ea690c28 -libusb,ATxmega64A1U,03EB,2FE8,2553d8fa-7de1-44a6-bdbf-57be8bb37e28 -libusb,ATxmega128A1U,03EB,2FED,6d9fd0ff-755d-4e29-bd29-df0a9a7544b9 -libusb,ATxmega64A4U,03EB,2FDD,bcf5e7c3-44a1-4fd1-971f-9ef9843f6291 -libusb,ATxmega128A4U,03EB,2FDE,3f976bb6-36ca-44cc-a728-844bc1d0d168 -libusb,ATxmega64B3,03EB,2FDF,de280c81-c12a-4ca7-bf34-566151786418 -libusb,ATxmega128B3,03EB,2FE0,2ad1ffeb-eb83-4e78-b34a-d5633771991f -libusb,ATxmega64B1,03EB,2FE1,002874a6-7fc7-413b-9ac4-2b52c5a230bd -libusb,ATxmega128B1,03EB,2FEA,60ea9d08-2ae6-4434-b743-ce6f73537136 -libusb,ATxmega256A3BU,03EB,2FE2,5949bd0a-8bd4-417b-b1c5-7d249836bf0d -libusb,ATxmega16A4U,03EB,2FE3,cc3172b0-e86a-4758-914e-951bca6ca7f5 -libusb,ATxmega32A4U,03EB,2FE4,f44c515f-7d17-4612-a532-ee620afb22b2 -libusb,ATxmega64A4U,03EB,2FE5,c1af4f1c-045f-40c9-893a-3ad4adb2e67d -libusb,ATxmega128A3U,03EB,2FE6,26f275f0-d6b2-46d8-8334-e4de66996c74 -libusb,ATxmega192A3U,03EB,2FE7,b7b50d98-0429-4235-8f08-5466e4f83ed4 -libusb,UC3,03EB,2FDC,972d9af7-d71b-44c7-a895-9340b362f545 -libusb,ATUC3,03EB,2FE9,d5855d0a-f82e-4df5-9c14-2b0b1dcb65bd -libusb,AT32UC3C,03EB,2FEB,1eeb52aa-fd24-47fd-8a76-056446d1a54f -libusb,ATxmega256A3U,03EB,2FEC,198fa8ea-3157-4863-b9a8-a3f6fe027367 -libusb,ATmega8U2,03EB,2FEE,14018055-46f4-4c62-aa03-e8fafeedaf72 libusb,ATmega16U2,03EB,2FEF,007274da-b75f-492e-a288-8fc0aff8339f libusb,ATmega32U2,03EB,2FF0,ddc2c572-cb6e-4f61-a6cc-1a5de941f063 -libusb,AT32UC3A3,03EB,2FF1,8b614283-36c0-46a2-890d-65f61b5b6201 -libusb,ATmega32U6,03EB,2FF2,a207dd90-2814-4418-b5b7-4b708fdf1bfd libusb,ATmega16U4,03EB,2FF3,3180d426-bf93-4578-a693-2efbc337da8e libusb,ATmega32U4,03EB,2FF4,5f9726fd-f9de-487a-9fbd-8b3524a7a56a -libusb,AT32UC3B,03EB,2FF6,ef90068a-277a-44db-805a-9b83a6beb29a -libusb,AT90USB82,03EB,2FF7,062fa2ab-f9d8-4a0d-83c1-df0521cfd0f6 -libusb,AT32UC3A,03EB,2FF8,24080a67-3874-4fb8-8808-fb4cc297c466 libusb,AT90USB64,03EB,2FF9,c6a708ad-e97d-43cd-b04a-3180d737a71b -libusb,AT90USB162,03EB,2FFA,de67bff5-6e39-4e9c-8dfe-de7fce113716 libusb,AT90USB128,03EB,2FFB,fd217df3-59d0-440a-a8f3-4c0c8c84daa3 -libusb,AT89C5130,03EB,2FFD,31b69a56-9ac0-4fab-a3ae-cd7bb7021ec5 -libusb,AT8XC5122,03EB,2FFE,395a6118-8568-41b2-913a-d16912722342 -libusb,AT89C5132,03EB,2FFF,266ca4bc-5e59-4a7b-82dc-6e8732373d40 diff --git a/util/freebsd_install.sh b/util/freebsd_install.sh index c8696e8cc7..8157592031 100755 --- a/util/freebsd_install.sh +++ b/util/freebsd_install.sh @@ -1,4 +1,5 @@ #!/bin/sh +util_dir=$(dirname "$0") pkg update pkg install -y \ git \ @@ -17,3 +18,4 @@ pkg install -y \ arm-none-eabi-newlib \ diffutils \ python3 +pip3 install -r ${util_dir}/../requirements.txt diff --git a/util/linux_install.sh b/util/linux_install.sh index 4731ec0156..c54a806234 100755 --- a/util/linux_install.sh +++ b/util/linux_install.sh @@ -8,6 +8,8 @@ SLACKWARE_WARNING="You will need the following packages from slackbuilds.org:\n\ SOLUS_INFO="Your tools are now installed. To start using them, open new terminal or source these scripts:\n\t/usr/share/defaults/etc/profile.d/50-arm-toolchain-path.sh\n\t/usr/share/defaults/etc/profile.d/50-avr-toolchain-path.sh" +util_dir=$(dirname "$0") + if grep ID /etc/os-release | grep -qE "fedora"; then sudo dnf install \ arm-none-eabi-binutils-cs \ @@ -17,6 +19,7 @@ if grep ID /etc/os-release | grep -qE "fedora"; then avr-gcc \ avr-libc \ binutils-avr32-linux-gnu \ + clang \ dfu-util \ dfu-programmer \ diffutils \ @@ -42,6 +45,7 @@ elif grep ID /etc/os-release | grep -qE 'debian|ubuntu'; then avr-libc \ binutils-arm-none-eabi \ binutils-avr \ + clang-format \ dfu-programmer \ dfu-util \ diffutils \ @@ -57,7 +61,7 @@ elif grep ID /etc/os-release | grep -qE 'debian|ubuntu'; then elif grep ID /etc/os-release | grep -q 'arch\|manjaro'; then sudo pacman -U https://archive.archlinux.org/packages/a/avr-gcc/avr-gcc-8.3.0-1-x86_64.pkg.tar.xz - sudo pacman -S \ + sudo pacman -S --needed \ arm-none-eabi-binutils \ arm-none-eabi-gcc \ arm-none-eabi-newlib \ @@ -66,18 +70,17 @@ elif grep ID /etc/os-release | grep -q 'arch\|manjaro'; then avr-libc \ avr-gcc \ base-devel \ + clang \ + dfu-programmer \ dfu-util \ diffutils \ gcc \ git \ python \ + python-pip \ unzip \ wget \ zip - git clone https://aur.archlinux.org/dfu-programmer.git /tmp/dfu-programmer - cd /tmp/dfu-programmer || exit 1 - makepkg -sic - rm -rf /tmp/dfu-programmer/ elif grep ID /etc/os-release | grep -q gentoo; then echo "$GENTOO_WARNING" | fmt @@ -94,6 +97,7 @@ elif grep ID /etc/os-release | grep -q gentoo; then dev-embedded/avrdude \ dev-lang/python:3.5 \ net-misc/wget \ + sys-devel/clang \ sys-devel/gcc \ sys-devel/crossdev sudo crossdev -s4 --stable --g =4.9.4 --portage --verbose --target avr @@ -110,6 +114,7 @@ elif grep ID /etc/os-release | grep -q sabayon; then dev-embedded/avrdude \ dev-lang/python \ net-misc/wget \ + sys-devel/clang \ sys-devel/gcc \ sys-devel/crossdev sudo crossdev -s4 --stable --g =4.9.4 --portage --verbose --target avr @@ -124,6 +129,7 @@ elif grep ID /etc/os-release | grep -qE "opensuse|tumbleweed"; then fi sudo zypper install \ avr-libc \ + clang \ $CROSS_AVR_GCC \ $CROSS_ARM_GCC \ cross-avr-binutils \ @@ -178,8 +184,34 @@ elif grep ID /etc/os-release | grep -q solus; then unzip printf "\n$SOLUS_INFO\n" +elif grep ID /etc/os-release | grep -q void; then + # musl Void systems don't have glibc cross compilers avaliable in their repos. + # glibc Void systems do have musl cross compilers though, for some reason. + # So, default to musl, and switch to glibc if it is installed. + CROSS_ARM=cross-arm-linux-musleabi + if xbps-query glibc > /dev/null; then # Check is glibc if installed + CROSS_ARM=cross-arm-linux-gnueabi + fi + + sudo xbps-install \ + avr-binutils \ + avr-gcc \ + avr-libc \ + $CROSS_ARM \ + dfu-programmer \ + dfu-util \ + gcc \ + git \ + make \ + wget \ + unzip \ + zip + else echo "Sorry, we don't recognize your OS. Help us by contributing support!" echo echo "https://docs.qmk.fm/#/contributing" fi + +# Global install tasks +pip3 install --user -r ${util_dir}/../requirements.txt diff --git a/util/macos_install.sh b/util/macos_install.sh index 915ff3143c..f993003f09 100755 --- a/util/macos_install.sh +++ b/util/macos_install.sh @@ -1,26 +1,29 @@ #!/bin/bash -if ! brew --version 2>&1 > /dev/null; then +util_dir=$(dirname "$0") + +if ! brew --version >/dev/null 2>&1; then echo "Error! Homebrew not installed or broken!" echo -n "Would you like to install homebrew now? [y/n] " - while read ANSWER; do + while read -r ANSWER; do case $ANSWER in - y|Y) - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - break + y | Y) + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + break ;; - n|N) - exit 1 + n | N) + exit 1 ;; - *) - echo -n "Would you like to install homebrew now? [y/n] " + *) + echo -n "Would you like to install homebrew now? [y/n] " ;; esac done fi brew tap osx-cross/avr -brew tap PX4/homebrew-px4 +brew tap osx-cross/arm brew update -brew install avr-gcc@8 gcc-arm-none-eabi dfu-programmer avrdude dfu-util python3 +brew install avr-gcc@8 arm-gcc-bin dfu-programmer avrdude clang-format dfu-util python3 brew link --force avr-gcc@8 +pip3 install -r "${util_dir}/../requirements.txt" diff --git a/util/msys2_install.sh b/util/msys2_install.sh index bcb628ab21..58397c7a3f 100755 --- a/util/msys2_install.sh +++ b/util/msys2_install.sh @@ -5,9 +5,10 @@ download_dir=~/qmk_utils avrtools=avr8-gnu-toolchain armtools=gcc-arm-none-eabi installflip=false +util_dir=$(dirname "$0") echo "Installing dependencies needed for the installation (quazip)" -pacman --needed -S base-devel mingw-w64-x86_64-toolchain msys/git msys/p7zip msys/python3 msys/unzip +pacman --needed -S base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang msys/git msys/p7zip msys/python3 msys/unzip source "$dir/win_shared_install.sh" @@ -92,6 +93,8 @@ else fi popd +pip3 install -r ${util_dir}/../requirements.txt + cp -f "$dir/activate_msys2.sh" "$download_dir/" if grep "^source ~/qmk_utils/activate_msys2.sh$" ~/.bashrc diff --git a/util/new_keyboard.sh b/util/new_keyboard.sh index 35d89e4026..11c6497e23 100755 --- a/util/new_keyboard.sh +++ b/util/new_keyboard.sh @@ -41,8 +41,8 @@ copy_templates() { echo " done" echo -n "Renaming keyboard files..." - mv "${keyboard_dir}/template.c" "${keyboard_dir}/${keyboard_name}.c" - mv "${keyboard_dir}/template.h" "${keyboard_dir}/${keyboard_name}.h" + mv "${keyboard_dir}/keyboard.c" "${keyboard_dir}/${keyboard_name}.c" + mv "${keyboard_dir}/keyboard.h" "${keyboard_dir}/${keyboard_name}.h" echo " done" } @@ -86,6 +86,7 @@ replace_year_placeholders() { replace_keyboard_placeholders() { local replace_keyboard_filenames=( "${keyboard_dir}/config.h" + "${keyboard_dir}/info.json" "${keyboard_dir}/readme.md" "${keyboard_dir}/${keyboard_name}.c" "${keyboard_dir}/keymaps/default/readme.md" @@ -97,6 +98,7 @@ replace_keyboard_placeholders() { replace_name_placeholders() { local replace_name_filenames=( "${keyboard_dir}/config.h" + "${keyboard_dir}/info.json" "${keyboard_dir}/readme.md" "${keyboard_dir}/${keyboard_name}.c" "${keyboard_dir}/${keyboard_name}.h" diff --git a/util/rules_cleaner.sh b/util/rules_cleaner.sh new file mode 100755 index 0000000000..ac27c2b09b --- /dev/null +++ b/util/rules_cleaner.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# This script finds all rules.mk files in keyboards/ subdirectories, +# and deletes the build option filesize impacts from them. + +# Print an error message with the word "ERROR" in red. +echo_error() { + echo -e "[\033[0;91mERROR\033[m]: $1" +} + +# If we've been started from util/, we want to be in qmk_firmware/ +[[ "$PWD" == *util ]] && cd .. + +# The root qmk_firmware/ directory should have a subdirectory called quantum/ +if [ ! -d "quantum" ]; then + echo_error "Could not detect the QMK firmware directory!" + echo_error "Are you sure you're in the right place?" + exit 1 +fi + +# Set the inplace editing parameter for sed. +# macOS/BSD sed expects a file extension immediately following -i. +set_sed_i() { + sed_i=(-i) + + case $(uname -a) in + *Darwin*) sed_i=(-i "") + esac +} +set_sed_i + +# Exclude keyamps/ directories +files=$(find keyboards -type f -name 'rules.mk' -not \( -path '*/keymaps*' -prune \)) + +# Edit rules.mk files +for file in $files; do + sed "${sed_i[@]}" -e "s/(+[0-9].*)$//g" "$file" +done + +echo "Cleaned up rules.mk files." diff --git a/util/travis_build.sh b/util/travis_build.sh index 554ec8b689..6d5dbed684 100755 --- a/util/travis_build.sh +++ b/util/travis_build.sh @@ -1,56 +1,42 @@ #!/bin/bash -# if docker is installed - call make within the qmk docker image -if command -v docker >/dev/null; then - function make() { - docker run --rm -e MAKEFLAGS="$MAKEFLAGS" -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/qmk_firmware make "$@" - } +source util/travis_utils.sh + +NUM_CORE_CHANGES=$(echo "$QMK_CHANGES" | grep -Ecv -e '^(docs/)' -e '^(keyboards/)' -e '^(layouts/)' -e '^(util/)' -e '^(lib/python/)' -e '^(bin/qmk)' -e '^(requirements.txt)' -e '(.travis.yml)') + +if [[ "$TRAVIS_COMMIT_MESSAGE" == *"[skip build]"* ]]; then + echo "Skipping due to commit message" + exit 0 fi -# test force push -#TRAVIS_COMMIT_RANGE="c287f1bfc5c8...81f62atc4c1d" +if [ "$LOCAL_BRANCH" == "master" ] || [ "$NUM_CORE_CHANGES" != "0" ]; then + echo "Making default keymaps for all keyboards" + make all:default + exit $? +fi -TRAVIS_COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE:-none}" -TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE:-HEAD~1..HEAD}" -MAKE_ALL="make all:default" +exit_code=0 -if [[ "$TRAVIS_COMMIT_MESSAGE" != *"[skip build]"* ]] ; then - exit_code=0 - git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE} - if [ $? -eq 128 ]; then - echo "Making default keymaps for all keyboards" - eval $MAKE_ALL +for KB in $(make list-keyboards); do + KEYBOARD_CHANGES=$(echo "$QMK_CHANGES" | grep -E '^(keyboards/'${KB}'/)') + if [[ -z "$KEYBOARD_CHANGES" ]]; then + # skip as no changes for this keyboard + continue + fi + + KEYMAP_ONLY=$(echo "$KEYBOARD_CHANGES" | grep -cv /keymaps/) + if [[ $KEYMAP_ONLY -gt 0 ]]; then + echo "Making all keymaps for $KB" + make ${KB}:all : $((exit_code = $exit_code + $?)) else - NEFM=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE} | grep -Ev '^(keyboards/)' | grep -Ev '^(docs/)' | wc -l) - BRANCH=$(git rev-parse --abbrev-ref HEAD) - # is this branch master or a "non docs, non keyboards" change - if [ $NEFM -gt 0 -o "$BRANCH" = "master" ]; then - echo "Making default keymaps for all keyboards" - eval $MAKE_ALL + CHANGED_KEYMAPS=$(echo "$KEYBOARD_CHANGES" | grep -oP '(?<=keyboards/'${KB}'/keymaps/)([a-zA-Z0-9_-]+)(?=\/)') + for KM in $CHANGED_KEYMAPS ; do + echo "Making $KM for $KB" + make ${KB}:${KM} : $((exit_code = $exit_code + $?)) - else - # keyboards project format - # /keyboards/board1/rev/keymaps/ - # /keyboards/board2/keymaps/ - # ensure we strip everything off after and including the keymaps folder to get board and/or revision - MKB=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE} | grep -oP '(?<=keyboards\/)([a-zA-Z0-9_\/]+)(?=\/)' | sed 's^/keymaps/.*^^' | sort -u) - for KB in $MKB ; do - KEYMAP_ONLY=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE} | grep -Ev '^(keyboards/'${KB}'/keymaps/)' | wc -l) - if [[ $KEYMAP_ONLY -gt 0 ]]; then - echo "Making all keymaps for $KB" - make ${KB}:all - : $((exit_code = $exit_code + $?)) - else - MKM=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE} | grep -oP '(?<=keyboards/'${KB}'/keymaps/)([a-zA-Z0-9_]+)(?=\/)' | sort -u) - for KM in $MKM ; do - echo "Making $KM for $KB" - make ${KB}:${KM} - : $((exit_code = $exit_code + $?)) - done - fi - done - fi + done fi - exit $exit_code -fi +done + +exit $exit_code diff --git a/util/travis_compiled_push.sh b/util/travis_compiled_push.sh index 04021ae7c2..e0490cd702 100755 --- a/util/travis_compiled_push.sh +++ b/util/travis_compiled_push.sh @@ -1,5 +1,6 @@ #!/bin/bash +source util/travis_utils.sh source util/travis_push.sh set -o errexit -o nounset @@ -9,11 +10,12 @@ echo "Using git hash ${rev}" if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]] ; then -# convert to unix line-endings +# fix formatting git checkout master -git diff --diff-filter=M --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 dos2unix -git diff --diff-filter=M --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 git add -git commit -m "convert to unix line-endings [skip ci]" && git push git@github.com:qmk/qmk_firmware.git master +git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 dos2unix +git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | grep -e '^drivers' -e '^quantum' -e '^tests' -e '^tmk_core' | grep -v 'quantum/template' | xargs -0 clang-format +git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 git add +git commit -m "format code according to conventions [skip ci]" && git push git@github.com:qmk/qmk_firmware.git master increment_version () { diff --git a/util/travis_docs.sh b/util/travis_docs.sh index 5cfd63466d..93c2d71867 100755 --- a/util/travis_docs.sh +++ b/util/travis_docs.sh @@ -1,5 +1,6 @@ #!/bin/bash +source util/travis_utils.sh source util/travis_push.sh if [[ "$TRAVIS_COMMIT_MESSAGE" != *"[skip docs]"* ]] ; then diff --git a/util/travis_push.sh b/util/travis_push.sh index d100f9d48f..7f7d4c2c64 100755 --- a/util/travis_push.sh +++ b/util/travis_push.sh @@ -1,10 +1,5 @@ # Use this by sourcing it in your script. -TRAVIS_BRANCH="${TRAVIS_BRANCH:master}" -TRAVIS_PULL_REQUEST="${TRAVIS_PULL_REQUEST:false}" -TRAVIS_COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE:-none}" -TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE:-HEAD~1..HEAD}" - if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]] ; then git config --global user.name "QMK Bot" git config --global user.email "hello@qmk.fm" diff --git a/util/travis_test.sh b/util/travis_test.sh index 3be4afff7a..95991907ef 100644 --- a/util/travis_test.sh +++ b/util/travis_test.sh @@ -1,29 +1,28 @@ #!/bin/bash -TRAVIS_COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE:-none}" -TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE:-HEAD~1..HEAD}" +source util/travis_utils.sh -# test force push -#TRAVIS_COMMIT_RANGE="c287f1bfc5c8...81f62atc4c1d" - -NUM_IMPACTING_CHANGES=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE} | grep -Ecv '^(docs/)') -BRANCH=$(git rev-parse --abbrev-ref HEAD) +NUM_CORE_CHANGES=$(echo "$QMK_CHANGES" | grep -Ecv -e '^(docs/)' -e '^(keyboards/)' -e '^(layouts/)' -e '^(util/)' -e '^(lib/python/)' -e '^(bin/qmk)' -e '^(requirements.txt)' -e '(.travis.yml)') +NUM_PY_CHANGES=$(echo "$QMK_CHANGES" | grep -Ec -e '^(lib/python/)' -e '^(bin/qmk)') if [[ "$TRAVIS_COMMIT_MESSAGE" == *"[skip test]"* ]]; then echo "Skipping due to commit message" exit 0 fi -if [ "$BRANCH" != "master" ] && [ "$NUM_IMPACTING_CHANGES" == "0" ]; then - echo "Skipping due to changes not impacting tests" - exit 0 +exit_code=0 + +if [ "$LOCAL_BRANCH" == "master" ] || [ "$NUM_CORE_CHANGES" != "0" ]; then + echo "Running tests." + make test:all + : $((exit_code = $exit_code + $?)) + fi -# if docker is installed - call make within the qmk docker image -if command -v docker >/dev/null; then - function make() { - docker run --rm -e MAKEFLAGS="$MAKEFLAGS" -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/qmk_firmware make "$@" - } +if [ "$LOCAL_BRANCH" == "master" ] || [ "$NUM_PY_CHANGES" != "0" ]; then + echo "Running python tests." + qmk pytest + : $((exit_code = $exit_code + $?)) fi -make test:all +exit $exit_code diff --git a/util/travis_utils.sh b/util/travis_utils.sh new file mode 100755 index 0000000000..e3d806dfba --- /dev/null +++ b/util/travis_utils.sh @@ -0,0 +1,24 @@ +# Use this by sourcing it in your script. + +# Provide sane defaults for travis environment +TRAVIS_BRANCH="${TRAVIS_BRANCH:master}" +TRAVIS_PULL_REQUEST="${TRAVIS_PULL_REQUEST:false}" +TRAVIS_COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE:-none}" +TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE:-HEAD~1..HEAD}" + +# test force push +#TRAVIS_COMMIT_RANGE="c287f1bfc5c8...81f62atc4c1d" + +# Extra variables +LOCAL_BRANCH=$(git rev-parse --abbrev-ref HEAD) +QMK_CHANGES=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE}) + +# if docker is installed - patch calls to within the qmk docker image +if command -v docker >/dev/null; then + function make() { + docker run --rm -e MAKEFLAGS="$MAKEFLAGS" -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/base_container make "$@" + } + function qmk() { + docker run --rm -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/base_container bin/qmk "$@" + } +fi diff --git a/util/vagrant/Dockerfile b/util/vagrant/Dockerfile new file mode 100644 index 0000000000..1936ee023a --- /dev/null +++ b/util/vagrant/Dockerfile @@ -0,0 +1,33 @@ +FROM qmkfm/base_container + +# Basic upgrades; install sudo and SSH. +RUN apt-get update && apt-get install --no-install-recommends -y \ + sudo \ + openssh-server \ + && rm -rf /var/lib/apt/lists/* +RUN mkdir /var/run/sshd +RUN sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config +RUN echo 'UseDNS no' >> /etc/ssh/sshd_config + +# Remove the policy file once we're finished installing software. +# This allows invoke-rc.d and friends to work as expected. +RUN rm /usr/sbin/policy-rc.d + +# Add the Vagrant user and necessary passwords. +RUN groupadd vagrant +RUN useradd -c "Vagrant" -g vagrant -d /home/vagrant -m -s /bin/bash vagrant +RUN echo 'root:vagrant' | chpasswd +RUN echo 'vagrant:vagrant' | chpasswd + +# Allow the vagrant user to use sudo without a password. +RUN echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant + +# Install Vagrant's insecure public key so provisioning and 'vagrant ssh' work. +RUN mkdir /home/vagrant/.ssh +ADD https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub /home/vagrant/.ssh/authorized_keys +RUN chmod 0600 /home/vagrant/.ssh/authorized_keys +RUN chown -R vagrant:vagrant /home/vagrant/.ssh +RUN chmod 0700 /home/vagrant/.ssh + +EXPOSE 22 +CMD ["/usr/sbin/sshd", "-D"] diff --git a/util/vagrant/readme.md b/util/vagrant/readme.md new file mode 100644 index 0000000000..e4b870a642 --- /dev/null +++ b/util/vagrant/readme.md @@ -0,0 +1,12 @@ +# QMK Vagrant Utilities + +## Dockerfile +Vagrant-friendly `qmkfm/base_container`. + +In order for the Docker provider and `vagrant ssh` to function the container has a few extra requirements. + +* vagrant user +* ssh server + * configured with expected public key +* sudo + * passwordless for vagrant user diff --git a/util/win_shared_install.sh b/util/win_shared_install.sh index c7517881ee..f8fc9308f4 100755 --- a/util/win_shared_install.sh +++ b/util/win_shared_install.sh @@ -34,7 +34,7 @@ function install_drivers { pushd "$download_dir" cp -f "$dir/drivers.txt" . echo - cmd.exe /c "qmk_driver_installer.exe $1 $2 drivers.txt" + cmd.exe //c "qmk_driver_installer.exe $1 $2 drivers.txt" popd > /dev/null } diff --git a/util/wsl_install.sh b/util/wsl_install.sh index c2c206d2b9..197d9f089e 100755 --- a/util/wsl_install.sh +++ b/util/wsl_install.sh @@ -1,6 +1,7 @@ #!/bin/bash -dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P) +util_dir=$(dirname "$0") +dir=$(cd -P -- "$util_dir" && pwd -P) pushd "$dir"; if [[ $dir != /mnt/* ]]; @@ -28,6 +29,8 @@ download_dir=wsl_downloaded source "$dir/win_shared_install.sh" +pip3 install -r ${util_dir}/../requirements.txt + pushd "$download_dir" while true; do echo |