]> git.donarmstrong.com Git - qmk_firmware.git/blob - util/msys2_install.sh
Relocate magic keycode processing (#7512)
[qmk_firmware.git] / util / msys2_install.sh
1 #!/bin/bash
2
3 dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4 download_dir=~/qmk_utils
5 avrtools=avr8-gnu-toolchain
6 armtools=gcc-arm-none-eabi
7 installflip=false
8 util_dir=$(dirname "$0")
9
10 echo "Installing dependencies needed for the installation (quazip)"
11 pacman --needed --noconfirm --disable-download-timeout -Sy base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang msys/git msys/p7zip mingw-w64-x86_64-python3-pip msys/unzip
12
13 source "$dir/win_shared_install.sh"
14
15 function install_avr {
16     rm -f -r "$avrtools"
17     wget "https://blog.zakkemble.net/download/avr-gcc-8.3.0-x86-mingw.zip"
18     echo "Extracting AVR toolchain..."
19     unzip -q -d . avr-gcc-8.3.0-x86-mingw.zip
20     mv avr-gcc-8.3.0-x86-mingw avr8-gnu-toolchain
21     rm avr8-gnu-toolchain/bin/make.exe
22     rm avr-gcc-8.3.0-x86-mingw.zip
23     pacman --needed --disable-download-timeout -S mingw-w64-x86_64-avrdude
24 }
25
26 function install_arm {
27     rm -f -r "$armtools"
28     wget -O gcc-arm-none-eabi-8-2019-q3-update-win32.zip "https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2019q3/RC1.1/gcc-arm-none-eabi-8-2019-q3-update-win32.zip"
29     echo "Extracting ARM toolchain..."
30     unzip -q -d gcc-arm-none-eabi gcc-arm-none-eabi-8-2019-q3-update-win32.zip
31     rm gcc-arm-none-eabi-8-2019-q3-update-win32.zip
32 }
33
34 function extract_flip {
35     rm -f -r flip
36     7z -oflip x FlipInstaller.exe
37 }
38
39 pushd "$download_dir"
40
41 if [ -f "FlipInstaller.exe" ]; then
42     echo
43     echo "Extracting flip"
44     extract_flip
45 fi
46
47 if [ ! -d "$avrtools" ]; then
48     echo
49     echo "The AVR toolchain is not installed."
50     echo "This is needed for building AVR based keyboards."
51     install_avr
52 else
53     while true; do
54         echo
55         echo "The AVR toolchain is already installed"
56         read -p "Do you want to reinstall? (Y/N) " res
57         case $res in
58             [Yy]* ) install_avr; break;;
59             [Nn]* ) break;;
60             * ) echo "Invalid answer";;
61         esac
62     done
63 fi
64
65 if [ ! -d "$armtools" ]; then
66     echo
67     echo "The ARM toolchain is not installed."
68     echo "This is needed for building ARM based keyboards."
69     install_arm
70 else
71     while true; do
72         echo
73         echo "The ARM toolchain is already installed"
74         read -p "Do you want to reinstall? (Y/N) " res
75         case $res in
76             [Yy]* ) install_arm; break;;
77             [Nn]* ) break;;
78             * ) echo "Invalid answer";;
79         esac
80     done
81 fi
82 popd
83
84 pip3 install -r ${util_dir}/../requirements.txt
85
86 cp -f "$dir/activate_msys2.sh" "$download_dir/"
87
88 if grep "^source ~/qmk_utils/activate_msys2.sh$" ~/.bashrc
89 then
90     echo
91     echo "The line source ~/qmk_utils/activate_msys2.sh is already added to your /.bashrc"
92     echo "Not adding it twice!"
93 else
94         echo
95         echo "Adding 'source ~/qmk_utils/activate_msys2.sh' to the end of your"
96         echo ".bashrc file. Without this make won't find the needed utils."
97         echo "source ~/qmk_utils/activate_msys2.sh" >> ~/.bashrc;
98 fi
99
100 echo
101 echo "******************************************************************************"
102 echo "Installation completed!"
103 echo "Please close this Window and restart MSYS2 MinGW"
104 echo "******************************************************************************"