OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//base/android/linker/config.gni") | 5 import("//base/android/linker/config.gni") |
6 import("//build/config/android/config.gni") | 6 import("//build/config/android/config.gni") |
7 import("//build/config/android/internal_rules.gni") | 7 import("//build/config/android/internal_rules.gni") |
8 import("//build/config/sanitizers/sanitizers.gni") | 8 import("//build/config/sanitizers/sanitizers.gni") |
9 import("//build/toolchain/toolchain.gni") | 9 import("//build/toolchain/toolchain.gni") |
10 import("//third_party/android_platform/config.gni") | 10 import("//third_party/android_platform/config.gni") |
(...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2227 # executable, this will create a directory containing the native exe and all | 2227 # executable, this will create a directory containing the native exe and all |
2228 # it's library dependencies. | 2228 # it's library dependencies. |
2229 # | 2229 # |
2230 # Note: It's usually better to package things as an APK than as a native | 2230 # Note: It's usually better to package things as an APK than as a native |
2231 # executable. | 2231 # executable. |
2232 # | 2232 # |
2233 # Variables | 2233 # Variables |
2234 # dist_dir: Directory for the exe and libraries. Everything in this directory | 2234 # dist_dir: Directory for the exe and libraries. Everything in this directory |
2235 # will be deleted before copying in the exe and libraries. | 2235 # will be deleted before copying in the exe and libraries. |
2236 # binary: Path to (stripped) executable. | 2236 # binary: Path to (stripped) executable. |
2237 # include_main_binary: Whether |binary| should be copied to |dist_dir|. | 2237 # extra_files: List of extra files to copy in (optional). |
2238 # | 2238 # |
2239 # Example | 2239 # Example |
2240 # create_native_executable_dist("foo_dist") { | 2240 # create_native_executable_dist("foo_dist") { |
2241 # dist_dir = "$root_build_dir/foo_dist" | 2241 # dist_dir = "$root_build_dir/foo_dist" |
2242 # binary = "$root_build_dir/foo" | 2242 # binary = "$root_build_dir/foo" |
2243 # deps = [ ":the_thing_that_makes_foo" ] | 2243 # deps = [ ":the_thing_that_makes_foo" ] |
2244 # } | 2244 # } |
2245 template("create_native_executable_dist") { | 2245 template("create_native_executable_dist") { |
2246 set_sources_assignment_filter([]) | |
2247 forward_variables_from(invoker, [ "testonly" ]) | 2246 forward_variables_from(invoker, [ "testonly" ]) |
2248 | 2247 |
2249 dist_dir = invoker.dist_dir | 2248 _libraries_list = "${target_gen_dir}/${target_name}_library_dependencies.list" |
2250 binary = invoker.binary | |
2251 template_name = target_name | |
2252 | 2249 |
2253 libraries_list = | 2250 _find_deps_target_name = "${target_name}__find_library_dependencies" |
2254 "${target_gen_dir}/${template_name}_library_dependencies.list" | |
2255 | 2251 |
2256 find_deps_target_name = "${template_name}__find_library_dependencies" | 2252 # TODO(agrieve): Extract dependent libs from GN rather than readelf. |
2257 copy_target_name = "${template_name}__copy_libraries_and_exe" | 2253 action(_find_deps_target_name) { |
2258 | |
2259 action(find_deps_target_name) { | |
2260 forward_variables_from(invoker, [ "deps" ]) | 2254 forward_variables_from(invoker, [ "deps" ]) |
2261 visibility = [ ":$copy_target_name" ] | |
2262 | 2255 |
2263 script = "//build/android/gyp/write_ordered_libraries.py" | 2256 script = "//build/android/gyp/write_ordered_libraries.py" |
2264 depfile = "$target_gen_dir/$target_name.d" | 2257 depfile = "$target_gen_dir/$target_name.d" |
2265 inputs = [ | 2258 inputs = [ |
2266 binary, | 2259 invoker.binary, |
2267 android_readelf, | 2260 android_readelf, |
2268 ] | 2261 ] |
2269 outputs = [ | 2262 outputs = [ |
2270 depfile, | 2263 depfile, |
2271 libraries_list, | 2264 _libraries_list, |
2272 ] | 2265 ] |
2273 rebased_binaries = rebase_path([ binary ], root_build_dir) | 2266 rebased_binaries = rebase_path([ invoker.binary ], root_build_dir) |
2274 args = [ | 2267 args = [ |
2275 "--depfile", | 2268 "--depfile", |
2276 rebase_path(depfile, root_build_dir), | 2269 rebase_path(depfile, root_build_dir), |
2277 "--input-libraries=$rebased_binaries", | 2270 "--input-libraries=$rebased_binaries", |
2278 "--libraries-dir", | 2271 "--libraries-dir", |
2279 rebase_path(root_shlib_dir, root_build_dir), | 2272 rebase_path(root_shlib_dir, root_build_dir), |
2280 "--output", | 2273 "--output", |
2281 rebase_path(libraries_list, root_build_dir), | 2274 rebase_path(_libraries_list, root_build_dir), |
2282 "--readelf", | 2275 "--readelf", |
2283 rebase_path(android_readelf, root_build_dir), | 2276 rebase_path(android_readelf, root_build_dir), |
2284 ] | 2277 ] |
2285 } | 2278 } |
2286 | 2279 |
2287 copy_ex(copy_target_name) { | 2280 copy_ex(target_name) { |
2288 visibility = [ ":$template_name" ] | |
2289 | |
2290 clear_dir = true | 2281 clear_dir = true |
2291 | 2282 |
2292 inputs = [ | 2283 inputs = [ |
2293 libraries_list, | 2284 _libraries_list, |
| 2285 invoker.binary, |
2294 ] | 2286 ] |
2295 if (defined(invoker.include_main_binary) && invoker.include_main_binary) { | |
2296 inputs += [ binary ] | |
2297 } | |
2298 | 2287 |
2299 dest = dist_dir | 2288 dest = invoker.dist_dir |
2300 | 2289 |
2301 rebased_libraries_list = rebase_path(libraries_list, root_build_dir) | 2290 _rebased_libraries_list = rebase_path(_libraries_list, root_build_dir) |
2302 args = [ "--files=@FileArg($rebased_libraries_list:lib_paths)" ] | 2291 _rebased_binaries_list = rebase_path([ invoker.binary ], root_build_dir) |
2303 if (defined(invoker.include_main_binary) && invoker.include_main_binary) { | 2292 args = [ |
2304 rebased_binaries_list = rebase_path([ binary ], root_build_dir) | 2293 "--files=@FileArg($_rebased_libraries_list:lib_paths)", |
2305 args += [ "--files=$rebased_binaries_list" ] | 2294 "--files=$_rebased_binaries_list", |
| 2295 ] |
| 2296 if (defined(invoker.extra_files)) { |
| 2297 _rebased_extra_files = rebase_path(invoker.extra_files, root_build_dir) |
| 2298 args += [ "--files=$_rebased_extra_files" ] |
2306 } | 2299 } |
2307 | 2300 |
2308 deps = [ | 2301 deps = [ |
2309 ":$find_deps_target_name", | 2302 ":$_find_deps_target_name", |
2310 ] | 2303 ] |
2311 if (defined(invoker.deps)) { | 2304 if (defined(invoker.deps)) { |
2312 deps += invoker.deps | 2305 deps += invoker.deps |
2313 } | 2306 } |
2314 } | 2307 } |
2315 | |
2316 group(template_name) { | |
2317 forward_variables_from(invoker, [ "visibility" ]) | |
2318 public_deps = [ | |
2319 ":$copy_target_name", | |
2320 ] | |
2321 } | |
2322 } | 2308 } |
2323 | 2309 |
2324 # Compile a protocol buffer to java. | 2310 # Compile a protocol buffer to java. |
2325 # | 2311 # |
2326 # This generates java files from protocol buffers and creates an Android library | 2312 # This generates java files from protocol buffers and creates an Android library |
2327 # containing the classes. | 2313 # containing the classes. |
2328 # | 2314 # |
2329 # Variables | 2315 # Variables |
2330 # sources: Paths to .proto files to compile. | 2316 # sources: Paths to .proto files to compile. |
2331 # proto_path: Root directory of .proto files. | 2317 # proto_path: Root directory of .proto files. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 "--target", | 2403 "--target", |
2418 rebase_path(invoker.target, root_build_dir), | 2404 rebase_path(invoker.target, root_build_dir), |
2419 "--output-directory", | 2405 "--output-directory", |
2420 rebase_path(root_out_dir, root_build_dir), | 2406 rebase_path(root_out_dir, root_build_dir), |
2421 ] | 2407 ] |
2422 if (defined(invoker.flag_name)) { | 2408 if (defined(invoker.flag_name)) { |
2423 args += [ "--flag-name=${invoker.flag_name}" ] | 2409 args += [ "--flag-name=${invoker.flag_name}" ] |
2424 } | 2410 } |
2425 } | 2411 } |
2426 } | 2412 } |
OLD | NEW |