Skip to content

Instantly share code, notes, and snippets.

@wtokuno
Last active July 28, 2023 08:31
Show Gist options
  • Save wtokuno/7f7dc5f4814fbedf323f696368d89ef8 to your computer and use it in GitHub Desktop.
Save wtokuno/7f7dc5f4814fbedf323f696368d89ef8 to your computer and use it in GitHub Desktop.
@echo off
:: ================================================================
:: Workarounds for encoding problems that occur when the system locale is Japanese.
:: ================================================================
@echo Change console output code page to 65001 (UTF-8)
chcp 65001
@echo Enable Python UTF-8 Mode
:: See <https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUTF8>.
set PYTHONUTF8=1
:: ================================================================
:: Install depot_tools
:: See <https://chromium.googlesource.com/chromium/src.git/+/HEAD/docs/windows_build_instructions.md#install>.
:: ================================================================
set "DEPOT_TOOLS_PATH=%~dp0depot_tools"
if exist "%DEPOT_TOOLS_PATH%" (
@echo depot_tools seems already installed since the folder "%DEPOT_TOOLS_PATH%" exists
goto :add_depot_tools_to_path
)
set "DEPOT_TOOLS_BUNDLE=%~dp0depot_tools.zip"
if exist "%DEPOT_TOOLS_BUNDLE%" (
@echo depot_tools bundle is already downloaded in "%DEPOT_TOOLS_BUNDLE%"
goto :extract_depot_tools
)
@echo Download depot_tools bundle and save it to "%DEPOT_TOOLS_BUNDLE%"
:: Windows 10 Insider Build 17063 and later include tar and curl.
:: See <https://devblogs.microsoft.com/commandline/tar-and-curl-come-to-windows/>.
curl -o "%DEPOT_TOOLS_BUNDLE%" "https://storage.googleapis.com/chrome-infra/depot_tools.zip"
:extract_depot_tools
@echo Extract depot_tools bundle to the folder "%DEPOT_TOOLS_PATH%"
mkdir "%DEPOT_TOOLS_PATH%"
tar xf "%DEPOT_TOOLS_BUNDLE%" --directory "%DEPOT_TOOLS_PATH%"
:add_depot_tools_to_path
@echo Add "%DEPOT_TOOLS_PATH%" to the PATH
set "PATH=%DEPOT_TOOLS_PATH%;%PATH%"
@echo Configure depot_tools to use locally installed version of Visual Studio
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
@echo Find Visual Studio 2022 (version 17.x) installation using vswhere
:: See <https://github.com/microsoft/vswhere>.
set "VSWHERE_EXE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
for /f "usebackq tokens=*" %%i in (`"%VSWHERE_EXE%" -version 17 -property installationPath`) do (
set "vs2022_install=%%i"
)
@echo Visual Studio 2022 installation found in "%vs2022_install%"
@echo Run gclient
gclient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment