2 rem Copyright 2012 Adam Green (http://mbed.org/users/AdamGreen/)
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
8 rem http://www.apache.org/licenses/LICENSE-2.0
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.
17 rem Setup batch file specific environment variables.
20 set LOGFILE
=%ROOTDIR%win_install.log
21 set ERRORFILE
=%ROOTDIR%win_install.err
22 set GCC4ARM_FILENAME
=gcc
-arm
-none
-eabi
-4_6
-2012q1
-20120316.tar.bz2
23 set GCC4ARM_URL
=https
://launchpad.
net/gcc
-arm
-embedded
/4.6/4.6-2012-q1
-update
/+download
/%GCC4ARM_FILENAME%
24 set GCC4ARM_TAR
=%ROOTDIR%%GCC4ARM_FILENAME%
25 set GCC4ARM_MD5
=%ROOTDIR%external\win32\gcc
-arm
-none
-eabi.md5
26 set GCC4ARM_VERSION
=gcc
-arm
-none
-eabi
-4_6
-2012q1
27 set GCC4ARM_EXTRACT
=%ROOTDIR%%GCC4ARM_VERSION%
28 set GCC4ARM_DIR
=%ROOTDIR%gcc
-arm
-none
-eabi
29 set GCC4ARM_BINDIR
=%GCC4ARM_DIR%\bin
30 set GCC4ARM_LIBEXEC
=%GCC4ARM_DIR%\libexec\gcc
\arm
-none
-eabi\
4.6.2
31 set WINBIN_URL
=https
://github.com
/adamgreen
/GCC
-ARM
-Embedded
-20120316/tarball
/master
32 set WINBIN_TAR
=%ROOTDIR%GCC
-ARM
-Embedded
-20120316.tar.gz
33 set WINBIN_MD5
=%ROOTDIR%external\win32\GCC
-ARM
-Embedded.md5
34 set WINBIN_BASEDIR
=%ROOTDIR%GCC
-ARM
-Embedded
35 set WINBIN_DIR
=%WINBIN_BASEDIR%\win32
36 set OUR_MAKE
=%ROOTDIR%external\win32\make.exe
37 set BUILDENV_CMD
=%GCC4ARM_BINDIR%\buildenv.
cmd
38 set BUILDSHELL_CMD
=%ROOTDIR%BuildShell.
cmd
39 set BUILDSHELL_DEBUG_CMD
=%ROOTDIR%BuildShellDebug.
cmd
40 set ERROR_ENCOUNTERED
=0
43 rem Make sure that we are running with current directory set to where this
44 rem batch file is located.
47 rem Initialize install log files.
48 echo Logging install results to
%LOGFILE%
49 echo %DATE% %TIME% Starting
%0 %*>%LOGFILE%
51 echo Downloading GNU Tools
for ARM Embedded Processors...
52 echo %DATE% %TIME% Executing external\win32\curl
-kL0
%GCC4ARM_URL%>>%LOGFILE%
53 external\win32\curl
-kL0
%GCC4ARM_URL% >%GCC4ARM_TAR%
54 if errorlevel 1 goto ExitOnError
56 echo Validating md5 signature of Code Sourcery G
++ Lite...
57 call :RunAndLog external\win32\md5sum
--check
%GCC4ARM_MD5%
58 if errorlevel 1 goto ExitOnError
60 echo Downloading Windows GCC binaries from github...
61 echo %DATE% %TIME% Executing external\win32\curl
-kL0
%WINBIN_URL%>>%LOGFILE%
62 external\win32\curl
-kL0
%WINBIN_URL% >%WINBIN_TAR%
63 if errorlevel 1 goto ExitOnError
65 echo Validating md5 signature of Windows GCC binaries...
66 call :RunAndLog external\win32\md5sum
--check
%WINBIN_MD5%
67 if errorlevel 1 goto ExitOnError
69 echo Extracting GNU Tools
for ARM Embedded Processors...
70 call :RunAndLog rd /s
/q
%GCC4ARM_DIR%
71 call :RunAndLog external\win32
\bsdtar xf
%GCC4ARM_TAR%
72 if errorlevel 1 goto ExitOnError
73 call :RunAndLog move %GCC4ARM_EXTRACT% %GCC4ARM_DIR%
74 if errorlevel 1 goto ExitOnError
76 echo Extracting Windows GCC binaries...
77 call :RunAndLog rd /s
/q
%WINBIN_BASEDIR%
78 call :RunAndLog external\win32
\bsdtar xf
%WINBIN_TAR%
79 for /d
%%i in
(adamgreen
-GCC
-ARM
-Embedded
-*) do call :RunAndLog move %%i
%WINBIN_BASEDIR%
80 if errorlevel 1 goto ExitOnError
82 echo Installing Windows binaries...
83 call :RunAndLog del /q
%GCC4ARM_BINDIR%\
*
84 call :RunAndLog copy %WINBIN_DIR%\arm
-none
-eabi
-* %GCC4ARM_BINDIR%\
85 if errorlevel 1 goto ExitOnError
86 for %%i in
(as g
++ ld objcopy ranlib ar c
++ gcc nm objdump strip
) do call :CopyGccFile %%i
87 if "%ERROR_ENCOUNTERED%"=="1" goto ExitOnError
88 call :RunAndLog rd /s
/q
%GCC4ARM_LIBEXEC%
89 call :RunAndLog xcopy /eiy
%WINBIN_DIR%\libexec
%GCC4ARM_LIBEXEC%
90 if errorlevel 1 goto ExitOnError
92 echo Creating helper scripts...
93 echo @
echo off
>%BUILDENV_CMD%
94 echo REM Uncomment next line and
set destination drive to match mbed
device>>%BUILDENV_CMD%
95 echo REM
SET LPC_DEPLOY
=copy PROJECT.bin f
:\
>>%BUILDENV_CMD%
97 echo SET PATH=%%~dp0
;%%~dp0..\..\external\win32
;%%PATH%%>>%BUILDENV_CMD%
99 echo @
cmd.exe
/K
%%~dp0\gcc
-arm
-none
-eabi
\bin
\buildenv.
cmd>%BUILDSHELL_CMD%
101 echo @
cmd.exe
/K
"set GCC4MBED_TYPE=Debug& %%~dp0\gcc-arm-none-eabi\bin\buildenv.cmd">%BUILDSHELL_DEBUG_CMD%
103 rem Place GNU Tool for ARM Embedded Processors in the path before building gcc4mbed code.
104 set path=%GCC4ARM_BINDIR%;%ROOTDIR%external\win32
;%PATH%
106 echo Performing a clean build of the gcc4mbed samples...
107 call :RunAndLog %OUR_MAKE% clean
108 if errorlevel 1 goto ExitOnError
109 call :RunAndLog %OUR_MAKE%
110 if errorlevel 1 goto ExitOnError
112 echo Cleaning up intermediate
files...
113 call :RunAndLog rd /s
/q
%WINBIN_BASEDIR%
114 call :RunAndLog del /f
%WINBIN_TAR%
115 call :RunAndLog del /f
%GCC4ARM_TAR%
117 echo **************************************************************************
118 echo To build gcc4mbed samples
, you will first need to
run the following batch
119 echo file so that your environment variables are
set correctly
:
120 echo %BUILDSHELL_CMD%
121 echo You will want to
run this each
time you
start a new
Command Prompt. You
122 echo can simply double
-click on this batch file from Explorer to launch a
123 echo Command Prompt that has been properly initialized
for building gcc4mbed
125 echo **************************************************************************
127 rem Restore current directory and exit batch file on success.
128 echo %DATE% %TIME% Finished successfully
>>%LOGFILE%
129 echo Finished successfully
134 rem Logs the command to be run and then executes the command while logging the results.
136 echo %DATE% %TIME% Executing
%*>>%LOGFILE%
137 %* 1>>%LOGFILE% 2>%ERRORFILE%
142 rem Copies a file between GCC directories where one has arm-none-eabi prefix and the other doesn't
144 call :RunAndLog del "%GCC4ARM_DIR%\arm-none-eabi\bin\%1"
145 call :RunAndLog copy /y
"%GCC4ARM_BINDIR%\arm-none-eabi-%1.exe" "%GCC4ARM_DIR%\arm-none-eabi\bin\%1.exe"
146 if errorlevel 1 set ERROR_ENCOUNTERED
=1
150 rem Exits the batch file due to error.
151 rem Make sure that any stderr text ends up in win_install.log and the restore
152 rem the current dictory before forcing an early exit.
154 type %ERRORFILE% >>%LOGFILE%
155 echo %DATE% %TIME% Failure forced early
exit>>%LOGFILE%