• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@echo off
2:: Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
3:: reserved. Use of this source code is governed by a BSD-style license
4:: that can be found in the LICENSE file.
5
6:: Set up the environment for use with MSVS tools and then execute whatever
7:: was specified on the command-line.
8
9set RC=
10
11:: Support !! syntax for delayed variable expansion.
12setlocal enabledelayedexpansion
13
14:: Require that platform is passed as the first argument.
15if "%1" == "win32" (
16  set vcvarsbat=vcvars32.bat
17) else if "%1" == "win64" (
18  set vcvarsbat=vcvars64.bat
19) else if "%1" == "winarm64" (
20  set vcvarsbat=vcvarsamd64_arm64.bat
21) else (
22  echo ERROR: Please specify a target platform: win32, win64 or winarm64
23  set ERRORLEVEL=1
24  goto end
25)
26
27:: Check if vcvars is already provided via the environment.
28set vcvars="%CEF_VCVARS%"
29if %vcvars% == "none" goto found_vcvars
30if exist %vcvars% goto found_vcvars
31
32:: Search for the default VS installation path.
33for %%x in ("%PROGRAMFILES(X86)%" "%PROGRAMFILES%") do (
34  for %%y in (2019 2017) do (
35    for %%z in (Professional Enterprise Community BuildTools) do (
36      set vcvars="%%~x\Microsoft Visual Studio\%%y\%%z\VC\Auxiliary\Build\%vcvarsbat%"
37      if exist !vcvars! goto found_vcvars
38    )
39  )
40)
41
42echo ERROR: Failed to find vcvars
43set ERRORLEVEL=1
44goto end
45
46:found_vcvars
47echo vcvars:
48echo %vcvars%
49
50if not %vcvars% == "none" (
51  :: Set this variable to keep VS2017 < 15.5 from changing the current working directory.
52  set "VSCMD_START_DIR=%CD%"
53  call %vcvars%
54)
55
56echo PATH:
57echo %PATH%
58
59:: Remove the first argument and execute the command.
60for /f "tokens=1,* delims= " %%a in ("%*") do set ALL_BUT_FIRST=%%b
61echo command:
62echo %ALL_BUT_FIRST%
63%ALL_BUT_FIRST%
64
65:end
66endlocal & set RC=%ERRORLEVEL%
67goto omega
68
69:returncode
70exit /B %RC%
71
72:omega
73call :returncode %RC%
74