chromium/remoting/ios/app/remoting_ios_tmpl.gni

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

import("//build/apple/tweak_info_plist.gni")
import("//build/config/chrome_build.gni")
import("//build/config/ios/rules.gni")
import("//build/util/process_version.gni")
import("//remoting/build/config/remoting_build.gni")
import("//remoting/credits/credits.gni")

_remoting_ios_app_source_dir = get_path_info("./", "abspath")

# Arguments
#
#   output_name:
#     string, the filename of the generated .app folder
#
#   info_plist_path:
#     string, path of the Info.plist template
#
#   entitlements_path:
#     string, path of the .entitlements file
#
#   deps:
#     string array, deps to be compiled. E.g. source sets, launch screen, icons.
#
#   bundle_id:
#     (optional) string, the bundle_id. If this is not set, it will come from
#     either branding_Chromium or branding_Chrome
template("ios_remoting_app_tmpl") {
  _app_target_name = target_name
  _info_plist_target_name = "${target_name}_tweak_info_plist"
  tweak_info_plist(_info_plist_target_name) {
    info_plist = invoker.info_plist_path
    args = [ "--platform=ios" ]
  }

  _launchscreen_storyboard_target_name =
      "${target_name}_launchscreen_storyboard"
  bundle_data_ib_file(_launchscreen_storyboard_target_name) {
    source = rebase_path("resources/LaunchScreen.storyboard",
                         ".",
                         _remoting_ios_app_source_dir)
  }

  # Compiles the credits files into the gen directory.
  _credits_resources_target_name = "${target_name}_credits_resources"
  remoting_credits(_credits_resources_target_name) {
    app_target_gen_dir = get_label_info(":$_app_target_name", "target_gen_dir")
    credits_gen_dir =
        "${app_target_gen_dir}/${_app_target_name}_credits_resources"
    target_dir = get_path_info("./", "abspath")
    gn_target = "${target_dir}:${_app_target_name}"
  }

  # Adds the compiled credits files into the bundle.
  _credits_bundle_target_name = "${target_name}_credits_bundle"
  bundle_data(_credits_bundle_target_name) {
    sources = get_target_outputs(":$_credits_resources_target_name")
    public_deps = [ ":$_credits_resources_target_name" ]
    outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
  }

  ios_app_bundle(target_name) {
    forward_variables_from(invoker,
                           [
                             "bundle_deps",
                             "deps",
                             "output_name",
                           ])

    entitlements_path = invoker.entitlements_path
    info_plist_target = ":$_info_plist_target_name"

    if (defined(invoker.bundle_id)) {
      bundle_identifier = invoker.bundle_id
    } else {
      bundle_identifier = remoting_ios_bundle_id
    }

    extra_substitutions = [
      "DISPLAY_NAME=$remoting_ios_display_name",
      "EXECUTABLE_NAME=$output_name",
      "PRODUCT_NAME=$output_name",
      "VERSION_FULL=$remoting_version_full",
      "VERSION_SHORT=$remoting_version_short",
    ]

    frameworks = [
      "Accelerate.framework",
      "AudioToolbox.framework",
      "CoreAudio.framework",
      "CoreData.framework",
      "CoreMIDI.framework",
      "CoreVideo.framework",
      "GLKit.framework",
      "OpenGLES.framework",
      "WebKit.framework",
      "SafariServices.framework",
      "SystemConfiguration.framework",
    ]

    if (!defined(bundle_deps)) {
      bundle_deps = []
    }
    bundle_deps += [
      ":$_credits_bundle_target_name",
      ":$_launchscreen_storyboard_target_name",
    ]

    assert_no_deps = [ "//third_party/ffmpeg:*" ]
  }
}