blob: 8c14af27f93a99f9272bc92fcc6428ff7b667b84 [file] [log] [blame] [edit]
# Copyright 2019 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("//flutter/build/zip_bundle.gni")
import("//flutter/common/config.gni")
import("//third_party/dart/build/dart/dart_action.gni")
sdk_dill = "$root_out_dir/flutter_web_sdk/kernel/flutter_ddc_sdk.dill"
sdk_dill_sound =
"$root_out_dir/flutter_web_sdk/kernel/flutter_ddc_sdk_sound.dill"
dart_sdk_package_config = "//third_party/dart/.dart_tool/package_config.json"
web_ui_sources = exec_script("//third_party/dart/tools/list_dart_files.py",
[
"absolute",
rebase_path("//flutter/lib/web_ui/lib"),
],
"list lines")
web_engine_sources =
exec_script("//third_party/dart/tools/list_dart_files.py",
[
"absolute",
rebase_path("//flutter/lib/web_ui/lib/src/engine"),
],
"list lines")
web_engine_sources +=
[ rebase_path("//flutter/lib/web_ui/lib/src/engine.dart") ]
group("web_sdk") {
deps = [
":flutter_dartdevc_canvaskit_html_kernel_sdk",
":flutter_dartdevc_canvaskit_html_kernel_sdk_sound",
":flutter_dartdevc_canvaskit_kernel_sdk",
":flutter_dartdevc_canvaskit_kernel_sdk_sound",
":flutter_dartdevc_kernel_sdk",
":flutter_dartdevc_kernel_sdk_outline",
":flutter_dartdevc_kernel_sdk_outline_sound",
":flutter_dartdevc_kernel_sdk_sound",
]
}
prebuilt_dart_action("web_ui_sources") {
inputs = web_ui_sources + [ "sdk_rewriter.dart" ]
packages = dart_sdk_package_config
script = "sdk_rewriter.dart"
output_dir = rebase_path("$root_out_dir/flutter_web_sdk/lib/ui/")
input_dir = rebase_path("//flutter/lib/web_ui/lib/")
pool = "//flutter/build/dart:dart_pool"
outputs = [ "$target_gen_dir/$target_name.stamp" ]
args = [
"--output-dir=$output_dir",
"--input-dir=$input_dir",
"--ui",
"--stamp",
rebase_path(outputs[0], root_build_dir),
]
foreach(source_file, web_ui_sources) {
path = rebase_path(source_file)
args += [ "--input=$path" ]
}
}
prebuilt_dart_action("web_engine_sources") {
inputs = web_engine_sources + [ "sdk_rewriter.dart" ]
packages = dart_sdk_package_config
script = "sdk_rewriter.dart"
output_dir = rebase_path("$root_out_dir/flutter_web_sdk/lib/_engine/")
input_dir = rebase_path("//flutter/lib/web_ui/lib/src/")
pool = "//flutter/build/dart:dart_pool"
outputs = [ "$target_gen_dir/$target_name.stamp" ]
args = [
"--output-dir=$output_dir",
"--input-dir=$input_dir",
"--engine",
"--stamp",
rebase_path(outputs[0], root_build_dir),
]
foreach(source_file, web_engine_sources) {
path = rebase_path(source_file)
args += [ "--input=$path" ]
}
}
copy("web_ui_library") {
sources = [ "//flutter/web_sdk/libraries.json" ]
outputs = [ "$root_out_dir/flutter_web_sdk/{{source_file_part}}" ]
}
# Compiles a Dart program with dartdevc
#
# Parameters:
#
# inputs (required): The inputs to dartdevc
#
# outputs (required): The files generated by dartdevc
#
# args (required): The arguments to pass to dartdevc
template("_dartdevc") {
if (flutter_prebuilt_dart_sdk) {
action(target_name) {
not_needed(invoker, [ "packages" ])
deps = [
":web_engine_sources",
":web_ui_library",
":web_ui_sources",
"//flutter:dart_sdk",
]
script = "//build/gn_run_binary.py"
inputs = invoker.inputs
outputs = invoker.outputs
pool = "//flutter/build/dart:dart_pool"
ext = ""
if (is_win) {
ext = ".exe"
}
dart = rebase_path("$host_prebuilt_dart_sdk/bin/dart$ext", root_out_dir)
dartdevc = rebase_path(
"$host_prebuilt_dart_sdk/bin/snapshots/dartdevc.dart.snapshot")
args = [
dart,
dartdevc,
] + invoker.args
}
} else {
prebuilt_dart_action(target_name) {
forward_variables_from(invoker, "*")
deps = [
":web_engine_sources",
":web_ui_library",
":web_ui_sources",
"//flutter:dart_sdk",
"//third_party/dart/pkg:pkg_files_stamp",
"//third_party/dart/utils/dartdevc:dartdevc_files_stamp",
"//third_party/dart/utils/dartdevc:dartdevc_sdk_patch_stamp",
]
script = "//third_party/dart/pkg/dev_compiler/bin/dartdevc.dart"
pool = "//flutter/build/dart:dart_pool"
}
}
}
# Compiles a Dart SDK with the kernel_worker
#
# Parameters:
#
# inputs (required): The inputs to the kernel_worker
#
# outputs (required): The files generated by the kernel_worker
#
# args (required): The arguments to pass to the kernel_worker
template("_kernel_worker") {
if (flutter_prebuilt_dart_sdk) {
action(target_name) {
deps = [
":web_engine_sources",
":web_ui_library",
":web_ui_sources",
"//flutter:dart_sdk",
]
script = "//build/gn_run_binary.py"
inputs = invoker.inputs
outputs = invoker.outputs
pool = "//flutter/build/dart:dart_pool"
ext = ""
if (is_win) {
ext = ".exe"
}
dart = rebase_path("$host_prebuilt_dart_sdk/bin/dart$ext", root_out_dir)
kernel_worker = rebase_path(
"$host_prebuilt_dart_sdk/bin/snapshots/kernel_worker.dart.snapshot")
args = [
dart,
kernel_worker,
] + invoker.args
}
} else {
prebuilt_dart_action(target_name) {
forward_variables_from(invoker, "*")
deps = [
":web_engine_sources",
":web_ui_library",
":web_ui_sources",
"//flutter:dart_sdk",
"//third_party/dart/pkg:pkg_files_stamp",
"//third_party/dart/utils/dartdevc:dartdevc_files_stamp",
"//third_party/dart/utils/dartdevc:dartdevc_sdk_patch_stamp",
]
script = "//third_party/dart/utils/bazel/kernel_worker.dart"
pool = "//flutter/build/dart:dart_pool"
}
}
}
# Compile the unsound DDC SDK's summary.
_kernel_worker("flutter_dartdevc_kernel_sdk_outline") {
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
outputs = [ sdk_dill ]
args = [
"--no-sound-null-safety",
"--summary-only",
"--target",
"ddc",
"--packages-file",
"file:///" + rebase_path(dart_sdk_package_config),
"--multi-root-scheme",
"org-dartlang-sdk",
"--multi-root",
"file:///" + rebase_path("$root_out_dir"),
"--libraries-file",
"org-dartlang-sdk:///flutter_web_sdk/libraries.json",
"--output",
rebase_path(sdk_dill),
"--source",
"dart:core",
# Additional Flutter web dart libraries
"--source",
"dart:ui",
"--source",
"dart:_engine",
]
}
# Compiles the unsound html only renderer.
_dartdevc("flutter_dartdevc_kernel_sdk") {
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
packages = dart_sdk_package_config
outputs = [
"$root_out_dir/flutter_web_sdk/kernel/amd/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/amd/dart_sdk.js.map",
"$root_out_dir/flutter_web_sdk/kernel/legacy/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/legacy/dart_sdk.js.map",
]
args = [
"--no-sound-null-safety",
"--compile-sdk",
"dart:core",
# Additional Flutter web dart libraries
"dart:ui",
"dart:_engine",
"--no-summarize",
"--packages",
"file:///" + rebase_path(dart_sdk_package_config),
"--multi-root-scheme",
"org-dartlang-sdk",
"--multi-root",
"file:///" + rebase_path("$root_out_dir"),
"--multi-root-output-path",
rebase_path("$root_out_dir/"),
"--libraries-file",
"org-dartlang-sdk:///flutter_web_sdk/libraries.json",
"--inline-source-map",
"-DFLUTTER_WEB_USE_SKIA=false",
"-DFLUTTER_WEB_AUTO_DETECT=false",
"--modules",
"amd",
"-o",
rebase_path("$root_out_dir/flutter_web_sdk/kernel/amd/dart_sdk.js"),
"--modules",
"legacy",
"-o",
rebase_path("$root_out_dir/flutter_web_sdk/kernel/legacy/dart_sdk.js"),
]
}
# Compiles the unsound canvaskit only renderer.
_dartdevc("flutter_dartdevc_canvaskit_kernel_sdk") {
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
packages = dart_sdk_package_config
outputs = [
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit/dart_sdk.js.map",
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit/dart_sdk.js.map",
]
args = [
"--no-sound-null-safety",
"--compile-sdk",
"dart:core",
# Additional Flutter web dart libraries
"dart:ui",
"dart:_engine",
"--no-summarize",
"--packages",
"file:///" + rebase_path(dart_sdk_package_config),
"--multi-root-scheme",
"org-dartlang-sdk",
"--multi-root",
"file:///" + rebase_path("$root_out_dir"),
"--multi-root-output-path",
rebase_path("$root_out_dir/"),
"--libraries-file",
"org-dartlang-sdk:///flutter_web_sdk/libraries.json",
"--inline-source-map",
"-DFLUTTER_WEB_USE_SKIA=true",
"-DFLUTTER_WEB_AUTO_DETECT=false",
"--modules",
"amd",
"-o",
rebase_path(
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit/dart_sdk.js"),
"--modules",
"legacy",
"-o",
rebase_path(
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit/dart_sdk.js"),
]
}
# Compiles the unsound autodetect renderer.
_dartdevc("flutter_dartdevc_canvaskit_html_kernel_sdk") {
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
packages = dart_sdk_package_config
outputs = [
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit-html/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit-html/dart_sdk.js.map",
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit-html/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit-html/dart_sdk.js.map",
]
args = [
"--no-sound-null-safety",
"--compile-sdk",
"dart:core",
# Additional Flutter web dart libraries
"dart:ui",
"dart:_engine",
"--no-summarize",
"--packages",
"file:///" + rebase_path(dart_sdk_package_config),
"--multi-root-scheme",
"org-dartlang-sdk",
"--multi-root",
"file:///" + rebase_path("$root_out_dir"),
"--multi-root-output-path",
rebase_path("$root_out_dir/"),
"--libraries-file",
"org-dartlang-sdk:///flutter_web_sdk/libraries.json",
"--inline-source-map",
"-DFLUTTER_WEB_USE_SKIA=true",
"-DFLUTTER_WEB_AUTO_DETECT=true",
"--modules",
"amd",
"-o",
rebase_path(
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit-html/dart_sdk.js"),
"--modules",
"legacy",
"-o",
rebase_path(
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit-html/dart_sdk.js"),
]
}
# Compiles the sound html only renderer.
_dartdevc("flutter_dartdevc_kernel_sdk_sound") {
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
packages = dart_sdk_package_config
outputs = [
"$root_out_dir/flutter_web_sdk/kernel/amd-sound/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/amd-sound/dart_sdk.js.map",
"$root_out_dir/flutter_web_sdk/kernel/legacy-sound/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/legacy-sound/dart_sdk.js.map",
]
args = [
"--sound-null-safety",
"--compile-sdk",
"dart:core",
# Additional Flutter web dart libraries
"dart:ui",
"dart:_engine",
"--no-summarize",
"--packages",
"file:///" + rebase_path(dart_sdk_package_config),
"--multi-root-scheme",
"org-dartlang-sdk",
"--multi-root",
"file:///" + rebase_path("$root_out_dir"),
"--multi-root-output-path",
rebase_path("$root_out_dir/"),
"--libraries-file",
"org-dartlang-sdk:///flutter_web_sdk/libraries.json",
"--inline-source-map",
"-DFLUTTER_WEB_USE_SKIA=false",
"-DFLUTTER_WEB_AUTO_DETECT=false",
"--modules",
"amd",
"-o",
rebase_path("$root_out_dir/flutter_web_sdk/kernel/amd-sound/dart_sdk.js"),
"--modules",
"legacy",
"-o",
rebase_path(
"$root_out_dir/flutter_web_sdk/kernel/legacy-sound/dart_sdk.js"),
]
}
# Compiles the sound canvaskit only renderer.
_dartdevc("flutter_dartdevc_canvaskit_kernel_sdk_sound") {
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
packages = dart_sdk_package_config
outputs = [
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit-sound/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit-sound/dart_sdk.js.map",
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit-sound/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit-sound/dart_sdk.js.map",
]
args = [
"--sound-null-safety",
"--compile-sdk",
"dart:core",
# Additional Flutter web dart libraries
"dart:ui",
"dart:_engine",
"--no-summarize",
"--packages",
"file:///" + rebase_path(dart_sdk_package_config),
"--multi-root-scheme",
"org-dartlang-sdk",
"--multi-root",
"file:///" + rebase_path("$root_out_dir"),
"--multi-root-output-path",
rebase_path("$root_out_dir/"),
"--libraries-file",
"org-dartlang-sdk:///flutter_web_sdk/libraries.json",
"--inline-source-map",
"-DFLUTTER_WEB_USE_SKIA=true",
"-DFLUTTER_WEB_AUTO_DETECT=false",
"--modules",
"amd",
"-o",
rebase_path(
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit-sound/dart_sdk.js"),
"--modules",
"legacy",
"-o",
rebase_path(
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit-sound/dart_sdk.js"),
]
}
# Compiles the sound autodetect renderer.
_dartdevc("flutter_dartdevc_canvaskit_html_kernel_sdk_sound") {
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
packages = dart_sdk_package_config
outputs = [
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit-html-sound/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit-html-sound/dart_sdk.js.map",
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit-html-sound/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit-html-sound/dart_sdk.js.map",
]
args = [
"--sound-null-safety",
"--compile-sdk",
"dart:core",
# Additional Flutter web dart libraries
"dart:ui",
"dart:_engine",
"--no-summarize",
"--packages",
"file:///" + rebase_path(dart_sdk_package_config),
"--multi-root-scheme",
"org-dartlang-sdk",
"--multi-root",
"file:///" + rebase_path("$root_out_dir"),
"--multi-root-output-path",
rebase_path("$root_out_dir/"),
"--libraries-file",
"org-dartlang-sdk:///flutter_web_sdk/libraries.json",
"--inline-source-map",
"-DFLUTTER_WEB_USE_SKIA=false",
"-DFLUTTER_WEB_AUTO_DETECT=true",
"--modules",
"amd",
"-o",
rebase_path(
"$root_out_dir/flutter_web_sdk/kernel/amd-canvaskit-html-sound/dart_sdk.js"),
"--modules",
"legacy",
"-o",
rebase_path(
"$root_out_dir/flutter_web_sdk/kernel/legacy-canvaskit-html-sound/dart_sdk.js"),
]
}
# Compile the sound DDC SDK's summary.
_kernel_worker("flutter_dartdevc_kernel_sdk_outline_sound") {
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
outputs = [ sdk_dill_sound ]
args = [
"--sound-null-safety",
"--summary-only",
"--target",
"ddc",
"--packages-file",
"file:///" + rebase_path(dart_sdk_package_config),
"--multi-root-scheme",
"org-dartlang-sdk",
"--multi-root",
"file:///" + rebase_path("$root_out_dir"),
"--libraries-file",
"org-dartlang-sdk:///flutter_web_sdk/libraries.json",
"--output",
rebase_path(sdk_dill_sound),
"--source",
"dart:core",
# Additional Flutter web dart libraries
"--source",
"dart:ui",
"--source",
"dart:_engine",
]
}
# Archives Flutter Web SDK
if (!is_fuchsia) {
zip_bundle_from_file("flutter_web_sdk_archive") {
output = "flutter-web-sdk-${full_platform_name}.zip"
deps = [
":flutter_dartdevc_canvaskit_html_kernel_sdk",
":flutter_dartdevc_canvaskit_html_kernel_sdk_sound",
":flutter_dartdevc_canvaskit_kernel_sdk",
":flutter_dartdevc_canvaskit_kernel_sdk_sound",
":flutter_dartdevc_kernel_sdk",
":flutter_dartdevc_kernel_sdk_outline",
":flutter_dartdevc_kernel_sdk_outline_sound",
":flutter_dartdevc_kernel_sdk_sound",
":web_engine_sources",
":web_ui_library",
":web_ui_sources",
]
sources = get_target_outputs(":flutter_dartdevc_canvaskit_html_kernel_sdk")
sources +=
get_target_outputs(":flutter_dartdevc_canvaskit_html_kernel_sdk_sound")
sources += get_target_outputs(":flutter_dartdevc_canvaskit_kernel_sdk")
sources +=
get_target_outputs(":flutter_dartdevc_canvaskit_kernel_sdk_sound")
sources += get_target_outputs(":flutter_dartdevc_kernel_sdk")
sources += get_target_outputs(":flutter_dartdevc_kernel_sdk_outline")
sources += get_target_outputs(":flutter_dartdevc_kernel_sdk_outline_sound")
sources += get_target_outputs(":flutter_dartdevc_kernel_sdk_sound")
sources += get_target_outputs(":web_ui_library")
tmp_files = []
foreach(source, sources) {
tmp_files += [
{
source = rebase_path(source)
destination = rebase_path(source, "$root_build_dir")
},
]
}
foreach(source, web_ui_sources) {
rebased_path = rebase_path(source, "//flutter/lib/web_ui/lib")
tmp_files += [
{
source = rebase_path(source)
destination = "flutter_web_sdk/lib/ui/$rebased_path"
},
]
}
foreach(source, web_engine_sources) {
rebased_path = rebase_path(source, "//flutter/lib/web_ui/lib/src")
tmp_files += [
{
source = rebase_path(source)
destination = "flutter_web_sdk/lib/_engine/$rebased_path"
},
]
}
files = tmp_files
}
}