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    "//third_party/webrtc_overrides:webrtc_component",
140    "//third_party/wtl",
141    "//ui/base",
142    "//ui/events:dom_keycode_converter",
143    "//ui/events/platform",
144  ]
145
146  if (!is_ios) {
147    deps += [ "//components/policy:generated" ]
148  }
149}
150
151source_set("unit_tests") {
152  testonly = true
153
154  sources = [
155    "elevated_native_messaging_host.cc",
156    "elevated_native_messaging_host.h",
157    "event_trace_data.cc",
158    "event_trace_data.h",
159    "event_trace_data_unittest.cc",
160    "launch_native_messaging_host_process.cc",
161    "launch_native_messaging_host_process.h",
162    "rdp_client_unittest.cc",
163    "worker_process_launcher_unittest.cc",
164  ]
165
166  deps = [
167    "//ipc",
168    "//remoting/host:common",
169    "//remoting/host:test_support",
170    "//remoting/host/it2me:common",
171    "//remoting/host/native_messaging",
172    "//remoting/host/security_key:unit_tests",
173    "//remoting/host/setup:common",
174    "//remoting/proto",
175    "//remoting/resources",
176    "//skia",
177    "//testing/gmock",
178    "//testing/gtest",
179  ]
180}
181
182RDP_DESKTOP_SESSION_PLACEHOLDER_CLSID =
183    "PLACEHOLDER-GUID-6741fd0a-6a8a-5838-a35e-8088697e2088"
184
185midl("remoting_lib_idl") {
186  sources = [ "chromoting_lib.templ" ]
187  dynamic_guids =
188      "$RDP_DESKTOP_SESSION_PLACEHOLDER_CLSID=$rdp_desktop_session_clsid"
189  writes_tlb = true
190}
191
192config("MIDL_config") {
193  if (is_clang) {
194    cflags = [
195      # MIDL generated code has a habit of omitting optional braces.
196      "-Wno-missing-braces",
197
198      # Source files generated by the MIDL compiler trigger warnings with
199      # -Wincompatible-pointer-types enabled.
200      "-Wno-incompatible-pointer-types",
201
202      # Generated code contains unused variables.
203      "-Wno-unused-variable",
204
205      # PROXYFILE_LIST_START is an extern with initializer.
206      "-Wno-extern-initializer",
207    ]
208  }
209}
210
211static_library("remoting_lib_ps") {
212  sources = [
213    "$target_gen_dir/chromoting_lib.dlldata.c",
214    "$target_gen_dir/chromoting_lib_p.c",
215  ]
216
217  configs -= [ "//build/config/compiler:chromium_code" ]
218  configs += [
219    "//build/config/compiler:no_chromium_code",
220
221    # Must be after no_chromium_code so the -Wno flags appear after the /W3
222    # added by no_chromium_code.
223    ":MIDL_config",
224  ]
225
226  defines = [
227    "ENTRY_PREFIX=Ps",
228    "REGISTER_PROXY_DLL",
229  ]
230
231  deps = [ ":remoting_lib_idl" ]
232}
233
234# Makes the .mc file from the .mc.jinja file.
235remoting_localize("messages_localizing") {
236  sources = [ "host_messages.mc.jinja2" ]
237  locales = remoting_locales
238  locale_dir = resources_locale_dir
239  encoding = "utf-16"
240
241  # This target is funny. It only produces one file and the output doesn't
242  # match the input. We want to generate remoting_host_messages.mc from
243  # host_messages.mg.jinja2. GN complains if it doesn't see a pattern in the
244  # output, so the following pattern produces the name we want with a template
245  # based on the input.
246  #
247  # TODO: This is for GYP compat. We should just make the names match instead.
248  output = "$target_gen_dir/remoting_{{source_name_part}}"
249}
250
251# Makes the .h/.rc files from the .mc file.
252message_compiler("messages") {
253  compile_generated_code = false
254  sources = get_target_outputs(":messages_localizing")
255  deps = [ ":messages_localizing" ]
256}
257
258executable("remoting_console") {
259  configs += [ "//build/config/compiler:wexit_time_destructors" ]
260
261  defines = host_predefines + [ "REMOTING_HOST_BINARY=BINARY_HOST_ME2ME" ]
262
263  deps = [
264    ":dpi_aware_exe_manifest",
265    ":remoting_core",
266    ":remoting_windows_resources",
267    "//base:clang_profiling_buildflags",
268  ]
269
270  sources = [
271    "$root_gen_dir/remoting/version.rc",
272    "entry_point.cc",
273  ]
274
275  if (!is_asan && !use_clang_profiling) {
276    no_default_deps = true
277    ldflags = [
278      "/ENTRY:HostEntryPoint",
279      # "/NODEFAULTLIB",
280    ]
281  }
282}
283
284executable("remoting_me2me_host") {
285  configs += [
286    "//build/config/compiler:wexit_time_destructors",
287    "//build/config/win:windowed",
288    "//remoting/build/config:remoting_me2me_host",
289  ]
290
291  defines = host_predefines + [ "REMOTING_HOST_BINARY=BINARY_HOST_ME2ME" ]
292
293  deps = [
294    ":dpi_aware_exe_manifest",
295    ":remoting_core",
296    ":remoting_windows_resources",
297  ]
298
299  sources = [
300    "$root_gen_dir/remoting/version.rc",
301    "entry_point.cc",
302  ]
303
304  output_name = "remoting_host"
305
306  if (!is_asan && !use_clang_profiling) {
307    no_default_deps = true
308    ldflags = [
309      "/ENTRY:HostEntryPoint",
310      # "/NODEFAULTLIB",
311    ]
312  }
313}
314
315shared_library("remoting_core") {
316  configs += [ "//build/config/compiler:wexit_time_destructors" ]
317
318  defines = host_predefines + [
319              "_ATL_APARTMENT_THREADED",
320              "_ATL_CSTRING_EXPLICIT_CONSTRUCTORS",
321              "_ATL_NO_AUTOMATIC_NAMESPACE",
322              "_ATL_NO_EXCEPTIONS",
323              "REMOTING_HOST_BINARY=BINARY_CORE",
324              "RDP_DESKTOP_SESSION_CLSID=\"$rdp_desktop_session_clsid\"",
325              "HOST_IMPLEMENTATION",
326              "ISOLATION_AWARE_ENABLED=1",
327              "STRICT",
328              "VERSION=$chrome_version_full",
329            ]
330
331  if (is_chrome_branded && is_official_build) {
332    defines += [ "REMOTING_ENABLE_BREAKPAD" ]
333  }
334
335  if (remoting_multi_process != 0 && remoting_rdp_session != 0) {
336    defines += [ "REMOTING_RDP_SESSION" ]
337  }
338
339  if (remoting_multi_process != 0) {
340    defines += [ "REMOTING_MULTI_PROCESS" ]
341  }
342
343  sources = [
344    "$root_gen_dir/remoting/core.rc",
345    "$root_gen_dir/remoting/host/win/remoting_host_messages.rc",
346    "$root_gen_dir/remoting/version.rc",
347    "//remoting/host/desktop_process_main.cc",
348    "//remoting/host/host_main.cc",
349    "//remoting/host/host_main.h",
350    "//remoting/host/it2me/it2me_native_messaging_host_main.cc",
351    "//remoting/host/it2me/it2me_native_messaging_host_main.h",
352    "//remoting/host/setup/host_starter.cc",
353    "//remoting/host/setup/host_starter.h",
354    "//remoting/host/setup/host_stopper.cc",
355    "//remoting/host/setup/host_stopper.h",
356    "//remoting/host/setup/me2me_native_messaging_host_main.cc",
357    "//remoting/host/setup/me2me_native_messaging_host_main.h",
358    "//remoting/host/setup/start_host_main.cc",
359    "//remoting/host/setup/start_host_main.h",
360    "//remoting/host/worker_process_ipc_delegate.h",
361    "chromoting_lib.rc",
362    "chromoting_module.cc",
363    "chromoting_module.h",
364    "core.cc",
365    "core.h",
366    "core_resource.h",
367    "elevated_native_messaging_host.cc",
368    "elevated_native_messaging_host.h",
369    "etw_trace_consumer.cc",
370    "etw_trace_consumer.h",
371    "etw_trace_controller.cc",
372    "etw_trace_controller.h",
373    "event_trace_data.cc",
374    "event_trace_data.h",
375    "host_event_file_logger.cc",
376    "host_event_file_logger.h",
377    "host_event_logger.h",
378    "host_service.cc",
379    "host_service.h",
380    "launch_native_messaging_host_process.cc",
381    "launch_native_messaging_host_process.h",
382    "rdp_desktop_session.cc",
383    "rdp_desktop_session.h",
384    "unprivileged_process_delegate.cc",
385    "unprivileged_process_delegate.h",
386    "wts_session_process_delegate.cc",
387    "wts_session_process_delegate.h",
388  ]
389
390  deps = [
391    ":messages",
392    ":remoting_lib_idl",
393    ":remoting_lib_ps",
394    ":remoting_windows_resources",
395    ":win",
396    "//base",
397    "//base:base_static",
398    "//base/allocator",
399    "//base/third_party/dynamic_annotations",
400    "//build/win:default_exe_manifest",
401    "//ipc",
402    "//mojo/public/cpp/platform",
403    "//mojo/public/cpp/system",
404    "//net",
405    "//remoting/base",
406    "//remoting/base:breakpad",
407    "//remoting/host:host",
408    "//remoting/host:remoting_me2me_host_static",
409    "//remoting/host/it2me:common",
410    "//remoting/host/native_messaging",
411    "//remoting/host/security_key:main",
412    "//remoting/host/setup",
413    "//remoting/protocol",
414    "//sandbox/win:sandbox",  # Should always use Windows version
415    "//services/network/public/mojom",
416    "//third_party/webrtc_overrides:webrtc_component",
417  ]
418
419  ldflags = [
420    "/EXPORT:DllGetClassObject=PsDllGetClassObject,PRIVATE",
421    "/EXPORT:DllCanUnloadNow=PsDllCanUnloadNow,PRIVATE",
422    "/EXPORT:DllRegisterServer=PsDllRegisterServer,PRIVATE",
423    "/EXPORT:DllUnregisterServer=PsDllUnregisterServer,PRIVATE",
424  ]
425
426  libs = [
427    "comctl32.lib",
428    "rpcns4.lib",
429    "rpcrt4.lib",
430    "sas.lib",
431    "uuid.lib",
432    "wtsapi32.lib",
433  ]
434
435  if (is_clang) {
436    cflags = [ "-Wno-header-hygiene" ]
437  }
438}
439
440executable("remoting_desktop") {
441  configs += [
442    "//build/config/compiler:wexit_time_destructors",
443    "//build/config/win:windowed",
444  ]
445
446  defines = host_predefines + [ "REMOTING_HOST_BINARY=BINARY_DESKTOP" ]
447
448  deps = [
449    ":remoting_core",
450    ":remoting_windows_resources",
451  ]
452
453  if (is_official_build) {
454    deps += [ ":dpi_aware_uiaccess_require_admin_exe_manifest" ]
455  } else {
456    deps += [ ":dpi_aware_exe_manifest" ]
457  }
458
459  sources = [
460    "$root_gen_dir/remoting/version.rc",
461    "entry_point.cc",
462  ]
463
464  if (!is_asan && !use_clang_profiling) {
465    no_default_deps = true
466    ldflags = [
467      "/ENTRY:HostEntryPoint",
468      # "/NODEFAULTLIB",
469    ]
470  }
471}
472
473executable("remoting_native_messaging_host") {
474  configs += [ "//build/config/compiler:wexit_time_destructors" ]
475
476  defines =
477      host_predefines + [ "REMOTING_HOST_BINARY=BINARY_NATIVE_MESSAGING_HOST" ]
478
479  deps = [
480    ":remoting_core",
481    ":remoting_windows_resources",
482    "//build/win:default_exe_manifest",
483  ]
484
485  sources = [
486    "$root_gen_dir/remoting/version.rc",
487    "../setup/me2me_native_messaging_host_entry_point.cc",
488  ]
489}
490
491remoting_localize("remoting_windows_resources") {
492  deps = [ "//remoting/resources" ]
493
494  sources = [
495    "core.rc.jinja2",
496    "version.rc.jinja2",
497  ]
498
499  variables = [
500    rebase_path(chrome_version_file),
501    rebase_path(remoting_version_file),
502    rebase_path(lastchange_file),
503  ]
504
505  output = "$root_gen_dir/remoting/{{source_name_part}}"
506
507  locale_dir = resources_locale_dir
508
509  encoding = "utf-16"
510
511  locales = remoting_locales
512}
513