Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gnfiles/build/toolchain/msvc/msvc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ template("msvc_toolchain") {
}

toolchain(target_name) {
# Allow callers to override build arguments for this toolchain context.
# For example, msvc_force sets is_clang=false so that all targets built
# under it use MSVC-compatible flags.
if (defined(invoker.toolchain_args)) {
toolchain_args = {
forward_variables_from(invoker.toolchain_args, "*")
}
}

lib_switch = ""
lib_dir_switch = "/LIBPATH:"

Expand Down
32 changes: 32 additions & 0 deletions .gnfiles/build/toolchain/msvc_force/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Copyright © 2025 Agora
# This file is part of TEN Framework, an open source project.
# Licensed under the Apache License, Version 2.0, with certain conditions.
# Refer to the "LICENSE" file in the root directory for more information.
#
# A dedicated MSVC toolchain that always uses cl.exe, even when the global
# is_clang=true. Used for targets that are incompatible with clang-cl
# (e.g., ten_runtime_nodejs.node).
#
# Setting is_clang=false via toolchain_args ensures all targets built under
# this toolchain use MSVC-compatible compiler flags.

import("//.gnfiles/build/toolchain/msvc/msvc.gni")

environment_file = rebase_path("${root_out_dir}/environment.${target_cpu}")
exec_script("//.gnfiles/build/scripts/setup_vs.py",
[
"$vs_version",
"$host_cpu",
"$target_cpu",
environment_file,
],
"list lines")

msvc_toolchain("msvc_force") {
environment = environment_file
use_clang = false
toolchain_args = {
is_clang = false
}
}