]> git.donarmstrong.com Git - qmk_firmware.git/blob - util/msys2_install.sh
QMK CLI and JSON keymap support (#6176)
[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 -S base-devel mingw-w64-x86_64-toolchain msys/git msys/p7zip msys/python3 msys/unzip
12
13 source "$dir/win_shared_install.sh"
14
15 function install_avr {
16     rm -f -r "$avrtools"
17     wget "http://ww1.microchip.com/downloads/en/DeviceDoc/avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip"
18     echo "Extracting AVR toolchain..."
19         unzip -q avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip
20         mv avr8-gnu-toolchain-win32_x86/ avr8-gnu-toolchain
21     rm __MACOSX -R
22     rm avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip
23     pacman --needed -S mingw-w64-x86_64-avrdude
24 }
25
26 function install_arm {
27     wget -O gcc-arm-none-eabi.zip "https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-win32.zip?product=GNU%20ARM%20Embedded%20Toolchain,ZIP,,Windows,6-2017-q2-update"
28     unzip -d gcc-arm-none-eabi gcc-arm-none-eabi.zip
29     rm gcc-arm-none-eabi.zip
30 }
31
32 function extract_flip {
33     rm -f -r flip
34     7z -oflip x FlipInstaller.exe
35 }
36
37 pushd "$download_dir"
38
39 if [ -f "FlipInstaller.exe" ]; then
40     echo
41     echo "Extracting flip"
42     extract_flip
43 fi
44
45 if [ ! -d "$avrtools" ]; then
46     while true; do
47         echo
48         echo "The AVR toolchain is not installed."
49         echo "This is needed for building AVR based keboards."
50         read -p "Do you want to install it? (Y/N) " res
51         case $res in
52             [Yy]* ) install_avr; break;;
53             [Nn]* ) break;;
54             * ) echo "Invalid answer";;
55         esac
56     done
57 else
58     while true; do
59         echo
60         echo "The AVR toolchain is already installed"
61         read -p "Do you want to reinstall? (Y/N) " res
62         case $res in
63             [Yy]* ) install_avr; break;;
64             [Nn]* ) break;;
65             * ) echo "Invalid answer";;
66         esac
67     done
68 fi
69
70 if [ ! -d "$armtools" ]; then
71     while true; do
72         echo
73         echo "The ARM toolchain is not installed."
74         echo "This is needed for building ARM based keyboards."
75         read -p "Do you want to install it? (Y/N) " res
76         case $res in
77             [Yy]* ) install_arm; break;;
78             [Nn]* ) break;;
79             * ) echo "Invalid answer";;
80         esac
81     done
82 else
83     while true; do
84         echo
85         echo "The ARM toolchain is already installed"
86         read -p "Do you want to reinstall? (Y/N) " res
87         case $res in
88             [Yy]* ) install_arm; break;;
89             [Nn]* ) break;;
90             * ) echo "Invalid answer";;
91         esac
92     done
93 fi
94 popd
95
96 pip3 install -r ${util_dir}/../requirements.txt
97
98 cp -f "$dir/activate_msys2.sh" "$download_dir/"
99
100 if grep "^source ~/qmk_utils/activate_msys2.sh$" ~/.bashrc
101 then
102     echo
103     echo "The line source ~/qmk_utils/activate_msys2.sh is already added to your /.bashrc"
104     echo "Not adding it twice!"
105 else
106     while true; do
107         echo
108         echo "Do you want to add 'source ~/qmk_utils/activate_msys2.sh' to the end of your"
109         echo ".bashrc file? Without this make won't find the needed utils, so if you don't"
110         echo "want to do it automatically, then you have to do it manually later."
111         read -p "(Y/N)? " res
112         case $res in
113             [Yy]* ) echo "source ~/qmk_utils/activate_msys2.sh" >> ~/.bashrc; break;;
114             [Nn]* ) break;;
115             * ) echo "Invalid answer";;
116         esac
117     done
118 fi
119
120 echo
121 echo "******************************************************************************"
122 echo "Installation completed!"
123 echo "Please close this Window and restart MSYS2 MinGW"
124 echo "******************************************************************************"