- add sources.
[platform/framework/web/crosswalk.git] / src / tools / win / copy-installer.bat
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.  Specify\r
16 REM "out|build" and/or "Debug|Release" (case matters) on the command line in\r
17 REM any order to influence selection.  The defaults for location and build type\r
18 REM can also be overridden in a given build tree by creating a\r
19 REM "copy-installer.cfg" file alongside the .gclient file that sets the OUTPUT\r
20 REM and/or BUILDTYPE 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
24 \r
25 SETLOCAL\r
26 \r
27 REM Get the path to the build tree's src directory.\r
28 CALL :_canonicalize "%~dp0..\.."\r
29 SET FROM=%RET%\r
30 \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
33 \r
34 REM Read OUTPUT and/or BUILDTYPE 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 )\r
41 \r
42 CALL :_find_build\r
43 IF "%OUTPUT%%BUILDTYPE%"=="" (\r
44 ECHO No build found to copy.\r
45 EXIT 1\r
46 )\r
47 \r
48 SET FROM=%FROM%\%OUTPUT%\%BUILDTYPE%\r
49 SET TO=\%OUTPUT%\%BUILDTYPE%\r
50 \r
51 REM Figure out what files to copy based on the component type (shared/static).\r
52 IF EXIST "%FROM%\base.dll" (\r
53 SET TOCOPY=setup.exe setup.exe.manifest chrome.7z *.dll\r
54 SET ARCHIVETODELETE=chrome.packed.7z\r
55 SET INSTALLER=setup.exe\r
56 ) ELSE (\r
57 SET TOCOPY=mini_installer.exe mini_installer.exe.pdb\r
58 SET INSTALLER=mini_installer.exe\r
59 )\r
60 \r
61 SET TOCOPY=%TOCOPY% *.dll.pdb chrome.exe.pdb setup.exe.pdb^\r
62            chrome_frame_helper.exe.pdb chrome_launcher.exe.pdb^\r
63            delegate_execute.exe.pdb\r
64 \r
65 CALL :_copyfiles\r
66 \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
73 \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
83 \r
84 ECHO Ready to run/debug %TO%\%INSTALLER%.\r
85 GOTO :EOF\r
86 \r
87 REM All labels henceforth are subroutines intended to be invoked by CALL.\r
88 \r
89 REM Canonicalize the first argument, returning it in RET.\r
90 :_canonicalize\r
91 SET RET=%~f1\r
92 GOTO :EOF\r
93 \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
101 )\r
102 \r
103 IF "%BUILDTYPE%"=="" (\r
104 SET BUILDTYPES=Debug Release\r
105 ) ELSE (\r
106 SET BUILDTYPES=%BUILDTYPE%\r
107 SET BUILDTYPE=\r
108 )\r
109 \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
116 )\r
117 )\r
118 )\r
119 GOTO :EOF\r
120 \r
121 REM Branch to handle copying via robocopy (fast) or xcopy (slow).\r
122 :_copyfiles\r
123 robocopy /? 1> nul 2> nul\r
124 IF NOT "%ERRORLEVEL%"=="9009" (\r
125 robocopy "%FROM%" "%TO%" %TOCOPY% /MT /XX\r
126 ) ELSE (\r
127 IF NOT EXIST "%TO%" mkdir "%TO%"\r
128 call :_xcopy_hack %TOCOPY%\r
129 )\r
130 GOTO :EOF\r
131 \r
132 REM We can't use a for..in..do loop since we have wildcards, so we make a call\r
133 REM to this with the files to copy.\r
134 :_xcopy_hack\r
135 SHIFT\r
136 IF "%0"=="" GOTO :EOF\r
137 xcopy "%FROM%\%0" "%TO%" /d /y\r
138 GOTO _xcopy_hack\r