summaryrefslogtreecommitdiff
path: root/chromium/remoting/host/win/BUILD.gn
blob: 1354dab3aa1c42bacc94d2b18ad6d7d6eeb4047e (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# 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/toolchain/win/midl.gni")
import("//build/util/lastchange.gni")
import("//build/win/message_compiler.gni")
import("//media/media_options.gni")
import("//remoting/build/config/remoting_build.gni")
import("//remoting/host/installer/win/generate_clsids.gni")

group("all") {
  testonly = true

  deps = [
    ":remoting_console",
    ":remoting_desktop",
    ":remoting_me2me_host",
    ":remoting_native_messaging_host",
    "//remoting/host/security_key:remote_security_key",
  ]
}

# Reference this manifest to indicate that a process is per-monitor DPI aware.
dpi_aware_manifest = "//remoting/host/win/dpi_aware.manifest"

# Reference this manifest to give the binary the uiAccess privilege.
enable_uiaccess_manifest = "//remoting/host/win/enable_uiaccess.manifest"
enable_uiaccess_require_admin_manifest =
    "//remoting/host/win/enable_uiaccess_require_admin.manifest"

# Depending on this target gives a default executable manifest with the addition
# of the DPI aware tag.
windows_manifest("dpi_aware_exe_manifest") {
  sources = [
    as_invoker_manifest,
    common_controls_manifest,
    default_compatibility_manifest,
    dpi_aware_manifest,
  ]
}

# Depending on this target gives a default executable manifest with the addition
# of the DPI aware tag and a requestedExecutionLevel of requireAdministrator.
windows_manifest("dpi_aware_elevated_exe_manifest") {
  sources = [
    common_controls_manifest,
    default_compatibility_manifest,
    dpi_aware_manifest,
    require_administrator_manifest,
  ]
}

# Depending on this target gives the executable a default manifest with the
# addition of the DPI aware tag and enables uiAccess.
windows_manifest("dpi_aware_uiaccess_exe_manifest") {
  sources = [
    common_controls_manifest,
    default_compatibility_manifest,
    dpi_aware_manifest,
    enable_uiaccess_manifest,
  ]
}

# Depending on this target gives the executable a default manifest with the
# addition of the DPI aware tag and enables uiAccess.
windows_manifest("dpi_aware_uiaccess_require_admin_exe_manifest") {
  sources = [
    common_controls_manifest,
    default_compatibility_manifest,
    dpi_aware_manifest,
    enable_uiaccess_require_admin_manifest,
  ]
}

source_set("win") {
  sources = [
    "audio_volume_filter_win.cc",
    "audio_volume_filter_win.h",
    "com_imported_mstscax.tlh",
    "com_security.cc",
    "com_security.h",
    "default_audio_device_change_detector.cc",
    "default_audio_device_change_detector.h",
    "evaluate_3d_display_mode.cc",
    "evaluate_3d_display_mode.h",
    "evaluate_d3d.cc",
    "evaluate_d3d.h",
    "launch_process_with_token.cc",
    "launch_process_with_token.h",
    "omaha.cc",
    "omaha.h",
    "rdp_client.cc",
    "rdp_client.h",
    "rdp_client_window.cc",
    "rdp_client_window.h",
    "security_descriptor.cc",
    "security_descriptor.h",
    "session_action_executor.cc",
    "session_action_executor.h",
    "session_desktop_environment.cc",
    "session_desktop_environment.h",
    "session_input_injector.cc",
    "session_input_injector.h",
    "window_station_and_desktop.cc",
    "window_station_and_desktop.h",
    "worker_process_launcher.cc",
    "worker_process_launcher.h",
    "wts_terminal_monitor.cc",
    "wts_terminal_monitor.h",
    "wts_terminal_observer.h",
  ]

  configs += [
    "//build/config/compiler:wexit_time_destructors",
    "//remoting/build/config:version",
  ]

  if (is_clang) {
    # TODO(thakis): Remove this once midl.exe no longer produces nonstandard
    # C++ (see the enums in com_imported_mstscax.tlh).
    cflags = [ "-Wno-microsoft-enum-forward-reference" ]
  }

  defines = [ "WEBRTC_CHROMIUM_BUILD" ]

  deps = [
    "//base:i18n",
    "//components/policy/core/common",
    "//crypto",
    "//ipc",
    "//remoting/base",
    "//remoting/host/security_key",
    "//remoting/host/win:messages",
    "//remoting/host/win:remoting_lib_idl",
    "//remoting/protocol",
    "//remoting/resources",
    "//services/device/wake_lock/power_save_blocker",
    "//third_party/webrtc/modules/desktop_capture",
    "//ui/base",
    "//ui/events:dom_keycode_converter",
    "//ui/events/platform",
  ]

  if (!is_ios) {
    deps += [ "//components/policy:generated" ]
  }
}

source_set("unit_tests") {
  testonly = true

  sources = [
    "elevated_native_messaging_host.cc",
    "elevated_native_messaging_host.h",
    "launch_native_messaging_host_process.cc",
    "launch_native_messaging_host_process.h",
    "rdp_client_unittest.cc",
    "worker_process_launcher_unittest.cc",
  ]

  deps = [
    "//ipc",
    "//remoting/host:common",
    "//remoting/host:test_support",
    "//remoting/host/it2me:common",
    "//remoting/host/native_messaging",
    "//remoting/host/security_key:unit_tests",
    "//remoting/host/setup:common",
    "//remoting/proto",
    "//remoting/resources",
    "//skia",
    "//testing/gmock",
    "//testing/gtest",
  ]
}

action("generate_idl") {
  script = "//build/util/version.py"

  inputs = [
    "chromoting_lib_idl.templ",
  ]
  outputs = [
    "$target_gen_dir/chromoting_lib.idl",
  ]

  args = [
    "-e",
    "RDP_DESKTOP_SESSION_CLSID='$rdp_desktop_session_clsid'",
    rebase_path(inputs[0], root_build_dir),
    rebase_path(outputs[0], root_build_dir),
  ]
}

midl("remoting_lib_idl") {
  sources = get_target_outputs(":generate_idl")
  dynamic_guid = rdp_desktop_session_clsid
  deps = [
    ":generate_idl",
  ]
}

config("MIDL_config") {
  if (is_clang) {
    cflags = [
      # MIDL generated code has a habit of omitting optional braces.
      "-Wno-missing-braces",

      # Source files generated by the MIDL compiler trigger warnings with
      # -Wincompatible-pointer-types enabled.
      "-Wno-incompatible-pointer-types",

      # Generated code contains unused variables.
      "-Wno-unused-variable",

      # PROXYFILE_LIST_START is an extern with initializer.
      "-Wno-extern-initializer",
    ]
  }
}

static_library("remoting_lib_ps") {
  sources = [
    "$root_gen_dir/remoting/host/win/chromoting_lib.dlldata.c",
    "$root_gen_dir/remoting/host/win/chromoting_lib_p.c",
  ]

  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",

    # Must be after no_chromium_code so the -Wno flags appear after the /W3
    # added by no_chromium_code.
    ":MIDL_config",
  ]

  defines = [
    "ENTRY_PREFIX=Ps",
    "REGISTER_PROXY_DLL",
  ]

  deps = [
    ":remoting_lib_idl",
  ]
}

# Makes the .mc file from the .mc.jinja file.
remoting_localize("messages_localizing") {
  sources = [
    "host_messages.mc.jinja2",
  ]
  locales = remoting_locales
  locale_dir = webapp_locale_dir
  encoding = "utf-16"

  # This target is funny. It only produces one file and the output doesn't
  # match the input. We want to generate remoting_host_messages.mc from
  # host_messages.mg.jinja2. GN complains if it doesn't see a pattern in the
  # output, so the following pattern produces the name we want with a template
  # based on the input.
  #
  # TODO: This is for GYP compat. We should just make the names match instead.
  output = "$target_gen_dir/remoting_{{source_name_part}}"
}

# Makes the .h/.rc files from the .mc file.
message_compiler("messages") {
  compile_generated_code = false
  sources = get_target_outputs(":messages_localizing")
  deps = [
    ":messages_localizing",
  ]
}

executable("remoting_console") {
  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  defines = host_predefines + [ "REMOTING_HOST_BINARY=BINARY_HOST_ME2ME" ]

  deps = [
    ":dpi_aware_exe_manifest",
    ":remoting_core",
    ":remoting_windows_resources",
  ]

  sources = [
    "$root_gen_dir/remoting/version.rc",
    "entry_point.cc",
  ]

  if (!is_asan) {
    no_default_deps = true
    ldflags = [
      "/ENTRY:HostEntryPoint",
      # "/NODEFAULTLIB",
    ]
  }
}

executable("remoting_me2me_host") {
  configs += [
    "//build/config/compiler:wexit_time_destructors",
    "//build/config/win:windowed",
    "//remoting/build/config:remoting_me2me_host",
  ]

  defines = host_predefines + [ "REMOTING_HOST_BINARY=BINARY_HOST_ME2ME" ]

  deps = [
    ":dpi_aware_exe_manifest",
    ":remoting_core",
    ":remoting_windows_resources",
  ]

  sources = [
    "$root_gen_dir/remoting/version.rc",
    "entry_point.cc",
  ]

  output_name = "remoting_host"

  if (!is_asan) {
    no_default_deps = true
    ldflags = [
      "/ENTRY:HostEntryPoint",
      # "/NODEFAULTLIB",
    ]
  }
}

shared_library("remoting_core") {
  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  defines = host_predefines + [
              "_ATL_APARTMENT_THREADED",
              "_ATL_CSTRING_EXPLICIT_CONSTRUCTORS",
              "_ATL_NO_AUTOMATIC_NAMESPACE",
              "_ATL_NO_EXCEPTIONS",
              "REMOTING_HOST_BINARY=BINARY_CORE",
              "RDP_DESKTOP_SESSION_CLSID=\"$rdp_desktop_session_clsid\"",
              "HOST_IMPLEMENTATION",
              "ISOLATION_AWARE_ENABLED=1",
              "STRICT",
              "VERSION=$chrome_version_full",
            ]

  if (is_chrome_branded && is_official_build) {
    defines += [ "REMOTING_ENABLE_BREAKPAD" ]
  }

  if (remoting_multi_process != 0 && remoting_rdp_session != 0) {
    defines += [ "REMOTING_RDP_SESSION" ]
  }

  if (remoting_multi_process != 0) {
    defines += [ "REMOTING_MULTI_PROCESS" ]
  }

  sources = [
    "$root_gen_dir/remoting/core.rc",
    "$root_gen_dir/remoting/host/win/remoting_host_messages.rc",
    "$root_gen_dir/remoting/version.rc",
    "//remoting/host/desktop_process_main.cc",
    "//remoting/host/host_main.cc",
    "//remoting/host/host_main.h",
    "//remoting/host/it2me/it2me_native_messaging_host_main.cc",
    "//remoting/host/it2me/it2me_native_messaging_host_main.h",
    "//remoting/host/setup/host_starter.cc",
    "//remoting/host/setup/host_starter.h",
    "//remoting/host/setup/me2me_native_messaging_host_main.cc",
    "//remoting/host/setup/me2me_native_messaging_host_main.h",
    "//remoting/host/setup/start_host_main.cc",
    "//remoting/host/setup/start_host_main.h",
    "//remoting/host/worker_process_ipc_delegate.h",
    "chromoting_lib.rc",
    "chromoting_module.cc",
    "chromoting_module.h",
    "core.cc",
    "core.h",
    "core_resource.h",
    "elevated_native_messaging_host.cc",
    "elevated_native_messaging_host.h",
    "host_service.cc",
    "host_service.h",
    "launch_native_messaging_host_process.cc",
    "launch_native_messaging_host_process.h",
    "rdp_desktop_session.cc",
    "rdp_desktop_session.h",
    "unprivileged_process_delegate.cc",
    "unprivileged_process_delegate.h",
    "wts_session_process_delegate.cc",
    "wts_session_process_delegate.h",
  ]

  deps = [
    ":messages",
    ":remoting_lib_idl",
    ":remoting_lib_ps",
    ":remoting_windows_resources",
    ":win",
    "//base",
    "//base:base_static",
    "//base/allocator",
    "//base/third_party/dynamic_annotations",
    "//build/win:default_exe_manifest",
    "//ipc",
    "//mojo/public/cpp/platform",
    "//mojo/public/cpp/system",
    "//net",
    "//remoting/base",
    "//remoting/base:breakpad",
    "//remoting/host:host",
    "//remoting/host:remoting_me2me_host_static",
    "//remoting/host/it2me:common",
    "//remoting/host/native_messaging",
    "//remoting/host/security_key:main",
    "//remoting/host/setup",
    "//remoting/protocol",
    "//sandbox/win:sandbox",  # Should always use Windows version
    "//services/network/public/mojom",
    "//third_party/webrtc/modules/desktop_capture",
  ]

  ldflags = [
    "/EXPORT:DllGetClassObject=PsDllGetClassObject,PRIVATE",
    "/EXPORT:DllCanUnloadNow=PsDllCanUnloadNow,PRIVATE",
    "/EXPORT:DllRegisterServer=PsDllRegisterServer,PRIVATE",
    "/EXPORT:DllUnregisterServer=PsDllUnregisterServer,PRIVATE",
  ]

  libs = [
    "comctl32.lib",
    "rpcns4.lib",
    "rpcrt4.lib",
    "sas.lib",
    "uuid.lib",
    "wtsapi32.lib",
  ]

  if (is_clang) {
    cflags = [ "-Wno-header-hygiene" ]
  }
}

executable("remoting_desktop") {
  configs += [
    "//build/config/compiler:wexit_time_destructors",
    "//build/config/win:windowed",
  ]

  defines = host_predefines + [ "REMOTING_HOST_BINARY=BINARY_DESKTOP" ]

  deps = [
    ":remoting_core",
    ":remoting_windows_resources",
  ]

  if (is_official_build) {
    deps += [ ":dpi_aware_uiaccess_require_admin_exe_manifest" ]
  } else {
    deps += [ ":dpi_aware_exe_manifest" ]
  }

  sources = [
    "$root_gen_dir/remoting/version.rc",
    "entry_point.cc",
  ]

  if (!is_asan) {
    no_default_deps = true
    ldflags = [
      "/ENTRY:HostEntryPoint",
      # "/NODEFAULTLIB",
    ]
  }
}

executable("remoting_native_messaging_host") {
  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  defines =
      host_predefines + [ "REMOTING_HOST_BINARY=BINARY_NATIVE_MESSAGING_HOST" ]

  deps = [
    ":remoting_core",
    ":remoting_windows_resources",
    "//build/win:default_exe_manifest",
  ]

  sources = [
    "$root_gen_dir/remoting/version.rc",
    "../setup/me2me_native_messaging_host_entry_point.cc",
  ]
}

remoting_localize("remoting_windows_resources") {
  deps = [
    "//remoting/resources",
  ]

  sources = [
    "core.rc.jinja2",
    "version.rc.jinja2",
  ]

  variables = [
    rebase_path(chrome_version_file),
    rebase_path(remoting_version_file),
    rebase_path(lastchange_file),
  ]

  output = "$root_gen_dir/remoting/{{source_name_part}}"

  locale_dir = webapp_locale_dir

  encoding = "utf-16"

  locales = remoting_locales
}
# TODO(GYP) More Windows remoting targets from remoting_host_win.gypi