1# Copyright 2016 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/toolchain/win/midl.gni")
6import("//build/util/lastchange.gni")
7import("//build/win/message_compiler.gni")
8import("//media/media_options.gni")
9import("//remoting/build/config/remoting_build.gni")
10import("//remoting/host/installer/win/generate_clsids.gni")
11
12group("all") {
13  testonly = true
14
15  deps = [
16    ":remoting_console",
17    ":remoting_desktop",
18    ":remoting_me2me_host",
19    ":remoting_native_messaging_host",
20    "//remoting/host/security_key:remote_security_key",
21  ]
22}
23
24# Reference this manifest to indicate that a process is per-monitor DPI aware.
25dpi_aware_manifest = "//remoting/host/win/dpi_aware.manifest"
26
27# Reference this manifest to give the binary the uiAccess privilege.
28enable_uiaccess_manifest = "//remoting/host/win/enable_uiaccess.manifest"
29enable_uiaccess_require_admin_manifest =
30    "//remoting/host/win/enable_uiaccess_require_admin.manifest"
31
32# Depending on this target gives a default executable manifest with the addition
33# of the DPI aware tag.
34windows_manifest("dpi_aware_exe_manifest") {
35  sources = [
36    as_invoker_manifest,
37    common_controls_manifest,
38    default_compatibility_manifest,
39    dpi_aware_manifest,
40  ]
41}
42
43# Depending on this target gives a default executable manifest with the addition
44# of the DPI aware tag and a requestedExecutionLevel of requireAdministrator.
45windows_manifest("dpi_aware_elevated_exe_manifest") {
46  sources = [
47    common_controls_manifest,
48    default_compatibility_manifest,
49    dpi_aware_manifest,
50    require_administrator_manifest,
51  ]
52}
53
54# Depending on this target gives the executable a default manifest with the
55# addition of the DPI aware tag and enables uiAccess.
56windows_manifest("dpi_aware_uiaccess_exe_manifest") {
57  sources = [
58    common_controls_manifest,
59    default_compatibility_manifest,
60    dpi_aware_manifest,
61    enable_uiaccess_manifest,
62  ]
63}
64
65# Depending on this target gives the executable a default manifest with the
66# addition of the DPI aware tag and enables uiAccess.
67windows_manifest("dpi_aware_uiaccess_require_admin_exe_manifest") {
68  sources = [
69    common_controls_manifest,
70    default_compatibility_manifest,
71    dpi_aware_manifest,
72    enable_uiaccess_require_admin_manifest,
73  ]
74}
75
76source_set("win") {
77  sources = [
78    "audio_volume_filter_win.cc",
79    "audio_volume_filter_win.h",
80    "com_imported_mstscax.h",
81    "com_security.cc",
82    "com_security.h",
83    "default_audio_device_change_detector.cc",
84    "default_audio_device_change_detector.h",
85    "evaluate_3d_display_mode.cc",
86    "evaluate_3d_display_mode.h",
87    "evaluate_d3d.cc",
88    "evaluate_d3d.h",
89    "launch_process_with_token.cc",
90    "launch_process_with_token.h",
91    "omaha.cc",
92    "omaha.h",
93    "rdp_client.cc",
94    "rdp_client.h",
95    "rdp_client_window.cc",
96    "rdp_client_window.h",
97    "security_descriptor.cc",
98    "security_descriptor.h",
99    "session_action_executor.cc",
100    "session_action_executor.h",
101    "session_desktop_environment.cc",
102    "session_desktop_environment.h",
103    "session_input_injector.cc",
104    "session_input_injector.h",
105    "window_station_and_desktop.cc",
106    "window_station_and_desktop.h",
107    "worker_process_launcher.cc",
108    "worker_process_launcher.h",
109    "wts_terminal_monitor.cc",
110    "wts_terminal_monitor.h",
111    "wts_terminal_observer.h",
112  ]
113
114  configs += [
115    "//build/config/compiler:wexit_time_destructors",
116    "//remoting/build/config:version",
117  ]
118
119  if (is_clang) {
120    # TODO(thakis): Remove this once midl.exe no longer produces nonstandard
121    # C++ (see the enums in com_imported_mstscax.h).
122    cflags = [ "-Wno-microsoft-enum-forward-reference" ]
123  }
124
125  defines = [ "WEBRTC_CHROMIUM_BUILD" ]
126
127  deps = [
128    "//base:i18n",
129    "//components/policy/core/common",
130    "//crypto",
131    "//ipc",
132    "//remoting/base",
133    "//remoting/host/security_key",
134    "//remoting/host/win:messages",
135    "//remoting/host/win:remoting_lib_idl",
136    "//remoting/protocol",
137    "//remoting/resources",
138    "//services/device/wake_lock/power_save_blocker",
139    "//ui/base",
140    "//ui/events:dom_keycode_converter",
141    "//ui/events/platform",
142  ]
143
144  if (!is_ios) {
145    deps += [ "//components/policy:generated" ]
146  }
147
148  if (enable_webrtc) {
149    deps += [ "//third_party/webrtc_overrides:webrtc_component" ]
150  }
151}
152
153source_set("unit_tests") {
154  testonly = true
155
156  sources = [
157    "elevated_native_messaging_host.cc",
158    "elevated_native_messaging_host.h",
159    "launch_native_messaging_host_process.cc",
160    "launch_native_messaging_host_process.h",
161    "rdp_client_unittest.cc",
162    "worker_process_launcher_unittest.cc",
163  ]
164
165  deps = [
166    "//ipc",
167    "//remoting/host:common",
168    "//remoting/host:test_support",
169    "//remoting/host/it2me:common",
170    "//remoting/host/native_messaging",
171    "//remoting/host/security_key:unit_tests",
172    "//remoting/host/setup:common",
173    "//remoting/proto",
174    "//remoting/resources",
175    "//skia",
176    "//testing/gmock",
177    "//testing/gtest",
178  ]
179}
180
181action("generate_idl") {
182  script = "//build/util/version.py"
183
184  inputs = [ "chromoting_lib_idl.templ" ]
185  outputs = [ "$target_gen_dir/chromoting_lib.idl" ]
186
187  args = [
188    "-e",
189    "RDP_DESKTOP_SESSION_CLSID='$rdp_desktop_session_clsid'",
190    rebase_path(inputs[0], root_build_dir),
191    rebase_path(outputs[0], root_build_dir),
192  ]
193}
194
195midl("remoting_lib_idl") {
196  sources = get_target_outputs(":generate_idl")
197  dynamic_guid = rdp_desktop_session_clsid
198  deps = [ ":generate_idl" ]
199  writes_tlb = true
200}
201
202config("MIDL_config") {
203  if (is_clang) {
204    cflags = [
205      # MIDL generated code has a habit of omitting optional braces.
206      "-Wno-missing-braces",
207
208      # Source files generated by the MIDL compiler trigger warnings with
209      # -Wincompatible-pointer-types enabled.
210      "-Wno-incompatible-pointer-types",
211
212      # Generated code contains unused variables.
213      "-Wno-unused-variable",
214
215      # PROXYFILE_LIST_START is an extern with initializer.
216      "-Wno-extern-initializer",
217    ]
218  }
219}
220
221static_library("remoting_lib_ps") {
222  sources = [
223    "$root_gen_dir/remoting/host/win/chromoting_lib.dlldata.c",
224    "$root_gen_dir/remoting/host/win/chromoting_lib_p.c",
225  ]
226
227  configs -= [ "//build/config/compiler:chromium_code" ]
228  configs += [
229    "//build/config/compiler:no_chromium_code",
230
231    # Must be after no_chromium_code so the -Wno flags appear after the /W3
232    # added by no_chromium_code.
233    ":MIDL_config",
234  ]
235
236  defines = [
237    "ENTRY_PREFIX=Ps",
238    "REGISTER_PROXY_DLL",
239  ]
240
241  deps = [ ":remoting_lib_idl" ]
242}
243
244# Makes the .mc file from the .mc.jinja file.
245remoting_localize("messages_localizing") {
246  sources = [ "host_messages.mc.jinja2" ]
247  locales = remoting_locales
248  locale_dir = resources_locale_dir
249  encoding = "utf-16"
250
251  # This target is funny. It only produces one file and the output doesn't
252  # match the input. We want to generate remoting_host_messages.mc from
253  # host_messages.mg.jinja2. GN complains if it doesn't see a pattern in the
254  # output, so the following pattern produces the name we want with a template
255  # based on the input.
256  #
257  # TODO: This is for GYP compat. We should just make the names match instead.
258  output = "$target_gen_dir/remoting_{{source_name_part}}"
259}
260
261# Makes the .h/.rc files from the .mc file.
262message_compiler("messages") {
263  compile_generated_code = false
264  sources = get_target_outputs(":messages_localizing")
265  deps = [ ":messages_localizing" ]
266}
267
268executable("remoting_console") {
269  configs += [ "//build/config/compiler:wexit_time_destructors" ]
270
271  defines = host_predefines + [ "REMOTING_HOST_BINARY=BINARY_HOST_ME2ME" ]
272
273  deps = [
274    ":dpi_aware_exe_manifest",
275    ":remoting_core",
276    ":remoting_windows_resources",
277  ]
278
279  sources = [
280    "$root_gen_dir/remoting/version.rc",
281    "entry_point.cc",
282  ]
283
284  if (!is_asan) {
285    no_default_deps = true
286    ldflags = [
287      "/ENTRY:HostEntryPoint",
288      # "/NODEFAULTLIB",
289    ]
290  }
291}
292
293executable("remoting_me2me_host") {
294  configs += [
295    "//build/config/compiler:wexit_time_destructors",
296    "//build/config/win:windowed",
297    "//remoting/build/config:remoting_me2me_host",
298  ]
299
300  defines = host_predefines + [ "REMOTING_HOST_BINARY=BINARY_HOST_ME2ME" ]
301
302  deps = [
303    ":dpi_aware_exe_manifest",
304    ":remoting_core",
305    ":remoting_windows_resources",
306  ]
307
308  sources = [
309    "$root_gen_dir/remoting/version.rc",
310    "entry_point.cc",
311  ]
312
313  output_name = "remoting_host"
314
315  if (!is_asan) {
316    no_default_deps = true
317    ldflags = [
318      "/ENTRY:HostEntryPoint",
319      # "/NODEFAULTLIB",
320    ]
321  }
322}
323
324shared_library("remoting_core") {
325  configs += [ "//build/config/compiler:wexit_time_destructors" ]
326
327  defines = host_predefines + [
328              "_ATL_APARTMENT_THREADED",
329              "_ATL_CSTRING_EXPLICIT_CONSTRUCTORS",
330              "_ATL_NO_AUTOMATIC_NAMESPACE",
331              "_ATL_NO_EXCEPTIONS",
332              "REMOTING_HOST_BINARY=BINARY_CORE",
333              "RDP_DESKTOP_SESSION_CLSID=\"$rdp_desktop_session_clsid\"",
334              "HOST_IMPLEMENTATION",
335              "ISOLATION_AWARE_ENABLED=1",
336              "STRICT",
337              "VERSION=$chrome_version_full",
338            ]
339
340  if (is_chrome_branded && is_official_build) {
341    defines += [ "REMOTING_ENABLE_BREAKPAD" ]
342  }
343
344  if (remoting_multi_process != 0 && remoting_rdp_session != 0) {
345    defines += [ "REMOTING_RDP_SESSION" ]
346  }
347
348  if (remoting_multi_process != 0) {
349    defines += [ "REMOTING_MULTI_PROCESS" ]
350  }
351
352  sources = [
353    "$root_gen_dir/remoting/core.rc",
354    "$root_gen_dir/remoting/host/win/remoting_host_messages.rc",
355    "$root_gen_dir/remoting/version.rc",
356    "//remoting/host/desktop_process_main.cc",
357    "//remoting/host/host_main.cc",
358    "//remoting/host/host_main.h",
359    "//remoting/host/it2me/it2me_native_messaging_host_main.cc",
360    "//remoting/host/it2me/it2me_native_messaging_host_main.h",
361    "//remoting/host/setup/host_starter.cc",
362    "//remoting/host/setup/host_starter.h",
363    "//remoting/host/setup/me2me_native_messaging_host_main.cc",
364    "//remoting/host/setup/me2me_native_messaging_host_main.h",
365    "//remoting/host/setup/start_host_main.cc",
366    "//remoting/host/setup/start_host_main.h",
367    "//remoting/host/worker_process_ipc_delegate.h",
368    "chromoting_lib.rc",
369    "chromoting_module.cc",
370    "chromoting_module.h",
371    "core.cc",
372    "core.h",
373    "core_resource.h",
374    "elevated_native_messaging_host.cc",
375    "elevated_native_messaging_host.h",
376    "host_service.cc",
377    "host_service.h",
378    "launch_native_messaging_host_process.cc",
379    "launch_native_messaging_host_process.h",
380    "rdp_desktop_session.cc",
381    "rdp_desktop_session.h",
382    "unprivileged_process_delegate.cc",
383    "unprivileged_process_delegate.h",
384    "wts_session_process_delegate.cc",
385    "wts_session_process_delegate.h",
386  ]
387
388  deps = [
389    ":messages",
390    ":remoting_lib_idl",
391    ":remoting_lib_ps",
392    ":remoting_windows_resources",
393    ":win",
394    "//base",
395    "//base:base_static",
396    "//base/allocator",
397    "//base/third_party/dynamic_annotations",
398    "//build/win:default_exe_manifest",
399    "//ipc",
400    "//mojo/public/cpp/platform",
401    "//mojo/public/cpp/system",
402    "//net",
403    "//remoting/base",
404    "//remoting/base:breakpad",
405    "//remoting/host:host",
406    "//remoting/host:remoting_me2me_host_static",
407    "//remoting/host/it2me:common",
408    "//remoting/host/native_messaging",
409    "//remoting/host/security_key:main",
410    "//remoting/host/setup",
411    "//remoting/protocol",
412    "//sandbox/win:sandbox",  # Should always use Windows version
413    "//services/network/public/mojom",
414    "//third_party/webrtc_overrides:webrtc_component",
415  ]
416
417  ldflags = [
418    "/EXPORT:DllGetClassObject=PsDllGetClassObject,PRIVATE",
419    "/EXPORT:DllCanUnloadNow=PsDllCanUnloadNow,PRIVATE",
420    "/EXPORT:DllRegisterServer=PsDllRegisterServer,PRIVATE",
421    "/EXPORT:DllUnregisterServer=PsDllUnregisterServer,PRIVATE",
422  ]
423
424  libs = [
425    "comctl32.lib",
426    "rpcns4.lib",
427    "rpcrt4.lib",
428    "sas.lib",
429    "uuid.lib",
430    "wtsapi32.lib",
431  ]
432
433  if (is_clang) {
434    cflags = [ "-Wno-header-hygiene" ]
435  }
436}
437
438executable("remoting_desktop") {
439  configs += [
440    "//build/config/compiler:wexit_time_destructors",
441    "//build/config/win:windowed",
442  ]
443
444  defines = host_predefines + [ "REMOTING_HOST_BINARY=BINARY_DESKTOP" ]
445
446  deps = [
447    ":remoting_core",
448    ":remoting_windows_resources",
449  ]
450
451  if (is_official_build) {
452    deps += [ ":dpi_aware_uiaccess_require_admin_exe_manifest" ]
453  } else {
454    deps += [ ":dpi_aware_exe_manifest" ]
455  }
456
457  sources = [
458    "$root_gen_dir/remoting/version.rc",
459    "entry_point.cc",
460  ]
461
462  if (!is_asan) {
463    no_default_deps = true
464    ldflags = [
465      "/ENTRY:HostEntryPoint",
466      # "/NODEFAULTLIB",
467    ]
468  }
469}
470
471executable("remoting_native_messaging_host") {
472  configs += [ "//build/config/compiler:wexit_time_destructors" ]
473
474  defines =
475      host_predefines + [ "REMOTING_HOST_BINARY=BINARY_NATIVE_MESSAGING_HOST" ]
476
477  deps = [
478    ":remoting_core",
479    ":remoting_windows_resources",
480    "//build/win:default_exe_manifest",
481  ]
482
483  sources = [
484    "$root_gen_dir/remoting/version.rc",
485    "../setup/me2me_native_messaging_host_entry_point.cc",
486  ]
487}
488
489remoting_localize("remoting_windows_resources") {
490  deps = [ "//remoting/resources" ]
491
492  sources = [
493    "core.rc.jinja2",
494    "version.rc.jinja2",
495  ]
496
497  variables = [
498    rebase_path(chrome_version_file),
499    rebase_path(remoting_version_file),
500    rebase_path(lastchange_file),
501  ]
502
503  output = "$root_gen_dir/remoting/{{source_name_part}}"
504
505  locale_dir = resources_locale_dir
506
507  encoding = "utf-16"
508
509  locales = remoting_locales
510}
511