xref: /aosp_15_r20/external/cronet/components/nacl/common/BUILD.gn (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2015 The Chromium Authors
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/buildflag_header.gni")
6import("//components/nacl/features.gni")
7import("//components/nacl/toolchain.gni")
8import("//mojo/public/tools/bindings/mojom.gni")
9
10if (enable_nacl) {
11  # This is separate so it can be used by ../broker:nacl64.
12  static_library("minimal") {
13    sources = [
14      "nacl_cmd_line.cc",
15      "nacl_cmd_line.h",
16      "nacl_constants.cc",
17      "nacl_constants.h",
18      "nacl_messages.cc",
19      "nacl_messages.h",
20      "nacl_process_type.h",
21      "nacl_service.cc",
22      "nacl_service.h",
23      "nacl_types.cc",
24      "nacl_types.h",
25      "nacl_types_param_traits.cc",
26      "nacl_types_param_traits.h",
27    ]
28
29    public_deps = [
30      ":minimal_content_dummy",
31      ":switches",
32      "//ipc",
33      "//sandbox/policy",
34    ]
35
36    deps = [
37      "//base",
38      "//base:base_static",
39      "//content/public/common:content_descriptors",
40      "//mojo/core/embedder",
41      "//native_client/src/trusted/error_code",
42      "//services/service_manager/public/cpp",
43    ]
44  }
45
46  # This exists just to make 'gn check' happy with :minimal.  It can't
47  # depend on //content/public/common or anything like that, because that
48  # would bring in lots more than counts as "minimal" (stuff that should
49  # not be in the nacl64.exe build).
50  source_set("minimal_content_dummy") {
51    check_includes = false
52    sources = [
53      "//content/public/common/content_descriptors.h",
54      "//content/public/common/content_switches.h",
55      "//content/public/common/process_type.h",
56    ]
57
58    # Deps required by the above headers.
59    deps = [ "//media:media_buildflags" ]
60  }
61
62  static_library("common") {
63    sources = [
64      "nacl_host_messages.cc",
65      "nacl_host_messages.h",
66      "pnacl_types.cc",
67      "pnacl_types.h",
68    ]
69
70    public_deps = [
71      ":minimal",
72      ":mojo_bindings",
73      ":switches",
74      "//ipc",
75    ]
76
77    deps = [
78      "//base",
79      "//build:chromeos_buildflags",
80      "//url",
81      "//url/ipc:url_ipc",
82    ]
83
84    if (is_linux || is_chromeos) {
85      sources += [
86        "nacl_paths.cc",
87        "nacl_paths.h",
88      ]
89
90      defines = [ "__STDC_LIMIT_MACROS=1" ]
91
92      deps += [ "//content/common:sandbox_support_linux" ]
93    }
94  }
95
96  mojom("mojo_bindings") {
97    sources = [ "nacl.mojom" ]
98    cpp_typemaps = [
99      {
100        types = [
101          {
102            mojom = "nacl.mojom.NaClErrorCode"
103            cpp = "::NaClErrorCode"
104          },
105        ]
106        traits_headers =
107            [ "//native_client/src/trusted/service_runtime/nacl_error_code.h" ]
108        traits_private_headers =
109            [ "//components/nacl/common/nacl_types_param_traits.h" ]
110        traits_public_deps = [
111          ":minimal",
112          "//native_client/src/trusted/error_code",
113        ]
114        traits_deps = [ "//ipc" ]
115      },
116    ]
117  }
118}
119
120# Depending on this allows targets to unconditionally include
121# nacl_process_type.h without testing whether nacl is enabled.
122source_set("process_type") {
123  public = [ "nacl_process_type.h" ]
124
125  deps = [ "//content/public/common" ]
126}
127
128static_library("switches") {
129  sources = [
130    "nacl_switches.cc",
131    "nacl_switches.h",
132  ]
133}
134
135buildflag_header("buildflags") {
136  header = "buildflags.h"
137  flags = [
138    "ENABLE_NACL=$enable_nacl",
139    "IS_MINIMAL_TOOLCHAIN=$is_minimal_toolchain",
140  ]
141}
142