xref: /aosp_15_r20/external/cronet/build/toolchain/win/BUILD.gn (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2013 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/config/win/visual_studio_version.gni")
6import("//build/toolchain/win/toolchain.gni")
7
8assert(is_win, "Should only be running on Windows")
9
10# Setup the Visual Studio state.
11#
12# Its arguments are the VS path and the compiler wrapper tool. It will write
13# "environment.x86" and "environment.x64" to the build directory and return a
14# list to us.
15
16# Copy the VS runtime DLL for the default toolchain to the root build directory
17# so things will run.
18if (current_toolchain == default_toolchain) {
19  if (is_debug) {
20    configuration_name = "Debug"
21  } else {
22    configuration_name = "Release"
23  }
24  exec_script("../../vs_toolchain.py",
25              [
26                "copy_dlls",
27                rebase_path(root_build_dir),
28                configuration_name,
29                target_cpu,
30              ])
31}
32
33if (target_cpu == "x86" || target_cpu == "x64") {
34  win_toolchains("x86") {
35    toolchain_arch = "x86"
36  }
37  win_toolchains("x64") {
38    toolchain_arch = "x64"
39  }
40}
41
42if (target_cpu == "arm64") {
43  win_toolchains("arm64") {
44    toolchain_arch = "arm64"
45  }
46  win_toolchains("x64") {
47    toolchain_arch = "x64"
48  }
49}
50
51# The nacl_win64 toolchain is nearly identical to the plain x64 toolchain.
52# It's used solely for building nacl64.exe (//components/nacl/broker:nacl64).
53# The only reason it's a separate toolchain is so that it can force
54# is_component_build to false in the toolchain_args() block, because
55# building nacl64.exe in component style does not work.
56win_toolchains("nacl_win64") {
57  toolchain_arch = "x64"
58  toolchain_args = {
59    is_component_build = false
60  }
61}
62
63# WinUWP toolchains. Only define these when targeting them.
64
65if (target_os == "winuwp") {
66  assert(target_cpu == "x64" || target_cpu == "x86" || target_cpu == "arm" ||
67         target_cpu == "arm64")
68
69  # Note that //build/toolchain/win/win_toolchain_data.gni collects the output
70  # of setup_toolchain.py, however it's not compatible with the UWP toolchain,
71  # as the UWP toolchain requires the `environment.store_$CPU` variable, instead
72  # of the usual `environment.$CPU`.
73  store_cpu_toolchain_data =
74      exec_script("//build/toolchain/win/setup_toolchain.py",
75                  [
76                    visual_studio_path,
77                    windows_sdk_path,
78                    visual_studio_runtime_dirs,
79                    target_os,
80                    target_cpu,
81                    "environment.store_" + target_cpu,
82                  ],
83                  "scope")
84
85  msvc_toolchain("uwp_" + target_cpu) {
86    environment = "environment.store_" + target_cpu
87    cl = "\"${store_cpu_toolchain_data.vc_bin_dir}/cl.exe\""
88    toolchain_args = {
89      current_os = "winuwp"
90      current_cpu = target_cpu
91      is_clang = false
92    }
93  }
94}
95