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