summaryrefslogtreecommitdiff
path: root/chromium/components/nacl/broker/BUILD.gn
blob: bf0bf3a4d48fdc4b69bd673f5e15459ab1d27306 (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# Copyright 2016 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/config/features.gni")
import("//build/config/compiler/compiler.gni")
import("//services/service_manager/public/service_manifest.gni")

# This file builds nacl64.exe, which is a 64-bit x86 Windows executable
# used only in the 32-bit x86 Windows build.  The :broker code runs both
# in nacl64.exe and in the 32-bit chrome executable, to launch
# nacl64.exe and communicate with it.

assert(enable_nacl)
assert(is_win)
assert(target_cpu == "x86")

source_set("broker") {
  sources = [
    "nacl_broker_listener.cc",
    "nacl_broker_listener.h",
  ]

  deps = [
    "//base",
    "//components/nacl/common:debug_exception_handler",
    "//components/nacl/common:minimal",
    "//components/nacl/common:switches",
    "//content/public/common:static_switches",
    "//ipc",
    "//mojo/edk/system",
    "//sandbox",
    "//services/service_manager/public/cpp",
  ]

  if (current_cpu == target_cpu) {
    deps += [ "//content/public/common" ]
  } else {
    deps += [ ":content_dummy" ]
  }
}

# This exists just to make 'gn check' happy with :broker.  It can't depend
# on //content/public/common or anything like that, because that would
# bring in lots more stuff that should not be in the nacl64.exe build.
source_set("content_dummy") {
  check_includes = false
  sources = [
    "//content/public/common/sandbox_init.h",
    "//content/public/common/sandboxed_process_launcher_delegate.h",
  ]
}

if (current_cpu == "x86") {
  # Tests, packaging rules, etc. will expect to find nacl64.exe in the root
  # of the output directory.  It gets built in a non-default toolchain and
  # so will be delivered in the toolchain output subdirectory.  So this
  # just copies it to the expected place.  Having this target also makes
  # it simpler for things to depend on nacl64, since they don't have to
  # use a toolchain qualifier.
  copy("nacl64") {
    # NOTE: This must match what //build/config/BUILDCONFIG.gn uses
    # as default toolchain for the corresponding x64 build.
    if (is_clang) {
      x64_toolchain = "//build/toolchain/win:clang_nacl_win64"
    } else {
      x64_toolchain = "//build/toolchain/win:nacl_win64"
    }
    nacl64_label = ":nacl64($x64_toolchain)"
    nacl64_out_dir = get_label_info(nacl64_label, "root_out_dir")
    sources = [
      "$nacl64_out_dir/nacl64.exe",
    ]
    if (symbol_level != 0) {
      sources += [ "$nacl64_out_dir/nacl64.exe.pdb" ]
    }
    outputs = [
      "$root_out_dir/{{source_file_part}}",
    ]
    deps = [
      nacl64_label,
    ]
  }
} else if (current_cpu == "x64") {
  # In the x64 toolchain context, build nacl64.exe for real.
  executable("nacl64") {
    configs += [ "//build/config/win:windowed" ]

    # //build/config/compiler:optimize{,_max} adds this for official builds
    # only, as it only reduces binary size and is not necessary for
    # correctness.  But for nacl64.exe, it makes more than a six-fold
    # difference in the binary size, so always use it in release builds.
    # Note that using this flag disables incremental linking.  In debug
    # builds, incremental rebuild time is usually of more concern than
    # binary size, so incremental linking is preferable to size reduction.
    if (!is_debug) {
      ldflags = [ "/OPT:REF" ]
    }

    sources = [
      "//chrome/nacl/nacl_exe_win_64.cc",
    ]

    deps = [
      ":broker",
      ":nacl64_content",
      ":nacl64_crash_reporter_client",
      "//base",
      "//breakpad:breakpad_handler",
      "//build/win:default_exe_manifest",
      "//chrome:nacl64_exe_version",
      "//chrome/install_static:install_static_util",
      "//components/crash/content/app:app_breakpad_mac_win_to_be_deleted",
      "//components/nacl/loader:nacl_helper_win_64",
      "//content/public/common:static_features",
      "//content/public/common:static_switches",
      "//ppapi/proxy:ipc",
      "//sandbox",
    ]
  }

  # This is a tiny subset of //content built specially for nacl64.exe.
  # There are no subcomponents of //content small enough to get just
  # what nacl64.exe needs without bringing in other stuff that causes
  # problems for the build.
  source_set("nacl64_content") {
    sources = [
      "//content/app/sandbox_helper_win.cc",
      "//content/common/sandbox_init_win.cc",
      "//content/common/sandbox_win.cc",
      "//content/public/common/sandboxed_process_launcher_delegate.cc",
    ]

    defines = [
      "COMPILE_CONTENT_STATICALLY",
      "NACL_WIN64",
    ]

    # This defangs 'gn check', which does not like this cherry-picking.
    # All the source files here are part of other proper components
    # under //content, where their #include discipline will be checked.
    check_includes = false

    deps = [
      "//base",
      "//content/public/common:static_switches",
      "//sandbox",
    ]
  }

  source_set("nacl64_crash_reporter_client") {
    sources = [
      "//chrome/app/chrome_crash_reporter_client_win.cc",
      "//chrome/common/crash_keys.cc",
    ]

    defines = [ "NACL_WIN64" ]

    check_includes = false

    deps = [
      "//chrome/common:constants",
      "//chrome/install_static:install_static_util",
      "//chrome/installer/util:with_no_strings",
      "//components/browser_watcher:browser_watcher_client",
      "//components/flags_ui:switches",
      "//components/policy:generated",
      "//content/public/common:static_switches",
      "//gpu/config:crash_keys",
      "//ipc",
    ]
  }
}

service_manifest("nacl_broker_manifest") {
  name = "nacl_broker"
  source = "nacl_broker_manifest.json"
}