mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-11-24 14:26:09 +03:00
214 lines
6.1 KiB
Plaintext
214 lines
6.1 KiB
Plaintext
|
# Copyright 2018 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("//build/config/fuchsia/config.gni")
|
||
|
|
||
|
assert(is_fuchsia)
|
||
|
|
||
|
# Template for FIDL libraries. Following parameters can be passed when
|
||
|
# instantiating this template:
|
||
|
# sources - List of .fidl files.
|
||
|
# library_name - (optional) Name of the library. target_name is used if name
|
||
|
# is not specified explicitly.
|
||
|
# 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
|
||
|
# FIDL library depends on.
|
||
|
#
|
||
|
# $namespace.$library_name must match the the library name specified in the FIDL
|
||
|
# files.
|
||
|
|
||
|
template("fidl_library") {
|
||
|
forward_variables_from(invoker,
|
||
|
[
|
||
|
"namespace",
|
||
|
"namespace_path",
|
||
|
])
|
||
|
|
||
|
_library_basename = target_name
|
||
|
if (defined(invoker.library_name)) {
|
||
|
_library_basename = invoker.library_name
|
||
|
}
|
||
|
|
||
|
if (defined(namespace)) {
|
||
|
assert(defined(namespace_path),
|
||
|
"FIDL libraries with namespace must specify namespace_path")
|
||
|
_library_name = "${namespace}.${_library_basename}"
|
||
|
_library_path = "${namespace_path}/${_library_basename}"
|
||
|
} else {
|
||
|
_library_name = _library_basename
|
||
|
_library_path = _library_basename
|
||
|
}
|
||
|
|
||
|
_response_file = "$target_gen_dir/$target_name.rsp"
|
||
|
_json_representation = "$target_gen_dir/${_library_name}.fidl.json"
|
||
|
_output_gen_dir = "$target_gen_dir/fidl"
|
||
|
_output_base = "$_output_gen_dir/${_library_path}/cpp/fidl"
|
||
|
_tables_file = "$_output_gen_dir/${_library_name}.fidl-tables.cc"
|
||
|
|
||
|
action("${target_name}_response_file") {
|
||
|
script = "//third_party/fuchsia-sdk/gen_fidl_response_file.py"
|
||
|
|
||
|
forward_variables_from(invoker,
|
||
|
[
|
||
|
"deps",
|
||
|
"public_deps",
|
||
|
"sources",
|
||
|
"testonly",
|
||
|
])
|
||
|
|
||
|
_libraries_file = "$target_gen_dir/${invoker.target_name}.fidl_libraries"
|
||
|
|
||
|
outputs = [
|
||
|
_response_file,
|
||
|
_libraries_file,
|
||
|
]
|
||
|
|
||
|
args = [
|
||
|
"--out-response-file",
|
||
|
rebase_path(_response_file, root_build_dir),
|
||
|
"--out-libraries",
|
||
|
rebase_path(_libraries_file, root_build_dir),
|
||
|
"--tables",
|
||
|
rebase_path(_tables_file, root_build_dir),
|
||
|
"--json",
|
||
|
rebase_path(_json_representation, root_build_dir),
|
||
|
"--name",
|
||
|
_library_name,
|
||
|
"--sources",
|
||
|
] + rebase_path(sources, root_build_dir)
|
||
|
|
||
|
if (defined(invoker.deps) || defined(invoker.public_deps)) {
|
||
|
merged_deps = []
|
||
|
|
||
|
if (defined(invoker.deps)) {
|
||
|
merged_deps += invoker.deps
|
||
|
}
|
||
|
|
||
|
if (defined(invoker.public_deps)) {
|
||
|
merged_deps += invoker.public_deps
|
||
|
}
|
||
|
|
||
|
dep_libraries = []
|
||
|
deps = []
|
||
|
|
||
|
foreach(dep, merged_deps) {
|
||
|
gen_dir = get_label_info(dep, "target_gen_dir")
|
||
|
name = get_label_info(dep, "name")
|
||
|
dep_libraries += [ "$gen_dir/$name.fidl_libraries" ]
|
||
|
deps += [ "${dep}_response_file" ]
|
||
|
}
|
||
|
|
||
|
inputs = dep_libraries
|
||
|
|
||
|
args += [ "--dep-libraries" ] + rebase_path(dep_libraries, root_build_dir)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
action("${target_name}_compile") {
|
||
|
forward_variables_from(invoker, [ "testonly" ])
|
||
|
|
||
|
visibility = [ ":*" ]
|
||
|
|
||
|
deps = [
|
||
|
":${invoker.target_name}_response_file",
|
||
|
]
|
||
|
|
||
|
script = "//build/gn_run_binary.py"
|
||
|
|
||
|
inputs = [
|
||
|
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
|
||
|
rebase_path("$fuchsia_sdk/.hash"),
|
||
|
_response_file,
|
||
|
]
|
||
|
|
||
|
outputs = [
|
||
|
_json_representation,
|
||
|
_tables_file,
|
||
|
]
|
||
|
|
||
|
rebased_response_file = rebase_path(_response_file, root_build_dir)
|
||
|
args = [
|
||
|
rebase_path("//third_party/fuchsia-sdk/sdk/tools/fidlc", root_build_dir),
|
||
|
"@$rebased_response_file",
|
||
|
]
|
||
|
}
|
||
|
|
||
|
action("${target_name}_cpp_gen") {
|
||
|
visibility = [ ":${invoker.target_name}" ]
|
||
|
|
||
|
deps = [
|
||
|
":${invoker.target_name}_compile",
|
||
|
]
|
||
|
|
||
|
inputs = [
|
||
|
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
|
||
|
rebase_path("$fuchsia_sdk/.hash"),
|
||
|
_json_representation,
|
||
|
]
|
||
|
|
||
|
outputs = [
|
||
|
"${_output_base}.h",
|
||
|
"${_output_base}.cc",
|
||
|
]
|
||
|
|
||
|
script = "//build/gn_run_binary.py"
|
||
|
args = [
|
||
|
rebase_path("//third_party/fuchsia-sdk/sdk/tools/fidlgen",
|
||
|
root_build_dir),
|
||
|
"-generators",
|
||
|
"cpp",
|
||
|
"-json",
|
||
|
rebase_path(_json_representation),
|
||
|
"-include-base",
|
||
|
rebase_path(_output_gen_dir),
|
||
|
"-output-base",
|
||
|
rebase_path("${_output_base}"),
|
||
|
]
|
||
|
}
|
||
|
|
||
|
config("${target_name}_config") {
|
||
|
visibility = [ ":${invoker.target_name}" ]
|
||
|
include_dirs = [ _output_gen_dir ]
|
||
|
}
|
||
|
|
||
|
source_set("${target_name}") {
|
||
|
forward_variables_from(invoker,
|
||
|
[
|
||
|
"deps",
|
||
|
"public_deps",
|
||
|
"testonly",
|
||
|
"visibility",
|
||
|
])
|
||
|
|
||
|
sources = [
|
||
|
"${_output_base}.cc",
|
||
|
"${_output_base}.h",
|
||
|
_tables_file,
|
||
|
]
|
||
|
|
||
|
if (!defined(deps)) {
|
||
|
deps = []
|
||
|
}
|
||
|
deps += [
|
||
|
":${invoker.target_name}_compile",
|
||
|
":${invoker.target_name}_cpp_gen",
|
||
|
]
|
||
|
|
||
|
if (!defined(public_deps)) {
|
||
|
public_deps = []
|
||
|
}
|
||
|
public_deps += [ "//third_party/fuchsia-sdk:fidl" ]
|
||
|
public_deps += [ "//third_party/fuchsia-sdk:fidl_cpp" ]
|
||
|
|
||
|
public_configs = [ ":${invoker.target_name}_config" ]
|
||
|
}
|
||
|
}
|