| # 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/${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})" ] |
| } |
| } |
| } |