blob: 5bc430ac1ef6ae2caa1804cc2544b3868cbb4eb7 [file] [log] [blame]
# Copyright 2019 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/internal_rules.gni")
# Generates a script in the bin directory that runs
# //build/android/resource_sizes.py against the provided apk.
#
# Only one of apk_name or file_path should be provided.
#
# Variables:
# apk_name: The name of the apk, without the extension.
# file_path: The path to the apk or .minimal.apks.
# trichrome_chrome_path: The path to chrome apk or .minimal.apks.
# trichrome_webview_path: The path to webview apk or .minimal.apks.
# trichrome_library_path: The path to library apk or .minimal.apks.
template("android_resource_sizes_test") {
generate_android_wrapper(target_name) {
forward_variables_from(invoker, [ "data_deps" ])
executable = "//build/android/resource_sizes.py"
wrapper_script = "$root_out_dir/bin/run_${target_name}"
assert(defined(invoker.apk_name) != defined(invoker.file_path),
"Exactly one of apk_name or file_path should be provided.")
deps = [ "//build/android:resource_sizes_py" ]
executable_args = [
"--output-format",
"histograms",
"--chromium-output-directory",
"@WrappedPath(.)",
]
data = []
if (defined(invoker.trichrome_chrome_path)) {
data += [
invoker.trichrome_chrome_path,
invoker.trichrome_webview_path,
invoker.trichrome_library_path,
]
_rebased_chrome =
rebase_path(invoker.trichrome_chrome_path, root_build_dir)
_rebased_webview =
rebase_path(invoker.trichrome_webview_path, root_build_dir)
_rebased_library =
rebase_path(invoker.trichrome_library_path, root_build_dir)
# apk_name used only as test suite name. Not a path in this case.
executable_args += [
"--trichrome-chrome",
"@WrappedPath(${_rebased_chrome})",
"--trichrome-webview",
"@WrappedPath(${_rebased_webview})",
"--trichrome-library",
"@WrappedPath(${_rebased_library})",
"${invoker.apk_name}",
]
} else {
if (defined(invoker.apk_name)) {
_file_path = "$root_out_dir/apks/${invoker.apk_name}.apk"
data += [ "$root_out_dir/arsc/apks/${invoker.apk_name}.ap_" ]
} else if (defined(invoker.file_path)) {
_file_path = invoker.file_path
}
data += [ _file_path ]
_rebased_file_path = rebase_path(_file_path, root_build_dir)
executable_args += [ "@WrappedPath(${_rebased_file_path})" ]
}
}
}
# Generates a "size config JSON file" to specify data to be passed from recipes
# to Python scripts for binary size measurement on bots. All filenames are
# relative to $root_build_dir. The resulting JSON file is written to
# "$root_build_dir/config/${invoker.name}_size_config.json".
#
# Variables:
# name: The name of the path to the generated size config JSON file.
# mapping_files: List of mapping files.
# to_resource_sizes_py: Scope containing data to pass to resource_sizes.py,
# processed by generate_commit_size_analysis.py.
# supersize_input_file: Main input for SuperSize.
template("android_size_bot_config") {
_full_target_name = get_label_info(target_name, "label_no_toolchain")
_out_json = {
_HEADER = "Written by build target '${_full_target_name}'"
forward_variables_from(invoker,
[
"mapping_files",
"to_resource_sizes_py",
"supersize_input_file",
])
}
_output_json_path = "$root_build_dir/config/${invoker.name}_size_config.json"
write_file(_output_json_path, _out_json, "json")
}