chromium/third_party/androidx_javascriptengine/BUILD.gn

# Copyright 2022 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("//testing/test.gni")

group("androidx_javascriptengine") {
  testonly = true
  deps = [ ":javascriptengine_test" ]
}

android_aidl("js_sandbox_aidl") {
  import_include = [ "src/main/stableAidl" ]
  sources = [
    "src/main/stableAidl/org/chromium/android_webview/js_sandbox/common/IJsSandboxConsoleCallback.aidl",
    "src/main/stableAidl/org/chromium/android_webview/js_sandbox/common/IJsSandboxIsolate.aidl",
    "src/main/stableAidl/org/chromium/android_webview/js_sandbox/common/IJsSandboxIsolateCallback.aidl",
    "src/main/stableAidl/org/chromium/android_webview/js_sandbox/common/IJsSandboxIsolateClient.aidl",
    "src/main/stableAidl/org/chromium/android_webview/js_sandbox/common/IJsSandboxIsolateSyncCallback.aidl",
    "src/main/stableAidl/org/chromium/android_webview/js_sandbox/common/IJsSandboxService.aidl",
  ]
}

android_library("js_sandbox_aidl_java") {
  srcjar_deps = [ ":js_sandbox_aidl" ]

  deps = [ "//third_party/androidx:androidx_annotation_annotation_java" ]
}

android_library("javascriptengine_common_java") {
  sources = [
    "src/main/java/androidx/javascriptengine/common/LengthLimitExceededException.java",
    "src/main/java/androidx/javascriptengine/common/Utils.java",
  ]

  deps = [ "//third_party/androidx:androidx_annotation_annotation_java" ]
}

android_library("javascriptengine_java") {
  sources = [
    "src/main/java/androidx/javascriptengine/CloseGuardHelper.java",
    "src/main/java/androidx/javascriptengine/EnvironmentDeadState.java",
    "src/main/java/androidx/javascriptengine/EvaluationFailedException.java",
    "src/main/java/androidx/javascriptengine/EvaluationResultSizeLimitExceededException.java",
    "src/main/java/androidx/javascriptengine/ExecutionErrorTypes.java",
    "src/main/java/androidx/javascriptengine/FileDescriptorIOException.java",
    "src/main/java/androidx/javascriptengine/IsolateClosedState.java",
    "src/main/java/androidx/javascriptengine/IsolateStartupParameters.java",
    "src/main/java/androidx/javascriptengine/IsolateState.java",
    "src/main/java/androidx/javascriptengine/IsolateTerminatedException.java",
    "src/main/java/androidx/javascriptengine/IsolateUsableState.java",
    "src/main/java/androidx/javascriptengine/JavaScriptConsoleCallback.java",
    "src/main/java/androidx/javascriptengine/JavaScriptException.java",
    "src/main/java/androidx/javascriptengine/JavaScriptIsolate.java",
    "src/main/java/androidx/javascriptengine/JavaScriptSandbox.java",
    "src/main/java/androidx/javascriptengine/MemoryLimitExceededException.java",
    "src/main/java/androidx/javascriptengine/SandboxDeadException.java",
    "src/main/java/androidx/javascriptengine/SandboxUnsupportedException.java",
    "src/main/java/androidx/javascriptengine/StreamingFailedException.java",
    "src/main/java/androidx/javascriptengine/TerminationInfo.java",
  ]

  deps = [
    ":javascriptengine_common_java",
    ":js_sandbox_aidl_java",
    "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
    "//third_party/android_deps:guava_android_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/androidx:androidx_concurrent_concurrent_futures_java",
    "//third_party/androidx:androidx_core_core_java",
  ]
}

instrumentation_test_apk("javascriptengine_test") {
  apk_name = "WebViewJsSandboxTestAppTest"
  android_manifest =
      "//android_webview/js_sandbox/javatests/AndroidManifest.xml"
  sources = [ "src/androidTest/java/androidx/javascriptengine/WebViewJavaScriptSandboxTest.java" ]
  deps = [
    ":javascriptengine_java",
    "//third_party/android_deps:guava_android_java",
    "//third_party/androidx:androidx_core_core_java",
    "//third_party/androidx:androidx_test_core_java",
    "//third_party/androidx:androidx_test_ext_junit_java",
    "//third_party/androidx:androidx_test_runner_java",
    "//third_party/junit:junit",
  ]

  # Tell GN to ignore 'incremental_install' even if the user has it in their GN
  # args because it's incompatible with 'use_webview_provider'.
  never_incremental = true
  use_webview_provider = system_webview_apk_target
}