1# Copyright 2020 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/config/mac/rules.gni")
6import("//build/util/process_version.gni")
7import("//build/util/version.gni")
8import("//chrome/updater/branding.gni")
9
10app_name = "UpdaterTestApp"
11app_bundle_id = "org.chromium.updatertestapp"
12
13if (is_mac) {
14  app_framework_name = app_name + " Framework"
15}
16
17group("test_app") {
18  deps = [ ":app" ]
19}
20
21process_version("version_header") {
22  sources = [ "//chrome/VERSION" ]
23
24  extra_args = [
25    "-e",
26    "TEST_APP_FULLNAME=\"$app_name\"",
27    "-e",
28    "TEST_APP_BUNDLE_IDENTIFIER=\"$app_bundle_id\"",
29    "-e",
30    "UPDATER_APP_FULLNAME=\"$updater_product_full_name\"",
31    "-e",
32    "UPDATER_APP_BUNDLE_IDENTIFIER=\"$mac_updater_bundle_identifier\"",
33    "-e",
34    "TEST_APP_COMPANY_NAME=\"$updater_company_short_name\"",
35  ]
36
37  template_file = "test_app_version.h.in"
38  output = "$target_gen_dir/test_app_version.h"
39}
40
41source_set("constants") {
42  sources = [
43    "constants.cc",
44    "constants.h",
45  ]
46}
47
48source_set("app_sources") {
49  sources = [
50    "//chrome/updater/app/app.cc",
51    "//chrome/updater/app/app.h",
52    "test_app.cc",
53    "test_app.h",
54    "update_client.cc",
55    "update_client.h",
56  ]
57
58  deps = [
59    ":constants",
60    ":version_header",
61    "//base",
62    "//chrome/updater:base",
63    "//chrome/updater:version_header",
64    "//components/update_client:update_client",
65  ]
66
67  if (is_mac) {
68    sources += [
69      "//chrome/updater/app/server/mac/service_protocol.h",
70      "//chrome/updater/app/server/mac/service_protocol.mm",
71      "//chrome/updater/app/server/mac/update_service_wrappers.h",
72      "//chrome/updater/app/server/mac/update_service_wrappers.mm",
73      "test_app_mac.mm",
74      "update_client_mac.h",
75      "update_client_mac.mm",
76    ]
77
78    deps += [ "//chrome/updater/mac:xpc_names" ]
79
80    frameworks = [ "CoreFoundation.framework" ]
81  }
82
83  if (is_win) {
84    sources += [
85      "test_app_win.cc",
86      "update_client_win.cc",
87      "update_client_win.h",
88    ]
89    deps += [
90      "//chrome/updater/app/server/win:updater_idl_idl",
91      "//chrome/updater/win:lib",
92    ]
93  }
94}
95
96if (is_win) {
97  executable("app") {
98    output_name = "updatertestapp"
99    sources = [ "main_win.cc" ]
100
101    configs += [ "//build/config/win:windowed" ]
102
103    deps = [ ":app_sources" ]
104  }
105}
106
107if (is_mac) {
108  mac_app_bundle("app") {
109    info_plist = "mac/Info.plist"
110    output_name = app_name
111    extra_substitutions = [ "MAC_BUNDLE_IDENTIFIER=$app_bundle_id" ]
112
113    sources = [ "main_mac.cc" ]
114
115    deps = [
116      ":app_sources",
117      ":bundle_versioned_data",
118      ":version_header",
119      "//base",
120    ]
121  }
122
123  bundle_data("bundle_versioned_data") {
124    sources = [ "$root_out_dir/$app_framework_name.framework" ]
125    outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ]
126
127    public_deps = [ ":app_framework" ]
128  }
129
130  bundle_data("bundle_updater") {
131    sources = [ "$root_out_dir/$updater_product_full_name.app" ]
132    outputs = [ "{{bundle_contents_dir}}/Helpers/{{source_file_part}}" ]
133
134    public_deps = [ "//chrome/updater/mac:updater_bundle" ]
135  }
136
137  mac_framework_bundle("app_framework") {
138    output_name = app_framework_name
139
140    framework_version = chrome_version_full
141    framework_contents = [
142      "Helpers",
143      "Resources",
144    ]
145
146    info_plist = "mac/framework-Info.plist"
147    extra_substitutions = [ "CHROMIUM_BUNDLE_ID=$app_bundle_id" ]
148
149    deps = [ ":bundle_updater" ]
150
151    ldflags = [ "-Wl,-install_name,@executable_path/../Frameworks/$app_framework_name.framework/Versions/$chrome_version_full/$app_framework_name" ]
152
153    ldflags += [
154      "-compatibility_version",
155      chrome_dylib_version,
156      "-current_version",
157      chrome_dylib_version,
158    ]
159  }
160}
161