# 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")

declare_args() {
  # Generate Linker map files. By default it is disabled since they can
  # be quite large.
  chip_generate_link_map_file = false
}

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
    }

    link_generate_map_file = chip_generate_link_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 ]
  }
}
