BUILD.gn 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. # Copyright 2018 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. import("//build/config/chrome_build.gni")
  5. import("//build/config/ui.gni")
  6. import("//build/toolchain/win/midl.gni")
  7. import("//chrome/process_version_rc_template.gni")
  8. import("//testing/test.gni")
  9. midl("elevation_service_idl") {
  10. sources = [ "elevation_service_idl.idl" ]
  11. writes_tlb = true
  12. }
  13. # Must be in a config because of how GN orders flags (otherwise /W4 will appear
  14. # after this, and turn it back on).
  15. config("no-missing-braces") {
  16. # Macros invoked by WRL CoCreatableClass omit optional braces.
  17. cflags = [ "-Wno-missing-braces" ]
  18. }
  19. # This service needs to work with Windows 7, so explicitly setting the defines
  20. # to reflect this. Otherwise, WRL uses APIs that are only available in later
  21. # Windows versions.
  22. config("winver") {
  23. defines = [
  24. "NTDDI_VERSION=NTDDI_WIN7",
  25. "_WIN32_WINNT=_WIN32_WINNT_WIN7",
  26. "WINVER=_WIN32_WINNT_WIN7",
  27. ]
  28. }
  29. executable("elevation_service") {
  30. sources = [
  31. "elevation_service.cc",
  32. "elevation_service.rc",
  33. ]
  34. configs -= [
  35. "//build/config/compiler:cet_shadow_stack",
  36. "//build/config/win:console",
  37. ]
  38. configs += [ "//build/config/win:windowed" ]
  39. configs += [ ":no-missing-braces" ]
  40. configs -= [ "//build/config/win:winver" ]
  41. configs += [ ":winver" ]
  42. deps = [
  43. ":lib",
  44. ":version_resources",
  45. "//base",
  46. "//build/win:default_exe_manifest",
  47. "//chrome/install_static:install_static_util",
  48. "//chrome/install_static:primary_module",
  49. "//components/crx_file",
  50. "//third_party/zlib/google:zip",
  51. ]
  52. }
  53. source_set("public_headers") {
  54. sources = [ "elevator.h" ]
  55. deps = [ "//base" ]
  56. public_deps = [ ":elevation_service_idl" ]
  57. }
  58. source_set("lib") {
  59. visibility = [ ":*" ]
  60. sources = [
  61. "caller_validation.cc",
  62. "caller_validation.h",
  63. "elevated_recovery_impl.cc",
  64. "elevated_recovery_impl.h",
  65. "elevator.cc",
  66. "service_main.cc",
  67. "service_main.h",
  68. ]
  69. configs += [ ":no-missing-braces" ]
  70. configs -= [ "//build/config/win:winver" ]
  71. configs += [ ":winver" ]
  72. deps = [
  73. "//base",
  74. "//chrome/install_static:install_static_util",
  75. "//components/crx_file:crx_file",
  76. "//third_party/zlib/google:zip",
  77. ]
  78. public_deps = [ ":public_headers" ]
  79. libs = [
  80. "crypt32.lib",
  81. "rpcrt4.lib",
  82. ]
  83. }
  84. process_version_rc_template("version_resources") {
  85. sources = [ "elevation_service_exe.ver" ]
  86. output = "$target_gen_dir/elevation_service_exe.rc"
  87. }
  88. copy("elevation_service_unittests_files") {
  89. sources = [
  90. "//components/test/data/crx_file/valid_no_publisher.crx3",
  91. "//components/test/data/crx_file/valid_publisher.crx3",
  92. "//components/test/data/update_client/ChromeRecovery.crx3",
  93. ]
  94. outputs = [ "$root_out_dir/elevated_recovery_unittest/{{source_file_part}}" ]
  95. }
  96. test("elevation_service_unittests") {
  97. use_xvfb = use_xvfb_in_this_config
  98. sources = [
  99. "caller_validation_unittest.cc",
  100. "elevated_recovery_unittest.cc",
  101. "elevator_unittest.cc",
  102. "run_all_unittests.cc",
  103. "scoped_mock_context.cc",
  104. "scoped_mock_context.h",
  105. "service_main_unittest.cc",
  106. ]
  107. configs -= [ "//build/config/win:winver" ]
  108. configs += [ ":winver" ]
  109. deps = [
  110. ":lib",
  111. "//base",
  112. "//base/test:test_support",
  113. "//chrome/elevation_service:elevation_service_idl",
  114. "//chrome/install_static:install_static_util",
  115. "//chrome/install_static/test:test_support",
  116. "//components/crx_file",
  117. "//testing/gtest",
  118. "//third_party/zlib/google:zip",
  119. ]
  120. data_deps = [
  121. ":elevation_service",
  122. ":elevation_service_unittests_files",
  123. ]
  124. }