Commit c354aa9a authored by Hans Wennborg's avatar Hans Wennborg Committed by Commit Bot

Revert "[Fuchsia] Remove namespace_path parameter from FIDL targets"

This reverts commit a6be9ec6.

Reason for revert:
Reverting in order to revert reverse-dependent
https://chromium-review.googlesource.com/c/chromium/src/+/1246681

Original change's description:
> [Fuchsia] Remove namespace_path parameter from FIDL targets
> 
> GN now supports string_replace(), which allows to remove namespace_path
> 
> TBR=dcheng@chromium.org (trivial change in //base)
> 
> Change-Id: Iac8a71b6962cf48bc7a79e2f7fc62a88969f80a1
> Reviewed-on: https://chromium-review.googlesource.com/1246834
> Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
> Reviewed-by: Kevin Marshall <kmarshall@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#594473}

TBR=kmarshall@chromium.org,sergeyu@chromium.org

Change-Id: Ibc138775c8b32a5d2d421a39ff4fe7ef7709826a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/1249262Reviewed-by: default avatarHans Wennborg <hans@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594670}
parent 27977555
...@@ -2199,6 +2199,7 @@ if (is_ios || is_mac) { ...@@ -2199,6 +2199,7 @@ if (is_ios || is_mac) {
if (is_fuchsia) { if (is_fuchsia) {
fidl_library("testfidl") { fidl_library("testfidl") {
namespace = "base.fuchsia" namespace = "base.fuchsia"
namespace_path = "base/fuchsia"
sources = [ sources = [
"fuchsia/test.fidl", "fuchsia/test.fidl",
......
...@@ -12,6 +12,13 @@ assert(is_fuchsia) ...@@ -12,6 +12,13 @@ assert(is_fuchsia)
# library_name - (optional) Name of the library. target_name is used if name # library_name - (optional) Name of the library. target_name is used if name
# is not specified explicitly. # is not specified explicitly.
# namespace - (optional) Namespace for the library. # namespace - (optional) Namespace for the library.
# namespace_path - (optional) namespace with '.' are replaced with '/', e.g.
# if namespace is "fuchsia.foo", then namespace_path must be
# set to "fuchsia/foo". This parameter must be specified when
# namespace is specified.
# TODO(sergeyu): In theory namespace_path can be generated
# from name, but GN doesn't provide any tools to perform this
# conversion without invoking a python script.
# deps - (optional) List of other fidl_library() targets that this # deps - (optional) List of other fidl_library() targets that this
# FIDL library depends on. # FIDL library depends on.
# #
...@@ -19,7 +26,11 @@ assert(is_fuchsia) ...@@ -19,7 +26,11 @@ assert(is_fuchsia)
# files. # files.
template("fidl_library") { template("fidl_library") {
forward_variables_from(invoker, [ "namespace" ]) forward_variables_from(invoker,
[
"namespace",
"namespace_path",
])
_library_basename = target_name _library_basename = target_name
if (defined(invoker.library_name)) { if (defined(invoker.library_name)) {
...@@ -27,9 +38,10 @@ template("fidl_library") { ...@@ -27,9 +38,10 @@ template("fidl_library") {
} }
if (defined(namespace)) { if (defined(namespace)) {
assert(defined(namespace_path),
"FIDL libraries with namespace must specify namespace_path")
_library_name = "${namespace}.${_library_basename}" _library_name = "${namespace}.${_library_basename}"
_namespace_path = string_replace(namespace, ".", "/") _library_path = "${namespace_path}/${_library_basename}"
_library_path = "${_namespace_path}/${_library_basename}"
} else { } else {
_library_name = _library_basename _library_name = _library_basename
_library_path = _library_basename _library_path = _library_basename
......
...@@ -13,7 +13,8 @@ import("//build/config/fuchsia/fidl_library.gni") ...@@ -13,7 +13,8 @@ import("//build/config/fuchsia/fidl_library.gni")
# Parameters: # 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.
# namespace - FIDL namespace. # namespace, namespace_path - FIDL namespace. See fidl_library.gni
# for details.
# sources - List of sources relative to sdk/fidl/${name}. # sources - List of sources relative to sdk/fidl/${name}.
# deps - List of dependencies. # deps - List of dependencies.
template("fuchsia_sdk_fidl_pkg") { template("fuchsia_sdk_fidl_pkg") {
...@@ -34,7 +35,10 @@ template("fuchsia_sdk_fidl_pkg") { ...@@ -34,7 +35,10 @@ template("fuchsia_sdk_fidl_pkg") {
library_name = _package_name library_name = _package_name
if (defined(invoker.namespace)) { if (defined(invoker.namespace)) {
assert(defined(invoker.namespace_path),
"SDK packages with namespace must specify namespace_path")
namespace = invoker.namespace namespace = invoker.namespace
namespace_path = invoker.namespace_path
} }
sources = invoker.sources sources = invoker.sources
......
...@@ -44,9 +44,11 @@ def ConvertFidlLibrary(json): ...@@ -44,9 +44,11 @@ def ConvertFidlLibrary(json):
name_tokenized = json['name'].split('.') name_tokenized = json['name'].split('.')
json['shortname'] = name_tokenized[-1] json['shortname'] = name_tokenized[-1]
json['namespace'] = '.'.join(name_tokenized[:-1]) json['namespace'] = '.'.join(name_tokenized[:-1])
json['namespace_path'] = json['namespace'].replace('.', '/')
return """fuchsia_sdk_fidl_pkg("{shortname}") {{ return """fuchsia_sdk_fidl_pkg("{shortname}") {{
namespace = "{namespace}" namespace = "{namespace}"
namespace_path = "{namespace_path}"
public_deps = {deps} public_deps = {deps}
sources = {sources} sources = {sources}
}}""".format(**json) }}""".format(**json)
......
...@@ -211,6 +211,7 @@ test("webrunner_unittests") { ...@@ -211,6 +211,7 @@ test("webrunner_unittests") {
fidl_library("fidl") { fidl_library("fidl") {
library_name = "web" library_name = "web"
namespace = "chromium" namespace = "chromium"
namespace_path = "chromium"
sources = [ sources = [
"fidl/context.fidl", "fidl/context.fidl",
......
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