Merge remote-tracking branch 'upstream/edge' into update/gcc4.8
[clinton/Smoothieware.git] / win_install.cmd
1 @echo off
2 rem Copyright 2013 Adam Green (http://mbed.org/users/AdamGreen/)
3 rem
4 rem Licensed under the Apache License, Version 2.0 (the "License");
5 rem you may not use this file except in compliance with the License.
6 rem You may obtain a copy of the License at
7 rem
8 rem http://www.apache.org/licenses/LICENSE-2.0
9 rem
10 rem Unless required by applicable law or agreed to in writing, software
11 rem distributed under the License is distributed on an "AS IS" BASIS,
12 rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 rem See the License for the specific language governing permissions and
14 rem limitations under the License.
15
16
17 rem Setup batch file specific environment variables.
18 setlocal
19 set ROOTDIR=%~dp0
20 set LOGFILE=%ROOTDIR%win_install.log
21 set ERRORFILE=%ROOTDIR%win_install.err
22 set GCC4ARM_VERSION=gcc-arm-none-eabi-4_8-2014q1
23 set GCC4ARM_FILENAME=gcc-arm-none-eabi-4_8-2014q1-20140314-win32.zip
24 set GCC4ARM_URL=https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/%GCC4ARM_FILENAME%
25 set GCC4ARM_TAR=%ROOTDIR%%GCC4ARM_FILENAME%
26 set GCC4ARM_MD5=09c19b3248863074f5498a88f31bee16
27 set GCC4ARM_MD5_FILENAME=%ROOTDIR%gcc-arm-none-eabi.md5
28 set GCC4ARM_DIR=%ROOTDIR%gcc-arm-none-eabi
29 set GCC4ARM_BINDIR=%GCC4ARM_DIR%\bin
30 set OUR_MAKE=%ROOTDIR%external\win32\make.exe
31 set BUILDENV_CMD=%GCC4ARM_BINDIR%\buildenv.cmd
32 set BUILDSHELL_CMD=%ROOTDIR%BuildShell.cmd
33 set BUILDSHELL_DEBUG_CMD=%ROOTDIR%BuildShellDebug.cmd
34
35
36 rem Make sure that we are running with current directory set to where this
37 rem batch file is located.
38 pushd %ROOTDIR%
39
40 rem Initialize install log files.
41 echo Logging install results to %LOGFILE%
42 echo %DATE% %TIME% Starting %0 %*>%LOGFILE%
43
44 echo Downloading GNU Tools for ARM Embedded Processors...
45 echo %DATE% %TIME% Executing external\win32\curl -kL0 %GCC4ARM_URL%>>%LOGFILE%
46 external\win32\curl -kL0 %GCC4ARM_URL% >%GCC4ARM_TAR%
47 if errorlevel 1 goto ExitOnError
48
49 echo Validating md5 signature of GNU Tools for ARM Embedded Processors...
50 echo %GCC4ARM_MD5% *%GCC4ARM_FILENAME%>%GCC4ARM_MD5_FILENAME%
51 call :RunAndLog external\win32\md5sum --check %GCC4ARM_MD5_FILENAME%
52 if errorlevel 1 goto ExitOnError
53 del "%GCC4ARM_MD5_FILENAME%"
54
55 echo Extracting GNU Tools for ARM Embedded Processors...
56 call :RunAndLog rd /s /q %GCC4ARM_DIR%
57 call :RunAndLog md %GCC4ARM_DIR%
58 if errorlevel 1 goto ExitOnError
59 call :RunAndLog cd %GCC4ARM_DIR%
60 call :RunAndLog ..\external\win32\bsdtar xf %GCC4ARM_TAR%
61 if errorlevel 1 goto ExitOnError
62 call :RunAndLog cd ..
63
64 echo Creating helper scripts...
65 echo @echo off>%BUILDENV_CMD%
66 echo REM Uncomment next line and set destination drive to match mbed device>>%BUILDENV_CMD%
67 echo REM SET LPC_DEPLOY=copy PROJECT.bin f:\>>%BUILDENV_CMD%
68 echo.>>%BUILDENV_CMD%
69 echo SET PATH=%%~dp0;%%~dp0..\..\external\win32;%%PATH%%>>%BUILDENV_CMD%
70 rem
71 echo @cmd.exe /K %%~dp0\gcc-arm-none-eabi\bin\buildenv.cmd>%BUILDSHELL_CMD%
72 rem
73 echo @cmd.exe /K "set GCC4MBED_TYPE=Debug& %%~dp0\gcc-arm-none-eabi\bin\buildenv.cmd">%BUILDSHELL_DEBUG_CMD%
74
75 rem Place GNU Tool for ARM Embedded Processors in the path before building gcc4mbed code.
76 set path=%GCC4ARM_BINDIR%;%ROOTDIR%external\win32;%PATH%
77
78 echo Performing a clean build of the gcc4mbed samples...
79 call :RunAndLog %OUR_MAKE% clean
80 if errorlevel 1 goto ExitOnError
81 call :RunAndLog %OUR_MAKE%
82 if errorlevel 1 goto ExitOnError
83
84 echo Cleaning up intermediate files...
85 call :RunAndLog del /f %GCC4ARM_TAR%
86
87 echo **************************************************************************
88 echo To build gcc4mbed samples, you will first need to run the following batch
89 echo file so that your environment variables are set correctly:
90 echo %BUILDSHELL_CMD%
91 echo You will want to run this each time you start a new Command Prompt. You
92 echo can simply double-click on this batch file from Explorer to launch a
93 echo Command Prompt that has been properly initialized for building gcc4mbed
94 echo based code.
95 echo **************************************************************************
96
97 rem Restore current directory and exit batch file on success.
98 echo %DATE% %TIME% Finished successfully>>%LOGFILE%
99 echo Finished successfully
100 goto Exit
101
102
103
104 rem Logs the command to be run and then executes the command while logging the results.
105 :RunAndLog
106 echo %DATE% %TIME% Executing %*>>%LOGFILE%
107 %* 1>>%LOGFILE% 2>%ERRORFILE%
108 goto :EOF
109
110
111
112 rem Exits the batch file due to error.
113 rem Make sure that any stderr text ends up in win_install.log and then restore
114 rem the current directory before forcing an early exit.
115 :ExitOnError
116 type %ERRORFILE% >>%LOGFILE%
117 echo %DATE% %TIME% Failure forced early exit>>%LOGFILE%
118 type %LOGFILE%
119
120
121 :Exit
122 del %ERRORFILE%
123 popd
124 pause