BUILD.gn 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. # Copyright 2015 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/c++/c++.gni")
  5. import("//build/config/chromeos/ui_mode.gni")
  6. import("//build/config/compiler/compiler.gni")
  7. import("//build/config/nacl/config.gni")
  8. import("//components/nacl/features.gni")
  9. import("//components/nacl/toolchain.gni")
  10. import("//testing/test.gni")
  11. assert(enable_nacl)
  12. if (current_cpu != "arm64") {
  13. # This is separate so it can be used by ../broker:nacl64.
  14. source_set("minimal") {
  15. sources = [
  16. "nacl_ipc_adapter.cc",
  17. "nacl_ipc_adapter.h",
  18. "nacl_listener.cc",
  19. "nacl_listener.h",
  20. "nacl_main.cc",
  21. "nacl_main_platform_delegate.h",
  22. "nacl_trusted_listener.cc",
  23. "nacl_trusted_listener.h",
  24. "nacl_validation_db.h",
  25. "nacl_validation_query.cc",
  26. "nacl_validation_query.h",
  27. ]
  28. deps = [
  29. ":minimal_content_dummy",
  30. "//base",
  31. "//components/nacl/common:minimal",
  32. "//components/nacl/common:mojo_bindings",
  33. "//content/public/common:main_function_params",
  34. "//crypto",
  35. "//ipc",
  36. "//mojo/core/embedder",
  37. "//native_client/src/trusted/service_runtime:sel_main_chrome",
  38. "//ppapi/c",
  39. "//ppapi/proxy:ipc",
  40. "//sandbox",
  41. "//services/service_manager/public/cpp",
  42. ]
  43. if (is_win) {
  44. sources += [ "nacl_main_platform_delegate_win.cc" ]
  45. }
  46. if (is_mac) {
  47. sources += [ "nacl_main_platform_delegate_mac.mm" ]
  48. }
  49. if (is_linux || is_chromeos) {
  50. sources += [ "nacl_main_platform_delegate_linux.cc" ]
  51. }
  52. }
  53. # This exists just to make 'gn check' happy with :minimal and
  54. # :nacl_helper_win_64 (below). They can't depend on //content/public/common
  55. # or anything like that, because that would bring in lots more than counts
  56. # as "minimal" (stuff that should not be in the nacl64.exe build).
  57. source_set("minimal_content_dummy") {
  58. check_includes = false
  59. sources = []
  60. if (is_win) {
  61. sources += [ "//content/public/common/sandbox_init_win.h" ]
  62. }
  63. if (is_linux || is_chromeos) {
  64. sources += [ "//content/public/common/zygote/sandbox_support_linux.h" ]
  65. }
  66. }
  67. source_set("loader") {
  68. public_deps = [ ":minimal" ]
  69. deps = [
  70. "//components/nacl/common",
  71. "//ppapi/shared_impl",
  72. "//services/service_manager/public/cpp",
  73. ]
  74. data_deps = [
  75. "//ppapi/native_client:irt",
  76. "//ppapi/native_client/src/untrusted/pnacl_support_extension",
  77. ]
  78. }
  79. test("nacl_loader_unittests") {
  80. sources = [
  81. "nacl_ipc_adapter_unittest.cc",
  82. "nacl_validation_query_unittest.cc",
  83. "run_all_unittests.cc",
  84. ]
  85. deps = [
  86. ":loader",
  87. "//base/test:test_support",
  88. "//ipc:test_support",
  89. "//ppapi/c",
  90. "//testing/gtest",
  91. ]
  92. }
  93. }
  94. if ((is_linux || is_chromeos) && current_cpu != "arm64") {
  95. executable("nacl_helper") {
  96. sources = [
  97. "nacl_helper_linux.cc",
  98. "nacl_helper_linux.h",
  99. ]
  100. deps = [
  101. ":loader",
  102. "//base",
  103. "//components/nacl/common:switches",
  104. "//components/nacl/loader/sandbox_linux",
  105. "//content/public/common:content_descriptors",
  106. "//content/public/common:main_function_params",
  107. "//content/public/common:sandbox_support_linux",
  108. "//crypto",
  109. "//ipc",
  110. "//mojo/core/embedder",
  111. "//sandbox/linux:sandbox_services",
  112. "//sandbox/policy",
  113. "//url/ipc:url_ipc",
  114. ]
  115. if (is_chromeos) {
  116. # NaCl is not working with compiler-rt in ChromeOS.
  117. # Force libgcc as a workaround. See https://crbug.com/761103
  118. ldflags = [
  119. "-rtlib=libgcc",
  120. "--unwindlib=libgcc",
  121. ]
  122. # nacl_helper needs to link with libgcc_s. We already have -lgcc_s in
  123. # the final link command line, but it was placed within "--as-needed"
  124. # with the result that the dependency gets dropped. Similarly, we need
  125. # to add this via "ldflags" and not "libs" because libraries added via
  126. # the latter are also placed within an "--as-needed"'.
  127. # See https://crbug.com/884017
  128. ldflags += [ "-lgcc_s" ]
  129. }
  130. # The only symbols that nacl_helper needs to export are those specified by
  131. # its direct dependencies, so -rdynamic would only serve to unnecessarily
  132. # increase the binary size.
  133. if (!export_libcxxabi_from_executables) {
  134. configs -= [ "//build/config/compiler:export_dynamic" ]
  135. }
  136. data_deps =
  137. [ "//native_client/src/trusted/service_runtime/linux:bootstrap" ]
  138. # In order to build ARM32 nacl_helper for ARM64 Chrome OS, we need to
  139. # minimize the dependencies on system libraries, including indirect
  140. # dependencies through other parts of Chrome (see
  141. # https://crbug.com/1339021).
  142. assert_no_deps = [
  143. "//content/public/common",
  144. "//media/audio",
  145. ]
  146. if (is_minimal_toolchain) {
  147. assert_no_deps += [ "//net" ]
  148. }
  149. }
  150. # For setting up nacl_helper.
  151. source_set("nacl_helper_integration") {
  152. public = [ "nacl_helper_linux.h" ]
  153. data_deps = [ ":nacl_helper" ]
  154. }
  155. }
  156. # In ARM64 Chrome, use the ARM32 versions of nacl_helper and
  157. # nacl_helper_bootstrap. Copy them from the build directory for the
  158. # ARM32 toolchain.
  159. if ((is_linux || is_chromeos) && current_cpu == "arm64") {
  160. copy("nacl_helper") {
  161. label = ":nacl_helper(//build/toolchain/linux:clang_arm)"
  162. out_dir = get_label_info(label, "root_out_dir")
  163. sources = [ "${out_dir}/nacl_helper" ]
  164. outputs = [ "${root_out_dir}/nacl_helper" ]
  165. deps = [ label ]
  166. data_deps = [
  167. ":nacl_helper_bootstrap",
  168. "//ppapi/native_client/src/untrusted/pnacl_support_extension",
  169. ]
  170. }
  171. copy("nacl_helper_bootstrap") {
  172. label = "//native_client/src/trusted/service_runtime/linux:bootstrap(//build/toolchain/linux:clang_arm)"
  173. out_dir = get_label_info(label, "root_out_dir")
  174. sources = [ "${out_dir}/nacl_helper_bootstrap" ]
  175. outputs = [ "${root_out_dir}/nacl_helper_bootstrap" ]
  176. deps = [ label ]
  177. }
  178. }
  179. if (is_win && target_cpu == "x86" && current_cpu == "x64") {
  180. source_set("nacl_helper_win_64") {
  181. sources = [
  182. "nacl_helper_win_64.cc",
  183. "nacl_helper_win_64.h",
  184. ]
  185. deps = [
  186. ":minimal",
  187. ":minimal_content_dummy",
  188. "//base",
  189. "//components/nacl/broker",
  190. "//components/nacl/common:switches",
  191. "//content/public/common:main_function_params",
  192. "//content/public/common:static_switches",
  193. "//mojo/core/embedder",
  194. "//sandbox",
  195. "//sandbox/policy",
  196. ]
  197. }
  198. }