Fix flakiness and reenable OAuth2Test.MergeSession
[chromium-blink-merge.git] / tools / win / copy-installer.bat
blobd86876076b5068a3a09f544a48749c520dacaab5
1 ECHO OFF\r
2 \r
3 REM Copyright (c) 2012 The Chromium Authors. All rights reserved.\r
4 REM Use of this source code is governed by a BSD-style license that can be\r
5 REM found in the LICENSE file.\r
6 \r
7 REM Copies an installer and symbols from a build directory on a network share\r
8 REM into the directory \[out|build]\[Debug|Release] on the current drive.\r
9 REM\r
10 REM Usage:\r
11 REM   \\build.share\<path_to_checkout>\src\tools\win\copy-installer.bat\r
12 REM\r
13 REM By default, the script will copy the Debug build in the tree, falling back\r
14 REM to the Release build if one is not found.  Similarly, the ninja output\r
15 REM directory is preferred over the devenv output directory.  The x86 build is\r
16 REM preferred over the x64 build.  Specify any of "out|build", "Debug|Release"\r
17 REM (case matters), or "x64" on the command line in any order to influence\r
18 REM selection.  The defaults for location and build type can also be overridden\r
19 REM in a given build tree by creating a "copy-installer.cfg" file alongside the\r
20 REM .gclient file that sets any of OUTPUT, BUILDTYPE, or ARCH variables.\r
21 REM\r
22 REM Install Robocopy for superior performance on Windows XP if desired (it is\r
23 REM present by default on Vista+).\r
25 SETLOCAL\r
27 REM Get the path to the build tree's src directory.\r
28 CALL :_canonicalize "%~dp0..\.."\r
29 SET FROM=%RET%\r
31 REM Read local configuration (set OUTPUT and BUILDTYPE there).\r
32 IF EXIST "%FROM%\..\copy-installer.cfg" CALL "%FROM%\..\copy-installer.cfg"\r
34 REM Read any of OUTPUT, BUILDTYPE, or ARCH from command line.\r
35 FOR %%a IN (%1 %2) do (\r
36 IF "%%a"=="out" SET OUTPUT=out\r
37 IF "%%a"=="build" SET OUTPUT=build\r
38 IF "%%a"=="Debug" SET BUILDTYPE=Debug\r
39 IF "%%a"=="Release" SET BUILDTYPE=Release\r
40 IF "%%s"=="x64" SET ARCH=_x64\r
41 )\r
43 CALL :_find_build\r
44 IF "%OUTPUT%%BUILDTYPE%%ARCH%"=="" (\r
45 ECHO No build found to copy.\r
46 EXIT 1\r
47 )\r
49 SET FROM=%FROM%\%OUTPUT%\%BUILDTYPE%%ARCH%\r
50 SET TO=\%OUTPUT%\%BUILDTYPE%%ARCH%\r
52 REM Figure out what files to copy based on the component type (shared/static).\r
53 IF EXIST "%FROM%\base.dll" (\r
54 SET TOCOPY=setup.exe chrome.7z *.dll\r
55 SET ARCHIVETODELETE=chrome.packed.7z\r
56 SET INSTALLER=setup.exe\r
57 ) ELSE (\r
58 SET TOCOPY=mini_installer.exe mini_installer.exe.pdb\r
59 SET INSTALLER=mini_installer.exe\r
60 )\r
62 SET TOCOPY=%TOCOPY% *.dll.pdb chrome.exe.pdb setup.exe.pdb^\r
63            delegate_execute.exe.pdb\r
65 CALL :_copyfiles\r
67 REM incremental_chrome_dll=1 puts chrome_dll.pdb into the "initial" dir.\r
68 IF EXIST "%FROM%\initial" (\r
69 SET FROM=%FROM%\initial\r
70 SET TOCOPY=*.pdb\r
71 CALL :_copyfiles\r
72 )\r
74 REM Keeping the old chrome.packed.7z around could cause the new setup.exe to\r
75 REM use it instead of the new chrome.7z, delete it to save developers from\r
76 REM debugging nightmares!\r
77 IF NOT "%ARCHIVETODELETE%"=="" (\r
78 IF EXIST "%TO%\%ARCHIVETODELETE%" (\r
79 ECHO Deleting old/deprecated %ARCHIVETODELETE%\r
80 del /Q "%TO%\%ARCHIVETODELETE%"\r
81 )\r
82 )\r
84 ECHO Ready to run/debug %TO%\%INSTALLER%.\r
85 GOTO :EOF\r
87 REM All labels henceforth are subroutines intended to be invoked by CALL.\r
89 REM Canonicalize the first argument, returning it in RET.\r
90 :_canonicalize\r
91 SET RET=%~f1\r
92 GOTO :EOF\r
94 REM Search for a mini_installer.exe in the candidate build outputs.\r
95 :_find_build\r
96 IF "%OUTPUT%"=="" (\r
97 SET OUTPUTS=out build\r
98 ) ELSE (\r
99 SET OUTPUTS=%OUTPUT%\r
100 SET OUTPUT=\r
103 IF "%BUILDTYPE%"=="" (\r
104 SET BUILDTYPES=Debug Release\r
105 ) ELSE (\r
106 SET BUILDTYPES=%BUILDTYPE%\r
107 SET BUILDTYPE=\r
110 FOR %%o IN (%OUTPUTS%) DO (\r
111 FOR %%f IN (%BUILDTYPES%) DO (\r
112 IF EXIST "%FROM%\%%o\%%f\mini_installer.exe" (\r
113 SET OUTPUT=%%o\r
114 SET BUILDTYPE=%%f\r
115 GOTO :EOF\r
117 IF EXIST "%FROM%\%%o\%%f_x64\mini_installer.exe" (\r
118 SET OUTPUT=%%o\r
119 SET BUILDTYPE=%%f\r
120 SET ARCH=_x64\r
121 GOTO :EOF\r
125 GOTO :EOF\r
127 REM Branch to handle copying via robocopy (fast) or xcopy (slow).\r
128 :_copyfiles\r
129 robocopy /? 1> nul 2> nul\r
130 IF NOT "%ERRORLEVEL%"=="9009" (\r
131 robocopy "%FROM%" "%TO%" %TOCOPY% /MT /XX\r
132 ) ELSE (\r
133 IF NOT EXIST "%TO%" mkdir "%TO%"\r
134 call :_xcopy_hack %TOCOPY%\r
136 GOTO :EOF\r
138 REM We can't use a for..in..do loop since we have wildcards, so we make a call\r
139 REM to this with the files to copy.\r
140 :_xcopy_hack\r
141 SHIFT\r
142 IF "%0"=="" GOTO :EOF\r
143 xcopy "%FROM%\%0" "%TO%" /d /y\r
144 GOTO _xcopy_hack\r