• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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/nacl/config.gni")
6import("//testing/test.gni")
7
8component("embedder_internal") {
9  output_name = "mojo_core_embedder_internal"
10  public_deps = [
11    ":impl_for_embedder",
12  ]
13  visibility = [
14    ":test_sources",
15    "//mojo:*",
16    "//mojo/core/embedder",
17  ]
18}
19
20# Bits of the EDK library which do not depend on public API linkage. It is
21# not allowed for this target or any of its transitive dependencies to depend
22# on anything under //mojo/public beyond strict C type definitions.
23#
24# This is templated because it's consumed by both the ":embedder_internal"
25# component library as well as the ":mojo_core" shared library. In the former
26# case we want to export symbols, but in the latter case we don't. The template
27# stamps out two nearly identical targets which differ only in what symbols they
28# export.
29template("core_impl_source_set") {
30  source_set(target_name) {
31    if (invoker.for_shared_library) {
32      visibility = [ ":shared_library" ]
33    } else {
34      visibility = [ ":embedder_internal" ]
35    }
36
37    public = [
38      "channel.h",
39      "configuration.h",
40      "connection_params.h",
41      "core.h",
42      "data_pipe_consumer_dispatcher.h",
43      "data_pipe_control_message.h",
44      "data_pipe_producer_dispatcher.h",
45      "dispatcher.h",
46      "embedder/configuration.h",
47      "embedder/process_error_callback.h",
48      "entrypoints.h",
49      "handle_signals_state.h",
50      "handle_table.h",
51      "invitation_dispatcher.h",
52      "message_pipe_dispatcher.h",
53      "node_controller.h",
54      "options_validation.h",
55      "platform_handle_dispatcher.h",
56      "platform_handle_utils.h",
57      "platform_shared_memory_mapping.h",
58      "request_context.h",
59      "scoped_process_handle.h",
60      "shared_buffer_dispatcher.h",
61      "user_message_impl.h",
62    ]
63
64    sources = [
65      "atomic_flag.h",
66      "broker.h",
67      "broker_win.cc",
68      "channel.cc",
69      "channel_win.cc",
70      "configuration.cc",
71      "connection_params.cc",
72      "core.cc",
73      "data_pipe_consumer_dispatcher.cc",
74      "data_pipe_control_message.cc",
75      "data_pipe_producer_dispatcher.cc",
76      "dispatcher.cc",
77      "entrypoints.cc",
78      "handle_table.cc",
79      "invitation_dispatcher.cc",
80      "message_pipe_dispatcher.cc",
81      "node_channel.cc",
82      "node_channel.h",
83      "node_controller.cc",
84      "platform_handle_dispatcher.cc",
85      "platform_handle_in_transit.cc",
86      "platform_handle_in_transit.h",
87      "platform_handle_utils.cc",
88      "platform_shared_memory_mapping.cc",
89      "request_context.cc",
90      "scoped_process_handle.cc",
91      "shared_buffer_dispatcher.cc",
92      "user_message_impl.cc",
93      "watch.cc",
94      "watch.h",
95      "watcher_dispatcher.cc",
96      "watcher_dispatcher.h",
97      "watcher_set.cc",
98      "watcher_set.h",
99    ]
100
101    public_deps = [
102      "//base",
103      "//mojo/core/ports",
104      "//mojo/public/c/system:headers",
105      "//mojo/public/cpp/platform",
106    ]
107
108    if (is_fuchsia) {
109      sources += [ "channel_fuchsia.cc" ]
110
111      public_deps += [ "//third_party/fuchsia-sdk:fdio" ]
112    }
113
114    if (is_posix) {
115      if (!is_nacl || is_nacl_nonsfi) {
116        sources += [
117          "broker_posix.cc",
118          "channel_posix.cc",
119        ]
120      }
121    }
122
123    if (is_mac && !is_ios) {
124      sources += [
125        "mach_port_relay.cc",
126        "mach_port_relay.h",
127      ]
128    }
129
130    if (!is_nacl || is_nacl_nonsfi) {
131      sources += [
132        "broker_host.cc",
133        "broker_host.h",
134      ]
135    }
136
137    defines = []
138    if (invoker.for_shared_library) {
139      defines += [ "MOJO_CORE_SHARED_LIBRARY" ]
140    } else {
141      defines += [ "MOJO_SYSTEM_IMPL_IMPLEMENTATION" ]
142    }
143
144    deps = []
145    if (is_android) {
146      deps += [ "//third_party/ashmem" ]
147    }
148    if (!is_nacl) {
149      deps += [ "//crypto" ]
150    }
151
152    if (is_win) {
153      cflags = [ "/wd4324" ]  # Structure was padded due to __declspec(align()),
154                              # which is uninteresting.
155    }
156
157    # Use target_os == "chromeos" instead of is_chromeos because we need to
158    # build NaCl targets (i.e. IRT) for ChromeOS the same as the rest of ChromeOS.
159    if (is_android || target_os == "chromeos") {
160      defines += [ "MOJO_CORE_LEGACY_PROTOCOL" ]
161    }
162  }
163}
164
165core_impl_source_set("impl_for_embedder") {
166  for_shared_library = false
167}
168
169if (is_chromeos || is_linux || is_android || is_win) {
170  core_impl_source_set("impl_for_shared_library") {
171    for_shared_library = true
172  }
173
174  shared_library("shared_library") {
175    output_name = "mojo_core"
176    sources = [
177      "mojo_core.cc",
178    ]
179    defines = [ "MOJO_CORE_SHARED_LIBRARY" ]
180    deps = [
181      ":impl_for_shared_library",
182      "//mojo/public/c/system:headers",
183    ]
184    if (is_win) {
185      inputs = [
186        "mojo_core.def",
187      ]
188      ldflags = [ "/DEF:" + rebase_path("mojo_core.def", root_build_dir) ]
189    } else {
190      configs += [ ":export_only_thunks_api" ]
191    }
192  }
193
194  if (is_chromeos) {
195    if (target_cpu == "arm" || target_cpu == "arm64") {
196      android32_toolchain = "android_clang_arm"
197      android64_toolchain = "android_clang_arm64"
198    } else {
199      android32_toolchain = "android_clang_x86"
200      android64_toolchain = "android_clang_x64"
201    }
202
203    group("shared_libraries_for_arc") {
204      deps = [
205        ":shared_library_arc32",
206        ":shared_library_arc64",
207      ]
208    }
209
210    copy("shared_library_arc32") {
211      sources = [
212        "${root_out_dir}/${android32_toolchain}/libmojo_core.so",
213      ]
214      outputs = [
215        "${root_out_dir}/libmojo_core_arc32.so",
216      ]
217      deps = [
218        ":shared_library(//build/toolchain/android:${android32_toolchain})",
219      ]
220    }
221
222    copy("shared_library_arc64") {
223      sources = [
224        "${root_out_dir}/${android64_toolchain}/libmojo_core.so",
225      ]
226      outputs = [
227        "${root_out_dir}/libmojo_core_arc64.so",
228      ]
229      deps = [
230        ":shared_library(//build/toolchain/android:${android64_toolchain})",
231      ]
232    }
233  }
234
235  config("export_only_thunks_api") {
236    ldflags = [ "-Wl,--version-script=" +
237                rebase_path("//mojo/core/export_only_thunks_api.lst",
238                            root_build_dir) ]
239  }
240
241  if (is_chromeos || is_linux || is_win) {
242    test("mojo_core_unittests") {
243      sources = [
244        "mojo_core_unittest.cc",
245        "run_all_core_unittests.cc",
246      ]
247
248      deps = [
249        "//base",
250        "//base/test:test_support",
251        "//mojo/public/c/system",
252        "//testing/gtest",
253      ]
254
255      data_deps = [
256        ":shared_library",
257      ]
258    }
259  }
260}
261
262source_set("test_utils") {
263  testonly = true
264
265  sources = [
266    "test_utils.cc",
267    "test_utils.h",
268  ]
269
270  public_deps = [
271    "//mojo/public/c/system",
272    "//mojo/public/cpp/system",
273  ]
274
275  deps = [
276    "//base",
277    "//base/test:test_support",
278    "//mojo/core/test:test_support",
279    "//testing/gtest:gtest",
280  ]
281}
282
283source_set("test_sources") {
284  testonly = true
285  sources = [
286    "channel_unittest.cc",
287    "core_test_base.cc",
288    "core_test_base.h",
289    "core_unittest.cc",
290    "embedder_unittest.cc",
291    "handle_table_unittest.cc",
292    "message_pipe_unittest.cc",
293    "message_unittest.cc",
294    "options_validation_unittest.cc",
295    "platform_handle_dispatcher_unittest.cc",
296    "quota_unittest.cc",
297    "shared_buffer_dispatcher_unittest.cc",
298    "shared_buffer_unittest.cc",
299    "signals_unittest.cc",
300    "trap_unittest.cc",
301  ]
302
303  if (!is_ios) {
304    sources += [
305      "data_pipe_unittest.cc",
306      "invitation_unittest.cc",
307      "multiprocess_message_pipe_unittest.cc",
308      "platform_wrapper_unittest.cc",
309    ]
310  }
311
312  deps = [
313    ":test_utils",
314    "//base",
315    "//base/test:test_support",
316    "//mojo/core:embedder_internal",
317    "//mojo/core/embedder",
318    "//mojo/core/ports:tests",
319    "//mojo/core/test:run_all_unittests",
320    "//mojo/core/test:test_support",
321    "//mojo/public/cpp/system",
322    "//testing/gmock",
323    "//testing/gtest",
324  ]
325}
326