blob: 93e6b140a7304ac92b16b892ab04dc8802200da9 [file] [log] [blame]
# Copyright 2013 The Flutter 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/config.gni")
import("//flutter/build/zip_bundle.gni")
import("//flutter/common/config.gni")
import("//flutter/shell/config.gni")
import("//flutter/shell/gpu/gpu.gni")
import("//flutter/shell/version/version.gni")
shell_gpu_configuration("android_gpu_configuration") {
enable_software = true
enable_vulkan = shell_enable_vulkan
enable_gl = true
enable_metal = false
}
shared_library("flutter_shell_native") {
visibility = [ ":*" ]
output_name = "flutter"
sources = [
"$root_build_dir/flutter_icu/icudtl.o",
"android_context_gl.cc",
"android_context_gl.h",
"android_environment_gl.cc",
"android_environment_gl.h",
"android_external_texture_gl.cc",
"android_external_texture_gl.h",
"android_shell_holder.cc",
"android_shell_holder.h",
"android_surface_gl.cc",
"android_surface_gl.h",
"android_surface_software.cc",
"android_surface_software.h",
"apk_asset_provider.cc",
"apk_asset_provider.h",
"flutter_main.cc",
"flutter_main.h",
"library_loader.cc",
"platform_message_response_android.cc",
"platform_message_response_android.h",
"platform_view_android.cc",
"platform_view_android.h",
"platform_view_android_jni_impl.cc",
"platform_view_android_jni_impl.h",
"vsync_waiter_android.cc",
"vsync_waiter_android.h",
]
deps = [
":android_gpu_configuration",
":icudtl_object",
"//flutter/assets",
"//flutter/common",
"//flutter/flow",
"//flutter/fml",
"//flutter/lib/ui",
"//flutter/runtime",
"//flutter/runtime:libdart",
"//flutter/shell/common",
"//flutter/shell/platform/android/context",
"//flutter/shell/platform/android/external_view_embedder",
"//flutter/shell/platform/android/jni",
"//flutter/shell/platform/android/surface",
"//flutter/shell/platform/android/surface:native_window",
"//third_party/skia",
]
public_configs = [ "//flutter:config" ]
defines = []
if (shell_enable_vulkan) {
sources += [
"android_surface_vulkan.cc",
"android_surface_vulkan.h",
]
deps += [ "//flutter/vulkan" ]
defines += [ "SHELL_ENABLE_VULKAN" ]
}
libs = [
"android",
"EGL",
"GLESv2",
]
ldflags = [ "-Wl,--version-script=" + rebase_path("android_exports.lst") ]
}
action("gen_android_build_config_java") {
script = "//flutter/tools/gen_android_buildconfig.py"
build_config_java = "$target_gen_dir/io/flutter/BuildConfig.java"
outputs = [
build_config_java,
]
args = [
"--out",
rebase_path(build_config_java),
"--runtime-mode",
flutter_runtime_mode,
]
}
embedding_artifact_id = "flutter_embedding_$flutter_runtime_mode"
embedding_jar_filename = "$embedding_artifact_id.jar"
embedding_jar_path = "$root_out_dir/$embedding_jar_filename"
embedding_sources_jar_filename = "$embedding_artifact_id-sources.jar"
embedding_source_jar_path = "$root_out_dir/$embedding_sources_jar_filename"
android_java_sources = [
"io/flutter/Log.java",
"io/flutter/app/FlutterActivity.java",
"io/flutter/app/FlutterActivityDelegate.java",
"io/flutter/app/FlutterActivityEvents.java",
"io/flutter/app/FlutterApplication.java",
"io/flutter/app/FlutterFragmentActivity.java",
"io/flutter/app/FlutterPluginRegistry.java",
"io/flutter/embedding/android/AndroidKeyProcessor.java",
"io/flutter/embedding/android/AndroidTouchProcessor.java",
"io/flutter/embedding/android/DrawableSplashScreen.java",
"io/flutter/embedding/android/FlutterActivity.java",
"io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java",
"io/flutter/embedding/android/FlutterActivityLaunchConfigs.java",
"io/flutter/embedding/android/FlutterEngineConfigurator.java",
"io/flutter/embedding/android/FlutterEngineProvider.java",
"io/flutter/embedding/android/FlutterFragment.java",
"io/flutter/embedding/android/FlutterFragmentActivity.java",
"io/flutter/embedding/android/FlutterImageView.java",
"io/flutter/embedding/android/FlutterSplashView.java",
"io/flutter/embedding/android/FlutterSurfaceView.java",
"io/flutter/embedding/android/FlutterTextureView.java",
"io/flutter/embedding/android/FlutterView.java",
"io/flutter/embedding/android/MotionEventTracker.java",
"io/flutter/embedding/android/RenderMode.java",
"io/flutter/embedding/android/SplashScreen.java",
"io/flutter/embedding/android/SplashScreenProvider.java",
"io/flutter/embedding/android/TransparencyMode.java",
"io/flutter/embedding/engine/FlutterEngine.java",
"io/flutter/embedding/engine/FlutterEngineCache.java",
"io/flutter/embedding/engine/FlutterEnginePluginRegistry.java",
"io/flutter/embedding/engine/FlutterJNI.java",
"io/flutter/embedding/engine/FlutterOverlaySurface.java",
"io/flutter/embedding/engine/mutatorsstack/FlutterMutatorsStack.java",
"io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java",
"io/flutter/embedding/engine/FlutterShellArgs.java",
"io/flutter/embedding/engine/dart/DartExecutor.java",
"io/flutter/embedding/engine/dart/DartMessenger.java",
"io/flutter/embedding/engine/dart/PlatformMessageHandler.java",
"io/flutter/embedding/engine/loader/FlutterLoader.java",
"io/flutter/embedding/engine/loader/ResourceExtractor.java",
"io/flutter/embedding/engine/plugins/FlutterPlugin.java",
"io/flutter/embedding/engine/plugins/PluginRegistry.java",
"io/flutter/embedding/engine/plugins/activity/ActivityAware.java",
"io/flutter/embedding/engine/plugins/activity/ActivityControlSurface.java",
"io/flutter/embedding/engine/plugins/activity/ActivityPluginBinding.java",
"io/flutter/embedding/engine/plugins/broadcastreceiver/BroadcastReceiverAware.java",
"io/flutter/embedding/engine/plugins/broadcastreceiver/BroadcastReceiverControlSurface.java",
"io/flutter/embedding/engine/plugins/broadcastreceiver/BroadcastReceiverPluginBinding.java",
"io/flutter/embedding/engine/plugins/contentprovider/ContentProviderAware.java",
"io/flutter/embedding/engine/plugins/contentprovider/ContentProviderControlSurface.java",
"io/flutter/embedding/engine/plugins/contentprovider/ContentProviderPluginBinding.java",
"io/flutter/embedding/engine/plugins/lifecycle/HiddenLifecycleReference.java",
"io/flutter/embedding/engine/plugins/service/ServiceAware.java",
"io/flutter/embedding/engine/plugins/service/ServiceControlSurface.java",
"io/flutter/embedding/engine/plugins/service/ServicePluginBinding.java",
"io/flutter/embedding/engine/plugins/shim/ShimPluginRegistry.java",
"io/flutter/embedding/engine/plugins/shim/ShimRegistrar.java",
"io/flutter/embedding/engine/renderer/FlutterRenderer.java",
"io/flutter/embedding/engine/renderer/FlutterUiDisplayListener.java",
"io/flutter/embedding/engine/renderer/RenderSurface.java",
"io/flutter/embedding/engine/systemchannels/AccessibilityChannel.java",
"io/flutter/embedding/engine/systemchannels/KeyEventChannel.java",
"io/flutter/embedding/engine/systemchannels/LifecycleChannel.java",
"io/flutter/embedding/engine/systemchannels/LocalizationChannel.java",
"io/flutter/embedding/engine/systemchannels/MouseCursorChannel.java",
"io/flutter/embedding/engine/systemchannels/NavigationChannel.java",
"io/flutter/embedding/engine/systemchannels/PlatformChannel.java",
"io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java",
"io/flutter/embedding/engine/systemchannels/RestorationChannel.java",
"io/flutter/embedding/engine/systemchannels/SettingsChannel.java",
"io/flutter/embedding/engine/systemchannels/SystemChannel.java",
"io/flutter/embedding/engine/systemchannels/TextInputChannel.java",
"io/flutter/plugin/common/ActivityLifecycleListener.java",
"io/flutter/plugin/common/BasicMessageChannel.java",
"io/flutter/plugin/common/BinaryCodec.java",
"io/flutter/plugin/common/BinaryMessenger.java",
"io/flutter/plugin/common/ErrorLogResult.java",
"io/flutter/plugin/common/EventChannel.java",
"io/flutter/plugin/common/FlutterException.java",
"io/flutter/plugin/common/JSONMessageCodec.java",
"io/flutter/plugin/common/JSONMethodCodec.java",
"io/flutter/plugin/common/JSONUtil.java",
"io/flutter/plugin/common/MessageCodec.java",
"io/flutter/plugin/common/MethodCall.java",
"io/flutter/plugin/common/MethodChannel.java",
"io/flutter/plugin/common/MethodCodec.java",
"io/flutter/plugin/common/PluginRegistry.java",
"io/flutter/plugin/common/StandardMessageCodec.java",
"io/flutter/plugin/common/StandardMethodCodec.java",
"io/flutter/plugin/common/StringCodec.java",
"io/flutter/plugin/editing/FlutterTextUtils.java",
"io/flutter/plugin/editing/InputConnectionAdaptor.java",
"io/flutter/plugin/editing/TextInputPlugin.java",
"io/flutter/plugin/localization/LocalizationPlugin.java",
"io/flutter/plugin/mouse/MouseCursorPlugin.java",
"io/flutter/plugin/platform/AccessibilityEventsDelegate.java",
"io/flutter/plugin/platform/PlatformPlugin.java",
"io/flutter/plugin/platform/PlatformView.java",
"io/flutter/plugin/platform/PlatformViewFactory.java",
"io/flutter/plugin/platform/PlatformViewRegistry.java",
"io/flutter/plugin/platform/PlatformViewRegistryImpl.java",
"io/flutter/plugin/platform/PlatformViewsAccessibilityDelegate.java",
"io/flutter/plugin/platform/PlatformViewsController.java",
"io/flutter/plugin/platform/SingleViewPresentation.java",
"io/flutter/plugin/platform/VirtualDisplayController.java",
"io/flutter/util/PathUtils.java",
"io/flutter/util/Preconditions.java",
"io/flutter/util/Predicate.java",
"io/flutter/view/AccessibilityBridge.java",
"io/flutter/view/AccessibilityViewEmbedder.java",
"io/flutter/view/FlutterCallbackInformation.java",
"io/flutter/view/FlutterMain.java",
"io/flutter/view/FlutterNativeView.java",
"io/flutter/view/FlutterRunArguments.java",
"io/flutter/view/FlutterView.java",
"io/flutter/view/TextureRegistry.java",
"io/flutter/view/VsyncWaiter.java",
]
list_script = rebase_path("//build/ls.py", ".", "//")
embedding_dependencies_jars =
exec_script(list_script,
[
"--target-directory",
rebase_path("//third_party/android_embedding_dependencies"),
],
"list lines")
action("flutter_shell_java") {
script = "//build/android/gyp/javac.py"
depfile = "$target_gen_dir/$target_name.d"
jar_path = embedding_jar_path
source_jar_path = embedding_source_jar_path
sources = android_java_sources
sources += get_target_outputs(":gen_android_build_config_java")
outputs = [
depfile,
jar_path,
jar_path + ".md5.stamp",
source_jar_path,
source_jar_path + ".md5.stamp",
]
lambda_jar = "$android_sdk_build_tools/core-lambda-stubs.jar"
inputs = [
android_sdk_jar,
lambda_jar,
] + embedding_dependencies_jars
_rebased_current_path = rebase_path(".")
_rebased_jar_path = rebase_path(jar_path, root_build_dir)
_rebased_source_jar_path = rebase_path(source_jar_path, root_build_dir)
_rebased_depfile = rebase_path(depfile, root_build_dir)
_rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
_rebased_lambda_jar = rebase_path(lambda_jar, root_build_dir)
_rebased_classpath =
[
_rebased_android_sdk_jar,
_rebased_lambda_jar,
] + rebase_path(embedding_dependencies_jars, root_build_dir)
args = [
"--depfile=$_rebased_depfile",
"--jar-path=$_rebased_jar_path",
"--jar-source-path=$_rebased_source_jar_path",
"--jar-source-base-dir=$_rebased_current_path",
"--classpath=$_rebased_classpath",
"--bootclasspath=$_rebased_android_sdk_jar",
]
args += rebase_path(sources, root_build_dir)
deps = [
":gen_android_build_config_java",
]
}
action("icudtl_object") {
script = "//flutter/sky/tools/objcopy.py"
icudtl_input = "//third_party/icu/flutter/icudtl.dat"
icudtl_output = "$root_build_dir/flutter_icu/icudtl.o"
inputs = [
"$icudtl_input",
]
outputs = [
"$icudtl_output",
]
args = [
"--objcopy",
rebase_path(android_objcopy),
"--input",
rebase_path(icudtl_input),
"--output",
rebase_path(icudtl_output),
"--arch",
current_cpu,
]
}
action("android_jar") {
script = "//build/android/gyp/create_flutter_jar.py"
if (stripped_symbols) {
engine_library = "lib.stripped/libflutter.so"
} else {
engine_library = "libflutter.so"
}
inputs = [
"$root_build_dir/$embedding_jar_filename",
"$root_build_dir/$engine_library",
]
engine_artifact_id =
string_replace(android_app_abi, "-", "_") + "_" + flutter_runtime_mode
engine_jar_filename = "$engine_artifact_id.jar"
outputs = [
"$root_build_dir/flutter.jar",
"$root_build_dir/$engine_jar_filename",
]
args = [
"--output",
rebase_path("flutter.jar", root_build_dir, root_build_dir),
"--output_native_jar",
rebase_path(engine_jar_filename, root_build_dir, root_build_dir),
"--dist_jar",
rebase_path(embedding_jar_filename, root_build_dir, root_build_dir),
"--native_lib",
rebase_path("$engine_library", root_build_dir, root_build_dir),
"--android_abi",
"$android_app_abi",
]
deps = [
":flutter_shell_java",
":flutter_shell_native",
":pom_embedding",
":pom_libflutter",
]
}
action("pom_libflutter") {
script = "//flutter/tools/androidx/generate_pom_file.py"
inputs = [
"//flutter/tools/androidx/files.json",
]
artifact_id =
string_replace(android_app_abi, "-", "_") + "_" + flutter_runtime_mode
outputs = [
"$root_build_dir/$artifact_id.pom",
]
args = [
"--destination",
rebase_path(root_build_dir),
"--engine-version",
engine_version,
"--engine-artifact-id",
artifact_id,
]
}
action("pom_embedding") {
script = "//flutter/tools/androidx/generate_pom_file.py"
inputs = [
"//flutter/tools/androidx/files.json",
]
artifact_id = "flutter_embedding_$flutter_runtime_mode"
outputs = [
"$root_build_dir/$artifact_id.pom",
]
args = [
"--destination",
rebase_path(root_build_dir),
"--engine-version",
engine_version,
"--engine-artifact-id",
artifact_id,
"--include-embedding-dependencies",
"true",
]
}
# To build and run:
# testing/run_tests.py [--type=java] [--java-filter=io.flutter.TestClassName]
action("robolectric_tests") {
script = "//build/android/gyp/javac.py"
depfile = "$target_gen_dir/$target_name.d"
jar_path = "$root_out_dir/robolectric_tests.jar"
sources = [
"test/io/flutter/FlutterTestSuite.java",
"test/io/flutter/SmokeTest.java",
"test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java",
"test/io/flutter/embedding/android/FlutterActivityTest.java",
"test/io/flutter/embedding/android/FlutterAndroidComponentTest.java",
"test/io/flutter/embedding/android/FlutterFragmentActivityTest.java",
"test/io/flutter/embedding/android/FlutterFragmentTest.java",
"test/io/flutter/embedding/android/FlutterViewTest.java",
"test/io/flutter/embedding/android/RobolectricFlutterActivity.java",
"test/io/flutter/embedding/engine/FlutterEngineCacheTest.java",
"test/io/flutter/embedding/engine/FlutterEnginePluginRegistryTest.java",
"test/io/flutter/embedding/engine/FlutterEngineTest.java",
"test/io/flutter/embedding/engine/FlutterJNITest.java",
"test/io/flutter/embedding/engine/FlutterShellArgsTest.java",
"test/io/flutter/embedding/engine/PluginComponentTest.java",
"test/io/flutter/embedding/engine/RenderingComponentTest.java",
"test/io/flutter/embedding/engine/dart/DartExecutorTest.java",
"test/io/flutter/embedding/engine/plugins/shim/ShimPluginRegistryTest.java",
"test/io/flutter/embedding/engine/renderer/FlutterRendererTest.java",
"test/io/flutter/embedding/engine/systemchannels/RestorationChannelTest.java",
"test/io/flutter/external/FlutterLaunchTests.java",
"test/io/flutter/plugin/common/StandardMessageCodecTest.java",
"test/io/flutter/plugin/common/StandardMethodCodecTest.java",
"test/io/flutter/plugin/editing/InputConnectionAdaptorTest.java",
"test/io/flutter/plugin/editing/TextInputPluginTest.java",
"test/io/flutter/plugin/localization/LocalizationPluginTest.java",
"test/io/flutter/plugin/mouse/MouseCursorPluginTest.java",
"test/io/flutter/plugin/platform/PlatformPluginTest.java",
"test/io/flutter/plugin/platform/PlatformViewsControllerTest.java",
"test/io/flutter/plugin/platform/SingleViewPresentationTest.java",
"test/io/flutter/plugins/GeneratedPluginRegistrant.java",
"test/io/flutter/util/FakeKeyEvent.java",
"test/io/flutter/util/PreconditionsTest.java",
"test/io/flutter/view/AccessibilityBridgeTest.java",
]
outputs = [
depfile,
jar_path,
jar_path + ".md5.stamp",
]
additional_jar_files = [ "robolectric.properties" ]
_jar_dependencies = [
android_sdk_jar,
embedding_jar_path,
] + embedding_dependencies_jars
inputs = _jar_dependencies + additional_jar_files
_rebased_current_path = rebase_path(".")
_rebased_jar_path = rebase_path(jar_path, root_build_dir)
_rebased_depfile = rebase_path(depfile, root_build_dir)
_rebased_classpath = rebase_path(_jar_dependencies, root_build_dir)
_rebased_srcjars = rebase_path(_jar_dependencies, root_build_dir)
_rebased_additional_files = rebase_path(additional_jar_files, root_build_dir)
args = [
"--depfile=$_rebased_depfile",
"--jar-path=$_rebased_jar_path",
"--classpath=$_rebased_classpath",
"--jar-source-base-dir=$_rebased_current_path",
"--java-srcjars=$_rebased_srcjars",
"--additional-jar-files=$_rebased_additional_files",
]
args += rebase_path(sources, root_build_dir)
deps = [
":android",
":flutter_shell_java",
]
}
zip_bundle("android_symbols") {
output = "$android_zip_archive_dir/symbols.zip"
files = [
{
source = "$root_build_dir/libflutter.so"
destination = "libflutter.so"
},
]
deps = [
":flutter_shell_native",
]
}
zip_bundle("android") {
output = "$android_zip_archive_dir/artifacts.zip"
files = [
{
source = "$root_build_dir/flutter.jar"
destination = "flutter.jar"
},
]
deps = [
":android_jar",
":android_symbols",
]
if (current_cpu == "x86" || current_cpu == "x64") {
files += [
{
source = "$root_build_dir/lib.stripped/libflutter.so"
destination = "libflutter.so"
},
]
deps += [ ":flutter_shell_native" ]
}
}
# TODO(dnfield): make these targets pass.
# https://github.com/flutter/flutter/issues/42400
action("gen_android_javadoc") {
script = "//flutter/tools/gen_javadoc.py"
sources = android_java_sources + embedding_dependencies_jars
outputs = [
"$target_gen_dir/javadocs",
]
args = [
"--out-dir",
rebase_path(outputs[0]),
"--android-source-root",
rebase_path("."),
"--build-config-path",
rebase_path(target_gen_dir),
"--third-party",
rebase_path("//third_party"),
]
}
zip_bundle("android_javadoc") {
output = "android-javadoc.zip"
javadoc_dir = get_target_outputs(":gen_android_javadoc")
files = [
{
source = javadoc_dir[0]
destination = "/"
},
]
deps = [
":gen_android_javadoc",
]
}