1# Copyright 2021 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build/config/android/android_nocompile.gni") 6import("//build/config/android/rules.gni") 7 8missing_symbol_generated_importer_template_nocompile_source = 9 "//build/android/java/test/missing_symbol/Importer.template" 10 11template("missing_symbol_test") { 12 # Not named "_java" to prevent target from being considered a classpath dep. 13 _helper_target_name = string_replace("${target_name}__helper", "java", "") 14 15 group(_helper_target_name) { 16 # Make group() depend on dependencies that |target_name| cannot find so that 17 # the missing symbol resolver can find and suggest the missing GN dep. 18 deps = invoker.deps 19 } 20 21 android_library(target_name) { 22 sources = [ "//tools/android/errorprone_plugin/test/src/org/chromium/tools/errorprone/plugin/Empty.java" ] 23 not_needed(invoker, 24 [ 25 "sources", 26 "importer_srcjar_deps", 27 ]) 28 if (enable_android_nocompile_tests) { 29 if (defined(invoker.sources)) { 30 sources += invoker.sources 31 } 32 if (defined(invoker.importer_srcjar_deps)) { 33 srcjar_deps = invoker.importer_srcjar_deps 34 } 35 } 36 37 deps = [ ":${_helper_target_name}" ] 38 } 39} 40 41# missing_symbol_test() template wrapper which generates importer class. 42template("missing_symbol_generated_importer_test") { 43 _importer_generator_target = "${target_name}__importer_javagen" 44 java_cpp_template(_importer_generator_target) { 45 sources = [ missing_symbol_generated_importer_template_nocompile_source ] 46 defines = [ 47 "_IMPORTER_PACKAGE=${invoker.importer_package}", 48 "_IMPORTEE_PACKAGE=${invoker.imported_package}", 49 "_IMPORTEE_CLASS_NAME=${invoker.imported_class_name}", 50 ] 51 } 52 53 missing_symbol_test(target_name) { 54 importer_srcjar_deps = [ ":${_importer_generator_target}" ] 55 forward_variables_from(invoker, [ "deps" ]) 56 } 57} 58