Initialize invert_probe
[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%build\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 build\win32\curl -kL0 %GCC4ARM_URL%>>%LOGFILE%
46 build\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 build\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 ..\build\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..\..\build\win32;%%PATH%%>>%BUILDENV_CMD%
70 rem
71 echo @cmd.exe /K %%~dp0\gcc-arm-none-eabi\bin\buildenv.cmd>%BUILDSHELL_CMD%
72
73 rem Place GNU Tool for ARM Embedded Processors in the path before building gcc4mbed code.
74 set path=%GCC4ARM_BINDIR%;%ROOTDIR%build\win32;%PATH%
75
76 echo Performing a clean build of the gcc4mbed samples...
77 call :RunAndLog %OUR_MAKE% clean
78 if errorlevel 1 goto ExitOnError
79 call :RunAndLog %OUR_MAKE%
80 if errorlevel 1 goto ExitOnError
81
82 echo Cleaning up intermediate files...
83 call :RunAndLog del /f %GCC4ARM_TAR%
84
85 echo **************************************************************************
86 echo To build gcc4mbed samples, you will first need to run the following batch
87 echo file so that your environment variables are set correctly:
88 echo %BUILDSHELL_CMD%
89 echo You will want to run this each time you start a new Command Prompt. You
90 echo can simply double-click on this batch file from Explorer to launch a
91 echo Command Prompt that has been properly initialized for building gcc4mbed
92 echo based code.
93 echo **************************************************************************
94
95 rem Restore current directory and exit batch file on success.
96 echo %DATE% %TIME% Finished successfully>>%LOGFILE%
97 echo Finished successfully
98 goto Exit
99
100
101
102 rem Logs the command to be run and then executes the command while logging the results.
103 :RunAndLog
104 echo %DATE% %TIME% Executing %*>>%LOGFILE%
105 %* 1>>%LOGFILE% 2>%ERRORFILE%
106 goto :EOF
107
108
109
110 rem Exits the batch file due to error.
111 rem Make sure that any stderr text ends up in win_install.log and then restore
112 rem the current directory before forcing an early exit.
113 :ExitOnError
114 type %ERRORFILE% >>%LOGFILE%
115 echo %DATE% %TIME% Failure forced early exit>>%LOGFILE%
116 type %LOGFILE%
117
118
119 :Exit
120 del %ERRORFILE%
121 popd
122 pause