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") {
}
# async-default keep a per-thread dispatcher for async.
fuchsia_sdk_lib_pkg("async_default") {
fuchsia_sdk_pkg("async_default") {
package_name = "async-default"
sources = [
"include/lib/async/default.h",
]
libs = [ "async-default" ]
}
fuchsia_sdk_pkg("component") {
fidl_files = [
fuchsia_sdk_fidl_pkg("component") {
sources = [
"application_controller.fidl",
"application_environment.fidl",
"application_environment_controller.fidl",
"application_launcher.fidl",
"application_runner.fidl",
"environment.fidl",
"environment_controller.fidl",
"flat_namespace.fidl",
"loader.fidl",
"runner.fidl",
"service_provider.fidl",
]
fidl_deps = [ ":mem" ]
deps = [
":mem",
]
}
fuchsia_sdk_lib_pkg("fdio") {
fuchsia_sdk_pkg("fdio") {
sources = [
"include/fdio/debug.h",
"include/fdio/io.fidl.h",
......@@ -60,6 +64,8 @@ fuchsia_sdk_lib_pkg("fdio") {
"include/fdio/vfs.h",
"include/fdio/watcher.h",
]
libs = [ "fdio" ]
}
fuchsia_sdk_pkg("fidl") {
......@@ -147,12 +153,10 @@ fuchsia_sdk_pkg("fidl_cpp") {
]
}
fuchsia_sdk_pkg("geometry") {
fidl_files = [ "geometry.fidl" ]
}
fuchsia_sdk_pkg("gfx") {
fidl_files = [
fuchsia_sdk_fidl_pkg("gfx") {
namespace = "fuchsia.ui"
namespace_path = "fuchsia/ui"
sources = [
"commands.fidl",
"display_info.fidl",
"events.fidl",
......@@ -163,11 +167,15 @@ fuchsia_sdk_pkg("gfx") {
"shapes.fidl",
"types.fidl",
]
fidl_deps = [ ":images" ]
deps = [
":images",
]
}
fuchsia_sdk_pkg("images") {
fidl_files = [
fuchsia_sdk_fidl_pkg("images") {
namespace = "fuchsia"
namespace_path = "fuchsia"
sources = [
"encoded_image.fidl",
"image_info.fidl",
"image_pipe.fidl",
......@@ -176,8 +184,10 @@ fuchsia_sdk_pkg("images") {
]
}
fuchsia_sdk_pkg("input") {
fidl_files = [
fuchsia_sdk_fidl_pkg("input") {
namespace = "fuchsia.ui"
namespace_path = "fuchsia/ui"
sources = [
"ime_service.fidl",
"input_connection.fidl",
"input_device_registry.fidl",
......@@ -191,15 +201,25 @@ fuchsia_sdk_pkg("input") {
]
}
fuchsia_sdk_lib_pkg("launchpad") {
fuchsia_sdk_pkg("launchpad") {
sources = [
"include/launchpad/launchpad.h",
"include/launchpad/vmo.h",
]
libs = [ "launchpad" ]
}
fuchsia_sdk_fidl_pkg("math") {
namespace = "fuchsia"
namespace_path = "fuchsia"
sources = [
"geometry.fidl",
]
}
fuchsia_sdk_pkg("media") {
fidl_files = [
fuchsia_sdk_fidl_pkg("media") {
sources = [
"audio_capturer.fidl",
"audio_renderer.fidl",
"audio_server.fidl",
......@@ -213,43 +233,43 @@ fuchsia_sdk_pkg("media") {
]
}
fuchsia_sdk_pkg("mem") {
fidl_namespace = "fuchsia"
fidl_namespace_path = "fuchsia"
fuchsia_sdk_fidl_pkg("mem") {
namespace = "fuchsia"
namespace_path = "fuchsia"
fidl_files = [ "buffer.fidl" ]
sources = [
"buffer.fidl",
]
}
fuchsia_sdk_pkg("netstack") {
fidl_files = [
fuchsia_sdk_fidl_pkg("netstack") {
sources = [
"net_address.fidl",
"netstack.fidl",
]
}
fuchsia_sdk_pkg("presentation") {
fidl_files = [
fuchsia_sdk_fidl_pkg("presentation") {
sources = [
"display_usage.fidl",
"presentation.fidl",
"presenter.fidl",
]
fidl_deps = [ ":views_v1" ]
}
fuchsia_sdk_lib_pkg("svc") {
sources = [
"include/lib/svc/dir.h",
deps = [
":views_v1",
]
}
fuchsia_sdk_pkg("ui") {
fidl_files = [
fuchsia_sdk_fidl_pkg("scenic") {
namespace = "fuchsia.ui"
namespace_path = "fuchsia/ui"
sources = [
"commands.fidl",
"events.fidl",
"scenic.fidl",
"session.fidl",
]
fidl_deps = [
deps = [
":component",
":gfx",
":input",
......@@ -257,38 +277,48 @@ fuchsia_sdk_pkg("ui") {
]
}
fuchsia_sdk_pkg("views") {
fidl_files = [
fuchsia_sdk_pkg("svc") {
sources = [
"include/lib/svc/dir.h",
]
libs = [ "svc" ]
}
fuchsia_sdk_fidl_pkg("views") {
sources = [
"commands.fidl",
"events.fidl",
]
fidl_deps = [
deps = [
":gfx",
":images",
]
}
fuchsia_sdk_pkg("views_v1") {
fidl_files = [
fuchsia_sdk_fidl_pkg("views_v1") {
sources = [
"view_containers.fidl",
"view_properties.fidl",
"views.fidl",
"view_tree_token.fidl",
"view_manager.fidl",
"view_properties.fidl",
"view_provider.fidl",
"view_tree_token.fidl",
"view_trees.fidl",
"views.fidl",
]
fidl_deps = [
":geometry",
deps = [
":gfx",
":ui",
":images",
":math",
":scenic",
":views_v1_token",
]
}
fuchsia_sdk_pkg("views_v1_token") {
fidl_files = [ "view_token.fidl" ]
fuchsia_sdk_fidl_pkg("views_v1_token") {
sources = [
"view_token.fidl",
]
}
fuchsia_sdk_pkg("zx") {
......
......@@ -52,8 +52,6 @@ template("fidl_library") {
_tables_file = "$_output_gen_dir/${_library_name}.fidl-tables.cc"
action("${target_name}_response_file") {
visibility = [ ":*" ]
script = "//third_party/fuchsia-sdk/gen_fidl_response_file.py"
forward_variables_from(invoker,
......
......@@ -6,73 +6,72 @@ assert(is_fuchsia)
import("fidl_library.gni")
# Template for Fuchsia SDK packages. Each package may contain a mix of C++ files
# and FIDL interfaces. The following parameters can be specified when
# instantiating this template:
# Templates for Fuchsia SDK packages.
# Declares a package specifying FIDL files and its dependencies.
#
# Parameters:
# package_name - Name of the library. target_name is used if name
# is not specified explicitly.
# fidl_namespace, fidl_namespace_path - FIDL namespace. See fidl_library.gni
# for details.
# sources - List of sources relative to sdk/pkg/${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.
# namespace, namespace_path - FIDL namespace. See fidl_library.gni
# for details.
# sources - List of sources relative to sdk/fidl/${name}.
# deps - List of dependencies.
# fidl_deps - List of FIDL dependencies for this package (must be other
# fuchsia_sdk_pkg).
template("fuchsia_sdk_pkg") {
template("fuchsia_sdk_fidl_pkg") {
_package_name = target_name
if (defined(invoker.package_name)) {
_package_name = invoker.package_name
}
_has_fidl_files = defined(invoker.fidl_files)
if (_has_fidl_files) {
fidl_library("${target_name}_fidl") {
forward_variables_from(invoker,
[
"public_deps",
"testonly",
"visibility",
])
library_name = _package_name
fidl_library(target_name) {
forward_variables_from(invoker,
[
"deps",
"public_deps",
"testonly",
"visibility",
])
if (defined(invoker.fidl_namespace)) {
assert(
defined(invoker.fidl_namespace_path),
"SDK packages with fidl_namespace must specify fidl_namespace_path")
namespace = invoker.fidl_namespace
namespace_path = invoker.fidl_namespace_path
library_name = _package_name
_library_name = "${namespace}.${_package_name}"
} else {
_library_name = _package_name
}
if (defined(invoker.namespace)) {
assert(defined(invoker.namespace_path),
"SDK packages with namespace must specify namespace_path")
namespace = invoker.namespace
namespace_path = invoker.namespace_path
sources = []
foreach(file, invoker.fidl_files) {
sources += [ "sdk/fidl/${_library_name}/${file}" ]
}
_library_name = "${namespace}.${_package_name}"
} else {
_library_name = _package_name
}
if (defined(invoker.fidl_deps)) {
deps = []
foreach(fidl_dep, invoker.fidl_deps) {
deps += [ "${fidl_dep}_fidl" ]
}
}
sources = []
foreach(file, invoker.sources) {
sources += [ "sdk/fidl/${_library_name}/${file}" ]
}
}
}
# 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") {
visibility = [ ":${invoker.target_name}" ]
include_dirs = [ "sdk/pkg/${_package_name}/include" ]
}
static_library("${target_name}") {
static_library(target_name) {
forward_variables_from(invoker,
[
"data",
......@@ -89,12 +88,6 @@ template("fuchsia_sdk_pkg") {
}
}
if (_has_fidl_files) {
public_deps = [
":${invoker.target_name}_fidl",
]
}
public_configs = [ ":${invoker.target_name}_config" ]
if (defined(invoker.libs)) {
......@@ -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