blob: 7ddb146b120795379a2c178e0a6b1b76462217c4 [file] [log] [blame]
# 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("//third_party/dart/build/dart/dart_action.gni")
import("//third_party/dart/utils/compile_platform.gni")
sdk_dill = "$root_out_dir/flutter_web_sdk/kernel/flutter_ddc_sdk.dill"
web_ui_sources = exec_script("//third_party/dart/tools/list_dart_files.py",
[
"absolute",
rebase_path("//flutter/lib/web_ui/lib/src/ui"),
],
"list lines")
web_ui_sources += [ "//flutter/lib/web_ui/lib/ui.dart" ]
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 += [ "//flutter/lib/web_ui/lib/src/engine.dart" ]
group("web_sdk") {
deps = [
":flutter_dartdevc_canvaskit_kernel_sdk",
":flutter_dartdevc_kernel_sdk",
":flutter_dartdevc_kernel_sdk_outline",
":web_engine_sources",
":web_ui_library",
":web_ui_sources",
]
}
prebuilt_dart_action("web_ui_sources") {
inputs = web_ui_sources + [ "sdk_rewriter.dart" ]
packages = "//third_party/dart/.packages"
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/")
args = [
"--output-dir=$output_dir",
"--input-dir=$input_dir",
"--ui",
]
outputs = [
"$root_out_dir/flutter_web_engine_sdk_stamp",
]
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 = "//third_party/dart/.packages"
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/")
args = [
"--output-dir=$output_dir",
"--input-dir=$input_dir",
"--engine",
]
outputs = [
"$root_out_dir/flutter_web_sdk_stamp",
]
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}}",
]
}
# Compile the DDC SDK's summary.
prebuilt_dart_action("flutter_dartdevc_kernel_sdk_outline") {
deps = [
"//third_party/dart:create_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",
]
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
outputs = [
sdk_dill,
]
script = "//third_party/dart/utils/bazel/kernel_worker.dart"
args = [
"--summary-only",
"--target",
"ddc",
"--packages-file",
"file:///" + rebase_path("//third_party/dart/.packages"),
"--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 DDC SDK's JS code.
prebuilt_dart_action("flutter_dartdevc_kernel_sdk") {
deps = [
"//third_party/dart:create_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",
]
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
packages = "//third_party/dart/.packages"
script = "//third_party/dart/pkg/dev_compiler/bin/dartdevc.dart"
outputs = [
"$root_out_dir/flutter_web_sdk/kernel/amd/dart_sdk.js",
"$root_out_dir/flutter_web_sdk/kernel/amd/dart_sdk.js.map",
]
args = [
"-k",
"--compile-sdk",
"dart:core",
# Additional Flutter web dart libraries
"dart:ui",
"dart:_engine",
"--no-summarize",
"--packages",
"file:///" + rebase_path("//third_party/dart/.packages"),
"--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",
"--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 DDC CanvasKit SDK's JS code.
prebuilt_dart_action("flutter_dartdevc_canvaskit_kernel_sdk") {
deps = [
"//third_party/dart:create_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",
]
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources + web_engine_sources
packages = "//third_party/dart/.packages"
script = "//third_party/dart/pkg/dev_compiler/bin/dartdevc.dart"
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",
]
args = [
"-k",
"--compile-sdk",
"dart:core",
# Additional Flutter web dart libraries
"dart:ui",
"dart:_engine",
"--no-summarize",
"--packages",
"file:///" + rebase_path("//third_party/dart/.packages"),
"--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",
"--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"),
]
}