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
23 set GCC4ARM_FILENAME
=gcc
-arm
-none
-eabi
-4_7
-2012q4
-20121208-linux.tar.bz2
24 set GCC4ARM_URL
=https
://launchpad.
net/gcc
-arm
-embedded
/4.7/4.7-2012-q4
-major
/+download
/%GCC4ARM_FILENAME%
25 set GCC4ARM_TAR
=%ROOTDIR%%GCC4ARM_FILENAME%
26 set GCC4ARM_MD5
=%ROOTDIR%build\win32\gcc
-arm
-none
-eabi.md5
27 set GCC4ARM_VERSION
=gcc
-arm
-none
-eabi
-4_7
-2012q4
28 set GCC4ARM_EXTRACT
=%ROOTDIR%%GCC4ARM_VERSION%
29 set GCC4ARM_DIR
=%ROOTDIR%gcc
-arm
-none
-eabi
30 set GCC4ARM_BINDIR
=%GCC4ARM_DIR%\bin
31 set GCC4ARM_LIBEXEC
=%GCC4ARM_DIR%\lib\gcc
\arm
-none
-eabi\
4.7.3
32 set WINBIN_URL
=https
://github.com
/adamgreen
/GCC
-ARM
-Embedded
-20121208/tarball
/master
33 set WINBIN_TAR
=%ROOTDIR%GCC
-ARM
-Embedded
-20121208.tar.gz
35 set WINBIN_MD5
=%ROOTDIR%build\win32\GCC
-ARM
-Embedded.md5
36 set WINBIN_BASEDIR
=%ROOTDIR%GCC
-ARM
-Embedded
37 set WINBIN_DIR
=%WINBIN_BASEDIR%\win32
38 set OUR_MAKE
=%ROOTDIR%build\win32\make.exe
39 set BUILDENV_CMD
=%GCC4ARM_BINDIR%\buildenv.
cmd
40 set BUILDSHELL_CMD
=%ROOTDIR%BuildShell.
cmd
41 set ERROR_ENCOUNTERED
=0
44 rem Make sure that we are running with current directory set to where this
45 rem batch file is located.
48 rem Initialize install log files.
49 echo Logging install results to
%LOGFILE%
50 echo %DATE% %TIME% Starting
%0 %*>%LOGFILE%
52 echo Downloading GNU Tools
for ARM Embedded Processors...
53 echo %DATE% %TIME% Executing build\win32\curl
-kL0
%GCC4ARM_URL%>>%LOGFILE%
54 build\win32\curl
-kL0
%GCC4ARM_URL% >%GCC4ARM_TAR%
55 if errorlevel 1 goto ExitOnError
57 echo Validating md5 signature of Code Sourcery G
++ Lite...
58 call :RunAndLog build\win32\md5sum
--check
%GCC4ARM_MD5%
59 if errorlevel 1 goto ExitOnError
61 echo Downloading Windows GCC binaries from github...
62 echo %DATE% %TIME% Executing build\win32\curl
-kL0
%WINBIN_URL%>>%LOGFILE%
63 build\win32\curl
-kL0
%WINBIN_URL% >%WINBIN_TAR%
64 if errorlevel 1 goto ExitOnError
66 echo Validating md5 signature of Windows GCC binaries...
67 call :RunAndLog build\win32\md5sum
--check
%WINBIN_MD5%
68 if errorlevel 1 goto ExitOnError
70 echo Extracting GNU Tools
for ARM Embedded Processors...
71 call :RunAndLog rd /s
/q
%GCC4ARM_EXTRACT%
72 call :RunAndLog rd /s
/q
%GCC4ARM_DIR%
73 call :RunAndLog build\win32
\bsdtar xf
%GCC4ARM_TAR%
74 if errorlevel 1 goto ExitOnError
75 call :RunAndLog move %GCC4ARM_EXTRACT% %GCC4ARM_DIR%
76 if errorlevel 1 goto ExitOnError
78 echo Extracting Windows GCC binaries...
79 call :RunAndLog rd /s
/q
%WINBIN_BASEDIR%
80 call :RunAndLog build\win32
\bsdtar xf
%WINBIN_TAR%
81 for /d
%%i in
(adamgreen
-GCC
-ARM
-Embedded
-*) do call :RunAndLog move %%i
%WINBIN_BASEDIR%
82 if errorlevel 1 goto ExitOnError
84 echo Installing Windows binaries...
85 call :RunAndLog del /q
%GCC4ARM_BINDIR%\
*
86 call :RunAndLog copy %WINBIN_DIR%\arm
-none
-eabi
-* %GCC4ARM_BINDIR%\
87 if errorlevel 1 goto ExitOnError
88 for %%i in
(as g
++ ld objcopy ranlib ar c
++ gcc nm objdump strip
) do call :CopyGccFile %%i
89 if "%ERROR_ENCOUNTERED%"=="1" goto ExitOnError
90 call :RunAndLog xcopy /eiy
%WINBIN_DIR%\libexec
%GCC4ARM_LIBEXEC%
91 if errorlevel 1 goto ExitOnError
93 echo Creating helper scripts...
94 echo @
echo off
>%BUILDENV_CMD%
95 echo REM Uncomment next line and
set destination drive to match mbed
device>>%BUILDENV_CMD%
96 echo REM
SET LPC_DEPLOY
=copy PROJECT.bin f
:\
>>%BUILDENV_CMD%
98 echo SET PATH=%%~dp0
;%%~dp0..\..
\build\win32
;%%PATH%%>>%BUILDENV_CMD%
100 echo @
cmd.exe
/K
%%~dp0\gcc
-arm
-none
-eabi
\bin
\buildenv.
cmd>%BUILDSHELL_CMD%
102 echo Cleaning up intermediate
files...
103 call :RunAndLog rd /s
/q
%WINBIN_BASEDIR%
104 call :RunAndLog del /f
%WINBIN_TAR%
105 call :RunAndLog del /f
%GCC4ARM_TAR%
107 echo **************************************************************************
108 echo To build Smoothie
, you will first need to
run the following batch
109 echo file so that your environment variables are
set correctly
:
110 echo %BUILDSHELL_CMD%
111 echo You will want to
run this each
time you
start a new
Command Prompt. You
112 echo can simply double
-click on this batch file from Explorer to launch a
113 echo Command Prompt that has been properly initialized
for building.
114 echo **************************************************************************
116 rem Restore current directory and exit batch file on success.
117 echo %DATE% %TIME% Finished successfully
>>%LOGFILE%
118 echo Finished successfully
123 rem Logs the command to be run and then executes the command while logging the results.
125 echo %DATE% %TIME% Executing
%*>>%LOGFILE%
126 %* 1>>%LOGFILE% 2>%ERRORFILE%
131 rem Copies a file between GCC directories where one has arm-none-eabi prefix and the other doesn't
133 call :RunAndLog del "%GCC4ARM_DIR%\arm-none-eabi\bin\%1"
134 call :RunAndLog copy /y
"%GCC4ARM_BINDIR%\arm-none-eabi-%1.exe" "%GCC4ARM_DIR%\arm-none-eabi\bin\%1.exe"
135 if errorlevel 1 set ERROR_ENCOUNTERED
=1
139 rem Exits the batch file due to error.
140 rem Make sure that any stderr text ends up in win_install.log and the restore
141 rem the current dictory before forcing an early exit.
143 type %ERRORFILE% >>%LOGFILE%
144 echo %DATE% %TIME% Failure forced early
exit>>%LOGFILE%