# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/toolchain/gcc_toolchain.gni") declare_args() { # Whether unstripped binaries, i.e. compiled with debug symbols, should be # considered runtime_deps rather than stripped ones. mingw_unstripped_runtime_outputs = true } template("mingw_toolchain") { gcc_toolchain(target_name) { assert(defined(invoker.toolchain_root), "toolchain_root must be defined for mingw_toolchain.") assert(defined(invoker.toolchain_args), "toolchain_args must be defined for mingw_toolchain.") toolchain_args = invoker.toolchain_args # Output linker map files for binary size analysis. enable_linker_map = true _mingw_tool_prefix = rebase_path("${invoker.toolchain_root}/bin", root_build_dir) cc = "${_mingw_tool_prefix}/clang" cxx = "${_mingw_tool_prefix}/clang++" ar = "${_mingw_tool_prefix}/llvm-ar" ld = cxx readelf = "${_mingw_tool_prefix}/llvm-readelf" nm = "${_mingw_tool_prefix}/llvm-nm" strip = "${_mingw_tool_prefix}/llvm-strip" use_unstripped_as_runtime_outputs = mingw_unstripped_runtime_outputs executable_extension = ".exe" shlib_extension = ".dll" dylib_extension = ".dll" rlib_extension = ".rlib" rust_abi_target = invoker.rust_abi_target if (rust_abi_target == "x86_64-pc-windows-gnullvm") { cc_command_args = "--target=${rust_abi_target} -Clinker=${_mingw_tool_prefix}/x86_64-w64-mingw32-clang -Clink-arg=-Wl,-Bstatic -Clink-arg=-lunwind -Clink-arg=-fuse-ld=lld -Clink-arg=-Wl,-Bstatic -Clink-arg=-lc++ -Clink-arg=-v -Clink-arg=--target=${rust_abi_target}" } } } mingw_toolchain("mingw_x86_64") { toolchain_root = "//prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw" rust_abi_target = "x86_64-pc-windows-gnullvm" toolchain_args = { current_cpu = "x86_64" current_os = "mingw" use_custom_libcxx = false is_clang = true } }