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