blob: f10bd7631345733fb8aa8a33d8bdf1f237499ffd [file] [log] [blame]
# Copyright 2019 The Chromium 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("//chrome/browser/resources/tools/optimize_webui.gni")
import("//chromeos/components/web_applications/system_apps.gni")
import("//third_party/closure_compiler/compile_js.gni")
import("//ui/webui/resources/tools/js_modulizer.gni")
stage_folder = "$target_gen_dir/stage"
# Move files to the stage folder to combine all resources in the same folder for
# JS bundling with rollup.
# This is for files direct from the src/: input_folder="./".
copy("stage_static") {
sources = [
"../../../../../ui/file_manager/image_loader/piex_loader.js",
"app_context_test_support.js",
"error_reporter.js",
"launch.js",
"mojo_api_bootstrap.js",
"piex_module.js",
"piex_module_loader.js",
"receiver.js",
"sandboxed_load_time_data.js",
]
outputs = [ stage_folder + "/{{source_file_part}}" ]
}
# This is for files that are generated in "gen/".
copy("stage_generated") {
sources = [
"$target_gen_dir/../../../system_apps/public/js/message_pipe.m.js",
"$target_gen_dir/../../media_app_ui.mojom-lite.js",
"$target_gen_dir/message_types.m.js",
]
outputs = [ stage_folder + "/{{source_file_part}}" ]
deps = [
":modulize",
"//chromeos/components/media_app_ui:mojo_bindings_js",
"//chromeos/components/system_apps/public/js:modulize",
]
}
optimize_webui("launch_rollup") {
host = "media-app"
js_out_files = [ "launch.rollup.js" ]
js_module_in_files = [ "launch.js" ]
input = rebase_path(stage_folder, root_build_dir)
deps = [
":stage_generated",
":stage_static",
]
}
optimize_webui("receiver_rollup") {
host = "media-app"
js_out_files = [ "receiver.rollup.js" ]
js_module_in_files = [ "receiver.js" ]
input = rebase_path(stage_folder, root_build_dir)
deps = [
":stage_generated",
":stage_static",
]
}
optimize_webui("piex_rollup") {
host = "media-app"
js_out_files = [ "piex_module.rollup.js" ]
js_module_in_files = [ "piex_module.js" ]
input = rebase_path(stage_folder, root_build_dir)
deps = [
":stage_generated",
":stage_static",
]
}
js_modulizer("modulize") {
input_files = [ "message_types.js" ]
}
# Build rules below here are just used for typechecking and don't influence what
# is shipped to resources.pak.
media_closure_flags = system_app_closure_flags_strict + [
"hide_warnings_for=chromeos/components/media_app_ui/media_app_ui.mojom-lite-for-compile.js",
# For all js module in source tree.
"js_module_root=" + rebase_path(".", root_build_dir),
# For all dynamic generated js module.
"js_module_root=" +
rebase_path(target_gen_dir, root_build_dir),
]
group("closure_compile") {
deps = [
":closure_compile_app",
":closure_compile_index",
":closure_compile_piex_module",
]
}
js_type_check("closure_compile_index") {
closure_flags = media_closure_flags
deps = [ ":launch" ]
}
js_type_check("closure_compile_app") {
closure_flags = media_closure_flags
deps = [ ":receiver" ]
}
js_type_check("closure_compile_piex_module") {
closure_flags = media_closure_flags
deps = [ ":piex_module" ]
}
js_library("app_context_test_support") {
}
js_library("launch") {
externs_list = [
"//chromeos/components/web_applications/externs/file_handling.externs.js",
"dom_draft.externs.js",
# The privileged context can't access the app, but shares struct definitions
# passed over postMessage.
"media_app.externs.js",
]
deps = [
":app_context_test_support",
":error_reporter",
":message_types.m",
":mojo_api_bootstrap",
"//chromeos/components/system_apps/public/js:message_pipe.m",
]
}
js_library("message_types") {
}
js_library("message_types.m") {
sources = [ "$root_gen_dir/chromeos/components/media_app_ui/resources/js/message_types.m.js" ]
extra_deps = [ ":modulize" ]
}
js_library("error_reporter") {
externs_list = [ "$externs_path/crash_report_private.js" ]
}
js_library("piex_module_loader") {
}
js_library("piex_module") {
deps = [ "//ui/file_manager/image_loader:piex_loader" ]
}
js_library("sandboxed_load_time_data") {
}
js_library("receiver") {
externs_list = [ "media_app.externs.js" ]
deps = [
":app_context_test_support",
":message_types.m",
":piex_module_loader",
":sandboxed_load_time_data",
"//chromeos/components/system_apps/public/js:message_pipe.m",
]
}
js_library("mojo_api_bootstrap") {
deps = [
"//chromeos/components/media_app_ui:mojo_bindings_js_library_for_compile",
]
}