# Copyright (c) 2020 Project CHIP Authors
#
# 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_overrides/pigweed.gni")
import("$dir_pw_toolchain/generate_toolchain.gni")

template("gcc_toolchain") {
  invoker_toolchain_args = invoker.toolchain_args

  _toolchain = {
    name = target_name

    ar = "ar"
    if (invoker_toolchain_args.is_clang) {
      cc = "clang"
      cxx = "clang++"
    } else {
      cc = "gcc"
      cxx = "g++"
    }

    if (defined(invoker.ar)) {
      ar = invoker.ar
    }
    if (defined(invoker.cc)) {
      cc = invoker.cc
    }
    if (defined(invoker.cxx)) {
      cxx = invoker.cxx
    }

    if (defined(invoker.link_generate_map_file)) {
      link_generate_map_file = invoker.link_generate_map_file
    }

    is_host_toolchain = invoker_toolchain_args.current_os == host_os
    link_group = invoker_toolchain_args.current_os != "mac" &&
                 invoker_toolchain_args.current_os != "ios"

    defaults = {
      forward_variables_from(invoker_toolchain_args, "*")
    }
  }

  generate_toolchains("gcc_toolchains") {
    toolchains = [ _toolchain ]
  }
}
