Commit d23c9065 authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

Fuchsia: Refactor Fuchsia SDK package GN templates.

Refactors the Fuchsia SDK packages to make dependencies on SDK FIDL
libraries easier. The previous definitions hid FIDL definitions inside
a template subtarget with inaccessible visibility.

* Add fuchsia_sdk_fidl_pkg() for FIDL files only, which can be
  depended on by directly specifying the target_name (no suffix).
* Remove fidl_* from fuchsia_sdk_pkg.
* Combine fuchsia_sdk_lib_pkg and fuchsia_sdk_pkg - there is so much
  overlap between the two that the convenience seemed minor compared
  to the overhead of adding another rule.

Change-Id: I2db7191d73fd971442b05ad91b831882cbaefe7e
Reviewed-on: https://chromium-review.googlesource.com/1080207
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563116}
parent 1604ce47
...@@ -24,28 +24,32 @@ fuchsia_sdk_pkg("async") { ...@@ -24,28 +24,32 @@ fuchsia_sdk_pkg("async") {
} }
# async-default keep a per-thread dispatcher for async. # async-default keep a per-thread dispatcher for async.
fuchsia_sdk_lib_pkg("async_default") { fuchsia_sdk_pkg("async_default") {
package_name = "async-default" package_name = "async-default"
sources = [ sources = [
"include/lib/async/default.h", "include/lib/async/default.h",
] ]
libs = [ "async-default" ]
} }
fuchsia_sdk_pkg("component") { fuchsia_sdk_fidl_pkg("component") {
fidl_files = [ sources = [
"application_controller.fidl", "application_controller.fidl",
"application_environment.fidl",
"application_environment_controller.fidl",
"application_launcher.fidl", "application_launcher.fidl",
"application_runner.fidl", "environment.fidl",
"environment_controller.fidl",
"flat_namespace.fidl", "flat_namespace.fidl",
"loader.fidl", "loader.fidl",
"runner.fidl",
"service_provider.fidl", "service_provider.fidl",
] ]
fidl_deps = [ ":mem" ] deps = [
":mem",
]
} }
fuchsia_sdk_lib_pkg("fdio") { fuchsia_sdk_pkg("fdio") {
sources = [ sources = [
"include/fdio/debug.h", "include/fdio/debug.h",
"include/fdio/io.fidl.h", "include/fdio/io.fidl.h",
...@@ -60,6 +64,8 @@ fuchsia_sdk_lib_pkg("fdio") { ...@@ -60,6 +64,8 @@ fuchsia_sdk_lib_pkg("fdio") {
"include/fdio/vfs.h", "include/fdio/vfs.h",
"include/fdio/watcher.h", "include/fdio/watcher.h",
] ]
libs = [ "fdio" ]
} }
fuchsia_sdk_pkg("fidl") { fuchsia_sdk_pkg("fidl") {
...@@ -147,12 +153,10 @@ fuchsia_sdk_pkg("fidl_cpp") { ...@@ -147,12 +153,10 @@ fuchsia_sdk_pkg("fidl_cpp") {
] ]
} }
fuchsia_sdk_pkg("geometry") { fuchsia_sdk_fidl_pkg("gfx") {
fidl_files = [ "geometry.fidl" ] namespace = "fuchsia.ui"
} namespace_path = "fuchsia/ui"
sources = [
fuchsia_sdk_pkg("gfx") {
fidl_files = [
"commands.fidl", "commands.fidl",
"display_info.fidl", "display_info.fidl",
"events.fidl", "events.fidl",
...@@ -163,11 +167,15 @@ fuchsia_sdk_pkg("gfx") { ...@@ -163,11 +167,15 @@ fuchsia_sdk_pkg("gfx") {
"shapes.fidl", "shapes.fidl",
"types.fidl", "types.fidl",
] ]
fidl_deps = [ ":images" ] deps = [
":images",
]
} }
fuchsia_sdk_pkg("images") { fuchsia_sdk_fidl_pkg("images") {
fidl_files = [ namespace = "fuchsia"
namespace_path = "fuchsia"
sources = [
"encoded_image.fidl", "encoded_image.fidl",
"image_info.fidl", "image_info.fidl",
"image_pipe.fidl", "image_pipe.fidl",
...@@ -176,8 +184,10 @@ fuchsia_sdk_pkg("images") { ...@@ -176,8 +184,10 @@ fuchsia_sdk_pkg("images") {
] ]
} }
fuchsia_sdk_pkg("input") { fuchsia_sdk_fidl_pkg("input") {
fidl_files = [ namespace = "fuchsia.ui"
namespace_path = "fuchsia/ui"
sources = [
"ime_service.fidl", "ime_service.fidl",
"input_connection.fidl", "input_connection.fidl",
"input_device_registry.fidl", "input_device_registry.fidl",
...@@ -191,15 +201,25 @@ fuchsia_sdk_pkg("input") { ...@@ -191,15 +201,25 @@ fuchsia_sdk_pkg("input") {
] ]
} }
fuchsia_sdk_lib_pkg("launchpad") { fuchsia_sdk_pkg("launchpad") {
sources = [ sources = [
"include/launchpad/launchpad.h", "include/launchpad/launchpad.h",
"include/launchpad/vmo.h", "include/launchpad/vmo.h",
] ]
libs = [ "launchpad" ]
}
fuchsia_sdk_fidl_pkg("math") {
namespace = "fuchsia"
namespace_path = "fuchsia"
sources = [
"geometry.fidl",
]
} }
fuchsia_sdk_pkg("media") { fuchsia_sdk_fidl_pkg("media") {
fidl_files = [ sources = [
"audio_capturer.fidl", "audio_capturer.fidl",
"audio_renderer.fidl", "audio_renderer.fidl",
"audio_server.fidl", "audio_server.fidl",
...@@ -213,43 +233,43 @@ fuchsia_sdk_pkg("media") { ...@@ -213,43 +233,43 @@ fuchsia_sdk_pkg("media") {
] ]
} }
fuchsia_sdk_pkg("mem") { fuchsia_sdk_fidl_pkg("mem") {
fidl_namespace = "fuchsia" namespace = "fuchsia"
fidl_namespace_path = "fuchsia" namespace_path = "fuchsia"
fidl_files = [ "buffer.fidl" ] sources = [
"buffer.fidl",
]
} }
fuchsia_sdk_pkg("netstack") { fuchsia_sdk_fidl_pkg("netstack") {
fidl_files = [ sources = [
"net_address.fidl", "net_address.fidl",
"netstack.fidl", "netstack.fidl",
] ]
} }
fuchsia_sdk_pkg("presentation") { fuchsia_sdk_fidl_pkg("presentation") {
fidl_files = [ sources = [
"display_usage.fidl", "display_usage.fidl",
"presentation.fidl", "presentation.fidl",
"presenter.fidl", "presenter.fidl",
] ]
fidl_deps = [ ":views_v1" ] deps = [
} ":views_v1",
fuchsia_sdk_lib_pkg("svc") {
sources = [
"include/lib/svc/dir.h",
] ]
} }
fuchsia_sdk_pkg("ui") { fuchsia_sdk_fidl_pkg("scenic") {
fidl_files = [ namespace = "fuchsia.ui"
namespace_path = "fuchsia/ui"
sources = [
"commands.fidl", "commands.fidl",
"events.fidl", "events.fidl",
"scenic.fidl", "scenic.fidl",
"session.fidl", "session.fidl",
] ]
fidl_deps = [ deps = [
":component", ":component",
":gfx", ":gfx",
":input", ":input",
...@@ -257,38 +277,48 @@ fuchsia_sdk_pkg("ui") { ...@@ -257,38 +277,48 @@ fuchsia_sdk_pkg("ui") {
] ]
} }
fuchsia_sdk_pkg("views") { fuchsia_sdk_pkg("svc") {
fidl_files = [ sources = [
"include/lib/svc/dir.h",
]
libs = [ "svc" ]
}
fuchsia_sdk_fidl_pkg("views") {
sources = [
"commands.fidl", "commands.fidl",
"events.fidl", "events.fidl",
] ]
fidl_deps = [ deps = [
":gfx", ":gfx",
":images", ":images",
] ]
} }
fuchsia_sdk_pkg("views_v1") { fuchsia_sdk_fidl_pkg("views_v1") {
fidl_files = [ sources = [
"view_containers.fidl", "view_containers.fidl",
"view_properties.fidl",
"views.fidl",
"view_tree_token.fidl",
"view_manager.fidl", "view_manager.fidl",
"view_properties.fidl",
"view_provider.fidl", "view_provider.fidl",
"view_tree_token.fidl",
"view_trees.fidl", "view_trees.fidl",
"views.fidl",
] ]
fidl_deps = [ deps = [
":geometry",
":gfx", ":gfx",
":ui",
":images", ":images",
":math",
":scenic",
":views_v1_token", ":views_v1_token",
] ]
} }
fuchsia_sdk_pkg("views_v1_token") { fuchsia_sdk_fidl_pkg("views_v1_token") {
fidl_files = [ "view_token.fidl" ] sources = [
"view_token.fidl",
]
} }
fuchsia_sdk_pkg("zx") { fuchsia_sdk_pkg("zx") {
......
...@@ -52,8 +52,6 @@ template("fidl_library") { ...@@ -52,8 +52,6 @@ template("fidl_library") {
_tables_file = "$_output_gen_dir/${_library_name}.fidl-tables.cc" _tables_file = "$_output_gen_dir/${_library_name}.fidl-tables.cc"
action("${target_name}_response_file") { action("${target_name}_response_file") {
visibility = [ ":*" ]
script = "//third_party/fuchsia-sdk/gen_fidl_response_file.py" script = "//third_party/fuchsia-sdk/gen_fidl_response_file.py"
forward_variables_from(invoker, forward_variables_from(invoker,
......
...@@ -6,34 +6,27 @@ assert(is_fuchsia) ...@@ -6,34 +6,27 @@ assert(is_fuchsia)
import("fidl_library.gni") import("fidl_library.gni")
# Template for Fuchsia SDK packages. Each package may contain a mix of C++ files # Templates for Fuchsia SDK packages.
# and FIDL interfaces. The following parameters can be specified when
# instantiating this template: # Declares a package specifying FIDL files and its dependencies.
#
# Parameters:
# package_name - Name of the library. target_name is used if name # package_name - Name of the library. target_name is used if name
# is not specified explicitly. # is not specified explicitly.
# fidl_namespace, fidl_namespace_path - FIDL namespace. See fidl_library.gni # namespace, namespace_path - FIDL namespace. See fidl_library.gni
# for details. # for details.
# sources - List of sources relative to sdk/pkg/${name}. # sources - List of sources relative to sdk/fidl/${name}.
# fidl_sources - List of .fidl files relative to
# sdk/fidl/${fidl_namespace}.${name}.
# public_deps - List of public dependencies which are propagated to
# dependents.
# deps - List of dependencies. # deps - List of dependencies.
# fidl_deps - List of FIDL dependencies for this package (must be other template("fuchsia_sdk_fidl_pkg") {
# fuchsia_sdk_pkg).
template("fuchsia_sdk_pkg") {
_package_name = target_name _package_name = target_name
if (defined(invoker.package_name)) { if (defined(invoker.package_name)) {
_package_name = invoker.package_name _package_name = invoker.package_name
} }
_has_fidl_files = defined(invoker.fidl_files) fidl_library(target_name) {
if (_has_fidl_files) {
fidl_library("${target_name}_fidl") {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"deps",
"public_deps", "public_deps",
"testonly", "testonly",
"visibility", "visibility",
...@@ -41,12 +34,11 @@ template("fuchsia_sdk_pkg") { ...@@ -41,12 +34,11 @@ template("fuchsia_sdk_pkg") {
library_name = _package_name library_name = _package_name
if (defined(invoker.fidl_namespace)) { if (defined(invoker.namespace)) {
assert( assert(defined(invoker.namespace_path),
defined(invoker.fidl_namespace_path), "SDK packages with namespace must specify namespace_path")
"SDK packages with fidl_namespace must specify fidl_namespace_path") namespace = invoker.namespace
namespace = invoker.fidl_namespace namespace_path = invoker.namespace_path
namespace_path = invoker.fidl_namespace_path
_library_name = "${namespace}.${_package_name}" _library_name = "${namespace}.${_package_name}"
} else { } else {
...@@ -54,17 +46,24 @@ template("fuchsia_sdk_pkg") { ...@@ -54,17 +46,24 @@ template("fuchsia_sdk_pkg") {
} }
sources = [] sources = []
foreach(file, invoker.fidl_files) { foreach(file, invoker.sources) {
sources += [ "sdk/fidl/${_library_name}/${file}" ] sources += [ "sdk/fidl/${_library_name}/${file}" ]
} }
if (defined(invoker.fidl_deps)) {
deps = []
foreach(fidl_dep, invoker.fidl_deps) {
deps += [ "${fidl_dep}_fidl" ]
}
}
} }
}
# Declares a package containing uncompiled code and/or precompiled libraries.
#
# Parameters:
# package_name - Name of the library. target_name is used if name
# is not specified explicitly.
# sources - List of sources relative to sdk/pkg/${name}.
# deps - List of dependencies.
# libs - List of precompiled libraries.
template("fuchsia_sdk_pkg") {
_package_name = target_name
if (defined(invoker.package_name)) {
_package_name = invoker.package_name
} }
config("${target_name}_config") { config("${target_name}_config") {
...@@ -72,7 +71,7 @@ template("fuchsia_sdk_pkg") { ...@@ -72,7 +71,7 @@ template("fuchsia_sdk_pkg") {
include_dirs = [ "sdk/pkg/${_package_name}/include" ] include_dirs = [ "sdk/pkg/${_package_name}/include" ]
} }
static_library("${target_name}") { static_library(target_name) {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"data", "data",
...@@ -89,12 +88,6 @@ template("fuchsia_sdk_pkg") { ...@@ -89,12 +88,6 @@ template("fuchsia_sdk_pkg") {
} }
} }
if (_has_fidl_files) {
public_deps = [
":${invoker.target_name}_fidl",
]
}
public_configs = [ ":${invoker.target_name}_config" ] public_configs = [ ":${invoker.target_name}_config" ]
if (defined(invoker.libs)) { if (defined(invoker.libs)) {
...@@ -103,14 +96,3 @@ template("fuchsia_sdk_pkg") { ...@@ -103,14 +96,3 @@ template("fuchsia_sdk_pkg") {
} }
} }
} }
template("fuchsia_sdk_lib_pkg") {
fuchsia_sdk_pkg(target_name) {
forward_variables_from(invoker, "*")
if (defined(invoker.package_name)) {
libs = [ invoker.package_name ]
} else {
libs = [ target_name ]
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment