summaryrefslogtreecommitdiffstats
path: root/build/android/BUILD.gn
blob: af819ed3ce62c8e4cb3482e4f6b787177e8687e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/android/rules.gni")
import("//third_party/ijar/ijar.gni")

sun_tools_jar_path = "$root_gen_dir/sun_tools_jar/tools.jar"

# Create or update the API versions cache if necessary by running a
# functionally empty lint task. This prevents racy creation of the
# cache while linting java targets in android_lint.
android_lint("prepare_android_lint_cache") {
  android_manifest = "//build/android/AndroidManifest.xml"
  create_cache = true
}

action("find_sun_tools_jar") {
  script = "//build/android/gyp/find_sun_tools_jar.py"
  depfile = "$target_gen_dir/$target_name.d"
  outputs = [
    depfile,
    sun_tools_jar_path,
  ]
  args = [
    "--depfile",
    rebase_path(depfile, root_build_dir),
    "--output",
    rebase_path(sun_tools_jar_path, root_build_dir),
  ]
}

java_prebuilt("sun_tools_java") {
  jar_path = sun_tools_jar_path
  jar_dep = ":find_sun_tools_jar"
}

generate_interface_jar("android_ijar") {
  input_jar = android_sdk_jar
  output_jar = "$root_out_dir/lib.java/android.interface.jar"
}

# Copy to the lib.unstripped directory so that gdb can easily find it.
copy("cpplib_unstripped") {
  _soname = "libc++_shared.so"
  sources = [
    "${android_libcpp_root}/libs/${android_app_abi}/${_soname}",
  ]
  outputs = [
    "${root_out_dir}/lib.unstripped/${_soname}",
  ]
}

action("cpplib_stripped") {
  _strip_bin = "${android_tool_prefix}strip"
  _soname = "libc++_shared.so"
  _input_so = "${root_out_dir}/lib.unstripped/${_soname}"
  _output_so = "${root_shlib_dir}/${_soname}"

  deps = [
    ":cpplib_unstripped",
  ]

  script = "//build/gn_run_binary.py"
  inputs = [
    _strip_bin,
  ]
  sources = [
    _input_so,
  ]
  outputs = [
    _output_so,
  ]

  _rebased_strip_bin = rebase_path(_strip_bin, root_out_dir)
  _rebased_input_so = rebase_path(_input_so, root_out_dir)
  _rebased_output_so = rebase_path(_output_so, root_out_dir)
  args = [
    _rebased_strip_bin,
    "--strip-unneeded",
    "-o",
    _rebased_output_so,
    _rebased_input_so,
  ]
}

group("test_runner_py") {
  _py_files = read_file("test_runner.pydeps", "list lines")

  # Filter out comments.
  set_sources_assignment_filter([ "#*" ])
  sources = _py_files

  data = sources + [
           "devil_chromium.json",
           "//third_party/android_tools/sdk/build-tools/23.0.1/aapt",
           "//third_party/android_tools/sdk/build-tools/23.0.1/dexdump",
           "//third_party/android_tools/sdk/build-tools/23.0.1/lib/libc++.so",
           "//third_party/android_tools/sdk/build-tools/23.0.1/split-select",
           "//third_party/android_tools/sdk/platform-tools/adb",
           "//third_party/catapult/third_party/gsutil/",
           "//third_party/catapult/devil/devil/devil_dependencies.json",
         ]
  data_deps = [
    "//tools/swarming_client:isolate_py",
  ]
}

# Create wrapper scripts in out/bin that takes care of setting the
# --output-directory.
_scripts_to_wrap = [
  # TODO(agrieve): Once GYP is no more, delete the checked-in adb_gdb_* scripts
  # and generated a script for each android_apk() that has a native library.
  "adb_gdb_android_webview_shell",
  "adb_gdb_blimp_client",
  "adb_gdb_chrome_public",
  "adb_gdb_content_shell",
  "adb_gdb_cronet_sample",
  "adb_gdb_mojo_shell",
  "asan_symbolize.py",
  "tombstones.py",
]

_wrapper_targets = []
foreach(script, _scripts_to_wrap) {
  _target_name = get_path_info(script, "name") + "_wrapper"
  _wrapper_targets += [ ":$_target_name" ]
  wrapper_script(_target_name) {
    target = script
  }
}

group("wrapper_scripts") {
  deps = _wrapper_targets
}