summaryrefslogtreecommitdiff
path: root/chromium/ios/chrome/content_widget_extension/BUILD.gn
blob: 9572d968d3741d807dc9982744c072552c7a61cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Copyright 2017 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/apple/compile_entitlements.gni")
import("//build/apple/tweak_info_plist.gni")
import("//build/config/ios/rules.gni")
import("//build/config/locales.gni")
import("//ios/build/chrome_build.gni")
import("//ios/build/config.gni")
import("//ios/chrome/tools/strings/generate_localizable_strings.gni")
import("//tools/grit/repack.gni")

assert(ios_deployment_target == "13.0",
       "content_widget_extension must target iOS 13.0")

assert(
    ios_enable_content_widget_extension,
    "ios_enable_content_widget_extension must be true to depend on //ios/chrome/content_widget_extension")

tweak_info_plist("tweak_info_plist") {
  info_plist = "Info.plist"

  # TODO(crbug.com/1140474): Remove once iOS 14.2 reaches mass adoption.
  if (ios_lock_to_version != "") {
    args = [ "--lock-to-version=$ios_lock_to_version" ]
  }
}

compile_entitlements("entitlements") {
  substitutions = [ "IOS_BUNDLE_ID_PREFIX=$ios_app_bundle_id_prefix" ]
  output_name = "$target_gen_dir/content_widget_extension.appex.entitlements"
  entitlements_templates =
      [ "entitlements/external/content_widget_extension.appex.entitlements" ]
}

ios_appex_bundle("content_widget_extension") {
  deps = [
    ":content_widget",
    ":system_strings",
  ]

  extra_substitutions = [
    "CHROME_CHANNEL_SCHEME=$url_channel_scheme",
    "CHROMIUM_SHORT_NAME=$chromium_short_name",
    "WIDGET_EXTENSION_BUNDLE_ID=$chromium_bundle_id.ContentTodayExtension",
  ]

  assert_no_deps = ios_extension_assert_no_deps

  entitlements_target = ":entitlements"
  info_plist_target = ":tweak_info_plist"
  xcode_product_bundle_id = "$chromium_bundle_id.ContentTodayExtension"
}

source_set("content_widget") {
  sources = [
    "content_widget_view.h",
    "content_widget_view.mm",
    "content_widget_view_controller.h",
    "content_widget_view_controller.mm",
    "most_visited_tile_view.h",
    "most_visited_tile_view.mm",
  ]

  deps = [
    "//base",
    "//ios/chrome/common/app_group",
    "//ios/chrome/common/app_group:command",
    "//ios/chrome/common/crash_report",
    "//ios/chrome/common/ntp_tile",
    "//ios/chrome/common/ui/elements",
    "//ios/chrome/common/ui/favicon",
    "//ios/chrome/common/ui/util",
  ]

  frameworks = [
    "Foundation.framework",
    "NotificationCenter.framework",
    "UIKit.framework",
  ]

  assert_no_deps = [ "//ios/chrome/browser" ]

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

repack_locales("packed_resources") {
  input_locales = ios_packed_locales
  output_locales = ios_packed_locales_as_mac_outputs

  source_patterns = [ "$root_gen_dir/ios/content_widget_extension/ios_content_widget_extension_${branding_path_component}_strings_" ]

  deps = [ "//ios/chrome/content_widget_extension/strings:ios_content_widget_extension_${branding_path_component}_strings" ]
}

generate_localizable_strings("system_strings") {
  visibility = [ ":*" ]
  _packed_resources_target = ":packed_resources"
  config_file = "content_widget_extension_localize_strings_config.plist"
  datapack_dir = get_label_info(_packed_resources_target, "target_gen_dir")
  packed_locales = ios_packed_locales_as_mac_outputs
  output_filenames = [ "InfoPlist.strings" ]
  deps = [
    "//ios/chrome/content_widget_extension/strings:ios_content_widget_extension_chromium_strings",

    # Depends on both branding strings target to ensure the proper .h exists
    # (the .plist configuration can only reference one of them, and their
    # content is identical).
    "//ios/chrome/content_widget_extension/strings:ios_content_widget_extension_google_chrome_strings",
    _packed_resources_target,
  ]
}