# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/ios/rules.gni")
import("//ios/features.gni")

template("cronet_consumer_template") {
  _target_name = target_name

  ios_app_bundle(_target_name) {
    info_plist = "cronet-consumer-Info.plist"

    deps = [
      "//base:base",
    ]

    deps += invoker.deps

    sources = [
      "cronet_consumer_app_delegate.h",
      "cronet_consumer_app_delegate.mm",
      "cronet_consumer_view_controller.h",
      "cronet_consumer_view_controller.m",
      "main.mm",
    ]

    forward_variables_from(invoker,
                           [
                             "bundle_deps",
                             "cflags",
                             "ldflags",
                           ])

    configs += [ "//build/config/compiler:enable_arc" ]
  }
}

cronet_consumer_template("cronet_consumer") {
  deps = [
    "//components/cronet/ios:cronet_framework+link",
  ]
  bundle_deps = [ "//components/cronet/ios:cronet_framework+bundle" ]
}

# TODO(mef): Building "cronet_consumer_static" app with additional_target_cpus
# causes "cronet_static_framework" to build lipo_binary("libcronet") for
# duplicate architecture (e.g. arm64+arm64) and breaks the build.
if (!defined(additional_target_cpus) || additional_target_cpus == []) {
  cronet_consumer_template("cronet_consumer_static") {
    deps = [
      "//components/cronet/ios:cronet_static_framework",
    ]

    cflags = [
      "-F",
      "Static",
    ]

    ldflags = [
      "-F",
      "Static",
    ]
  }
}
