chromium/chrome/android/webapk/libs/runtime_library/BUILD.gn

# Copyright 2016 The Chromium Authors
# 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("//chrome/android/webapk/libs/runtime_library_version.gni")

# runtime_library_version.gni must be updated whenever the runtime library is
# updated. The WebAPK re-extracts the runtime library from the Chrome APK when
# |runtime_library_version| is incremented.

# Whenever this constant is changed, WebApkUtils#getRuntimeDexName() must also
# be changed.
runtime_library_dex_asset_name = "webapk$runtime_library_version.dex"

android_aidl("webapk_service_aidl") {
  import_include = [ "src/org/chromium/webapk/lib/runtime_library" ]
  interface_file = "src/org/chromium/webapk/lib/runtime_library/common.aidl"
  sources = [ "src/org/chromium/webapk/lib/runtime_library/IWebApkApi.aidl" ]
}

# A standalone jar for the aidl's generated java files so that multiple places
# can depend on the aidl.
android_library("webapk_service_aidl_java") {
  srcjar_deps = [ ":webapk_service_aidl" ]
}

# runtime_library_from_assets_java cannot be used as a dependency of another
# library because the dx tool expects files ending in .dex.jar
android_library("runtime_library_for_assets_java") {
  jacoco_never_instrument = true
  sources =
      [ "src/org/chromium/webapk/lib/runtime_library/WebApkServiceImpl.java" ]
  srcjar_deps = [ ":webapk_service_aidl" ]
}

# The subset of runtime_library_from_assets_java needed for tests.
android_library("runtime_library_for_tests_java") {
  sources =
      [ "src/org/chromium/webapk/lib/runtime_library/WebApkServiceImpl.java" ]
  deps = [ ":webapk_service_aidl_java" ]
}

dist_dex("webapk_runtime_library") {
  deps = [ ":runtime_library_for_assets_java" ]
  proguard_enabled = true
  proguard_configs = [ "runtime_library.proguard.flags" ]
  output = "$target_out_dir/$runtime_library_dex_asset_name"
  package_name = "webapk_runtime_library"
  version_code = runtime_library_version
}

android_assets("runtime_library_assets") {
  write_file("$target_gen_dir/webapk_dex_version.txt", runtime_library_version)

  sources = [
    "$target_gen_dir/webapk_dex_version.txt",
    "$target_out_dir/$runtime_library_dex_asset_name",
  ]

  deps = [ ":webapk_runtime_library" ]
}

android_library("runtime_library_javatests") {
  testonly = true
  sources = [ "javatests/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImplTest.java" ]
  deps = [
    ":runtime_library_for_tests_java",
    ":webapk_service_aidl_java",
    "//base:base_java_test_support",
    "//chrome/test/android:chrome_java_integration_test_support",
    "//content/public/test/android:content_java_test_support",
    "//third_party/androidx:androidx_test_core_java",
    "//third_party/androidx:androidx_test_monitor_java",
    "//third_party/androidx:androidx_test_runner_java",
    "//third_party/junit",
  ]
}