copy-installer.bat 3.4 KB

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