Index: tools/win/copy-installer.bat |
diff --git a/tools/win/copy-installer.bat b/tools/win/copy-installer.bat |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9a7f3b36320f692445399b1c835f7236d30743f2 |
--- /dev/null |
+++ b/tools/win/copy-installer.bat |
@@ -0,0 +1,119 @@ |
+ECHO OFF |
+ |
+REM Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+REM Use of this source code is governed by a BSD-style license that can be |
+REM found in the LICENSE file. |
+ |
+REM Copies an installer and symbols from a build directory on a network share |
+REM into the directory \[out|build]\[Debug|Release] on the current drive. |
+REM |
+REM Usage: |
+REM \\build.share\<path_to_checkout>\src\tools\win\copy-installer.bat |
+REM |
+REM By default, the script will copy the Debug build in the tree, falling back |
+REM to the Release build if one is not found. Similarly, the ninja output |
+REM directory is preferred over the devenv output directory. Specify |
+REM "out|build" and/or "Debug|Release" (case matters) on the command line in |
+REM any order to influence selection. The defaults for location and build type |
+REM can also be overridden in a given build tree by creating a |
+REM "copy-installer.cfg" file alongside the .gclient file that sets the OUTPUT |
+REM and/or BUILDTYPE variables. |
+REM |
+REM Install Robocopy for superior performance on Windows XP if desired (it is |
+REM present by default on Vista+). |
+ |
+SETLOCAL |
+ |
+REM Get the path to the build tree's src directory. |
+CALL :_canonicalize "%~dp0..\.." |
+SET FROM=%RET% |
+ |
+REM Read local configuration (set OUTPUT and BUILDTYPE there). |
+IF EXIST "%FROM%\..\copy-installer.cfg" CALL "%FROM%\..\copy-installer.cfg" |
+ |
+REM Read OUTPUT and/or BUILDTYPE from command line. |
+FOR %%a IN (%1 %2) do ( |
+IF "%%a"=="out" SET OUTPUT=out |
+IF "%%a"=="build" SET OUTPUT=build |
+IF "%%a"=="Debug" SET BUILDTYPE=Debug |
+IF "%%a"=="Release" SET BUILDTYPE=Release |
+) |
+ |
+CALL :_find_build |
+IF "%OUTPUT%%BUILDTYPE%"=="" ( |
+ECHO No build found to copy. |
+EXIT 1 |
+) |
+ |
+SET FROM=%FROM%\%OUTPUT%\%BUILDTYPE% |
+SET TO=\%OUTPUT%\%BUILDTYPE% |
+ |
+REM Figure out what files to copy based on the component type (shared/static). |
+IF EXIST "%FROM%\base.dll" ( |
+SET TOCOPY=*.pdb setup.exe setup.exe.manifest chrome.packed.7z *.dll |
+SET INSTALLER=setup.exe |
+) ELSE ( |
+SET TOCOPY=*.pdb mini_installer.exe |
+SET INSTALLER=mini_installer.exe |
+) |
+ |
+REM Branch to handle copying via robocopy (fast) or xcopy (slow). |
+robocopy /? 1> nul 2> nul |
+IF "%ERRORLEVEL%"=="9009" GOTO _xcopy else GOTO _robocopy |
+ |
+REM robocopy is rsync, basically. |
+:_robocopy |
+robocopy "%FROM%" "%TO%" %TOCOPY% /J /MT |
+GOTO _copydone |
+ |
+REM xcopy is not. |
+:_xcopy |
+IF NOT exist "%TO%" mkdir "%TO%" |
+call :_xcopy_hack %TOCOPY% |
+GOTO _copydone |
+ |
+:_copydone |
+ECHO Ready to run/debug %TO%\%INSTALLER%. |
+GOTO :EOF |
+ |
+REM All labels henceforth are subroutines intended to be invoked by CALL. |
+ |
+REM Search for a mini_installer.exe in the candidate build outputs. |
+:_find_build |
+IF "%OUTPUT%"=="" ( |
+SET OUTPUTS=out build |
+) ELSE ( |
+SET OUTPUTS=%OUTPUT% |
+SET OUTPUT= |
+) |
+ |
+IF "%BUILDTYPE%"=="" ( |
+SET BUILDTYPES=Debug Release |
+) ELSE ( |
+SET BUILDTYPES=%BUILDTYPE% |
+SET BUILDTYPE= |
+) |
+ |
+FOR %%o IN (%OUTPUTS%) DO ( |
+FOR %%f IN (%BUILDTYPES%) DO ( |
+IF EXIST "%FROM%\%%o\%%f\mini_installer.exe" ( |
+SET OUTPUT=%%o |
+SET BUILDTYPE=%%f |
+GOTO :EOF |
+) |
+) |
+) |
+GOTO :EOF |
+ |
+REM We can't use a for..in..do loop since we have wildcards, so we make a call |
+REM to this with the files to copy. |
+:_xcopy_hack |
+SHIFT |
+IF "%0"=="" GOTO :EOF |
+xcopy "%FROM%\%0" "%TO%" /y |
+GOTO _xcopy_hack |
+ |
+REM Canonicalize the first argument, returning it in RET. |
+:_canonicalize |
+SET RET=%~f1 |
+GOTO :EOF |