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