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