Commit | Line | Data |
---|---|---|
3b1e82d2 | 1 | @echo off\r |
8fcce42e | 2 | rem Copyright 2012 Adam Green (http://mbed.org/users/AdamGreen/)\r |
3b1e82d2 AW |
3 | rem\r |
4 | rem Licensed under the Apache License, Version 2.0 (the "License");\r | |
5 | rem you may not use this file except in compliance with the License.\r | |
6 | rem You may obtain a copy of the License at\r | |
7 | rem\r | |
8 | rem http://www.apache.org/licenses/LICENSE-2.0\r | |
9 | rem\r | |
10 | rem Unless required by applicable law or agreed to in writing, software\r | |
11 | rem distributed under the License is distributed on an "AS IS" BASIS,\r | |
12 | rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r | |
13 | rem See the License for the specific language governing permissions and\r | |
14 | rem limitations under the License.\r | |
15 | \r | |
16 | \r | |
17 | rem Setup batch file specific environment variables.\r | |
18 | setlocal\r | |
19 | set ROOTDIR=%~dp0\r | |
20 | set LOGFILE=%ROOTDIR%win_install.log\r | |
21 | set ERRORFILE=%ROOTDIR%win_install.err\r | |
172d42d9 AG |
22 | \r |
23 | set GCC4ARM_FILENAME=gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar.bz2\r | |
24 | set GCC4ARM_URL=https://launchpad.net/gcc-arm-embedded/4.7/4.7-2012-q4-major/+download/%GCC4ARM_FILENAME%\r | |
8fcce42e | 25 | set GCC4ARM_TAR=%ROOTDIR%%GCC4ARM_FILENAME%\r |
172d42d9 AG |
26 | set GCC4ARM_MD5=%ROOTDIR%build\win32\gcc-arm-none-eabi.md5\r |
27 | set GCC4ARM_VERSION=gcc-arm-none-eabi-4_7-2012q4\r | |
8fcce42e AG |
28 | set GCC4ARM_EXTRACT=%ROOTDIR%%GCC4ARM_VERSION%\r |
29 | set GCC4ARM_DIR=%ROOTDIR%gcc-arm-none-eabi\r | |
30 | set GCC4ARM_BINDIR=%GCC4ARM_DIR%\bin\r | |
172d42d9 AG |
31 | set GCC4ARM_LIBEXEC=%GCC4ARM_DIR%\lib\gcc\arm-none-eabi\4.7.3\r |
32 | set WINBIN_URL=https://github.com/adamgreen/GCC-ARM-Embedded-20121208/tarball/master\r | |
33 | set WINBIN_TAR=%ROOTDIR%GCC-ARM-Embedded-20121208.tar.gz\r | |
34 | \r | |
35 | set WINBIN_MD5=%ROOTDIR%build\win32\GCC-ARM-Embedded.md5\r | |
8fcce42e AG |
36 | set WINBIN_BASEDIR=%ROOTDIR%GCC-ARM-Embedded\r |
37 | set WINBIN_DIR=%WINBIN_BASEDIR%\win32\r | |
172d42d9 | 38 | set OUR_MAKE=%ROOTDIR%build\win32\make.exe\r |
8fcce42e | 39 | set BUILDENV_CMD=%GCC4ARM_BINDIR%\buildenv.cmd\r |
3b1e82d2 | 40 | set BUILDSHELL_CMD=%ROOTDIR%BuildShell.cmd\r |
8fcce42e | 41 | set ERROR_ENCOUNTERED=0\r |
3b1e82d2 AW |
42 | \r |
43 | \r | |
44 | rem Make sure that we are running with current directory set to where this\r | |
45 | rem batch file is located.\r | |
46 | pushd %ROOTDIR%\r | |
47 | \r | |
48 | rem Initialize install log files.\r | |
49 | echo Logging install results to %LOGFILE%\r | |
50 | echo %DATE% %TIME% Starting %0 %*>%LOGFILE%\r | |
51 | \r | |
8fcce42e | 52 | echo Downloading GNU Tools for ARM Embedded Processors...\r |
172d42d9 AG |
53 | echo %DATE% %TIME% Executing build\win32\curl -kL0 %GCC4ARM_URL%>>%LOGFILE%\r |
54 | build\win32\curl -kL0 %GCC4ARM_URL% >%GCC4ARM_TAR%\r | |
3b1e82d2 AW |
55 | if errorlevel 1 goto ExitOnError\r |
56 | \r | |
57 | echo Validating md5 signature of Code Sourcery G++ Lite...\r | |
172d42d9 | 58 | call :RunAndLog build\win32\md5sum --check %GCC4ARM_MD5%\r |
3b1e82d2 AW |
59 | if errorlevel 1 goto ExitOnError\r |
60 | \r | |
8fcce42e | 61 | echo Downloading Windows GCC binaries from github...\r |
172d42d9 AG |
62 | echo %DATE% %TIME% Executing build\win32\curl -kL0 %WINBIN_URL%>>%LOGFILE%\r |
63 | build\win32\curl -kL0 %WINBIN_URL% >%WINBIN_TAR%\r | |
8fcce42e AG |
64 | if errorlevel 1 goto ExitOnError\r |
65 | \r | |
66 | echo Validating md5 signature of Windows GCC binaries...\r | |
172d42d9 | 67 | call :RunAndLog build\win32\md5sum --check %WINBIN_MD5%\r |
8fcce42e AG |
68 | if errorlevel 1 goto ExitOnError\r |
69 | \r | |
70 | echo Extracting GNU Tools for ARM Embedded Processors...\r | |
172d42d9 | 71 | call :RunAndLog rd /s /q %GCC4ARM_EXTRACT%\r |
8fcce42e | 72 | call :RunAndLog rd /s /q %GCC4ARM_DIR%\r |
172d42d9 | 73 | call :RunAndLog build\win32\bsdtar xf %GCC4ARM_TAR%\r |
8fcce42e AG |
74 | if errorlevel 1 goto ExitOnError\r |
75 | call :RunAndLog move %GCC4ARM_EXTRACT% %GCC4ARM_DIR%\r | |
76 | if errorlevel 1 goto ExitOnError\r | |
77 | \r | |
78 | echo Extracting Windows GCC binaries...\r | |
79 | call :RunAndLog rd /s /q %WINBIN_BASEDIR%\r | |
172d42d9 | 80 | call :RunAndLog build\win32\bsdtar xf %WINBIN_TAR%\r |
8fcce42e AG |
81 | for /d %%i in (adamgreen-GCC-ARM-Embedded-*) do call :RunAndLog move %%i %WINBIN_BASEDIR%\r |
82 | if errorlevel 1 goto ExitOnError\r | |
83 | \r | |
84 | echo Installing Windows binaries...\r | |
85 | call :RunAndLog del /q %GCC4ARM_BINDIR%\*\r | |
86 | call :RunAndLog copy %WINBIN_DIR%\arm-none-eabi-* %GCC4ARM_BINDIR%\\r | |
87 | if errorlevel 1 goto ExitOnError\r | |
88 | for %%i in (as g++ ld objcopy ranlib ar c++ gcc nm objdump strip) do call :CopyGccFile %%i\r | |
89 | if "%ERROR_ENCOUNTERED%"=="1" goto ExitOnError\r | |
8fcce42e | 90 | call :RunAndLog xcopy /eiy %WINBIN_DIR%\libexec %GCC4ARM_LIBEXEC%\r |
3b1e82d2 AW |
91 | if errorlevel 1 goto ExitOnError\r |
92 | \r | |
93 | echo Creating helper scripts...\r | |
94 | echo @echo off>%BUILDENV_CMD%\r | |
95 | echo REM Uncomment next line and set destination drive to match mbed device>>%BUILDENV_CMD%\r | |
96 | echo REM SET LPC_DEPLOY=copy PROJECT.bin f:\>>%BUILDENV_CMD%\r | |
97 | echo.>>%BUILDENV_CMD%\r | |
172d42d9 | 98 | echo SET PATH=%%~dp0;%%~dp0..\..\build\win32;%%PATH%%>>%BUILDENV_CMD%\r |
3b1e82d2 | 99 | rem\r |
8fcce42e | 100 | echo @cmd.exe /K %%~dp0\gcc-arm-none-eabi\bin\buildenv.cmd>%BUILDSHELL_CMD%\r |
3b1e82d2 | 101 | \r |
8fcce42e AG |
102 | echo Cleaning up intermediate files...\r |
103 | call :RunAndLog rd /s /q %WINBIN_BASEDIR%\r | |
104 | call :RunAndLog del /f %WINBIN_TAR%\r | |
105 | call :RunAndLog del /f %GCC4ARM_TAR%\r | |
106 | \r | |
3b1e82d2 | 107 | echo **************************************************************************\r |
172d42d9 | 108 | echo To build Smoothie, you will first need to run the following batch\r |
3b1e82d2 AW |
109 | echo file so that your environment variables are set correctly:\r |
110 | echo %BUILDSHELL_CMD%\r | |
111 | echo You will want to run this each time you start a new Command Prompt. You\r | |
112 | echo can simply double-click on this batch file from Explorer to launch a\r | |
172d42d9 | 113 | echo Command Prompt that has been properly initialized for building.\r |
3b1e82d2 AW |
114 | echo **************************************************************************\r |
115 | \r | |
116 | rem Restore current directory and exit batch file on success.\r | |
117 | echo %DATE% %TIME% Finished successfully>>%LOGFILE%\r | |
118 | echo Finished successfully\r | |
119 | goto Exit\r | |
120 | \r | |
121 | \r | |
122 | \r | |
123 | rem Logs the command to be run and then executes the command while logging the results.\r | |
124 | :RunAndLog\r | |
125 | echo %DATE% %TIME% Executing %*>>%LOGFILE%\r | |
126 | %* 1>>%LOGFILE% 2>%ERRORFILE%\r | |
127 | goto :EOF\r | |
128 | \r | |
129 | \r | |
130 | \r | |
8fcce42e AG |
131 | rem Copies a file between GCC directories where one has arm-none-eabi prefix and the other doesn't\r |
132 | :CopyGccFile\r | |
133 | call :RunAndLog del "%GCC4ARM_DIR%\arm-none-eabi\bin\%1"\r | |
134 | call :RunAndLog copy /y "%GCC4ARM_BINDIR%\arm-none-eabi-%1.exe" "%GCC4ARM_DIR%\arm-none-eabi\bin\%1.exe"\r | |
135 | if errorlevel 1 set ERROR_ENCOUNTERED=1\r | |
136 | goto :EOF\r | |
137 | \r | |
138 | \r | |
3b1e82d2 AW |
139 | rem Exits the batch file due to error.\r |
140 | rem Make sure that any stderr text ends up in win_install.log and the restore\r | |
141 | rem the current dictory before forcing an early exit.\r | |
142 | :ExitOnError\r | |
143 | type %ERRORFILE% >>%LOGFILE%\r | |
144 | echo %DATE% %TIME% Failure forced early exit>>%LOGFILE%\r | |
145 | type %LOGFILE%\r | |
146 | \r | |
147 | \r | |
148 | :Exit\r | |
149 | del %ERRORFILE%\r | |
150 | popd\r | |
151 | pause |