Skip to content

Commit

Permalink
[fuchsia] Use GN rules provided by the Fuchsia SDK.
Browse files Browse the repository at this point in the history
- Use the SDK-provided config.gni in //build/config/fuchsia/config.gni.
- Remove the fuchsia_sdk_pkg.gni and gen_fidl_response_file.py.
- Use the SDK-provided runtime_library_group to get runtime libraries.
- Temporarily have //build/config/fuchsia/fidl_lbrary.gni redirect to
  the SDK-provided version.
- Temporarily update gen_build_defs.py to generate "redirect" rules,
  from the old Chromium targets to the SDK-provided ones.

Follow-up CLs will migrate away from gen_build_defs.py to direct
dependencies on the SDK-provided libraries, etc.

Bug: 1050703
Change-Id: Ib970aa99fe1a2808d30a536dd0d370db6ab8c4d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2057307
Auto-Submit: Wez <wez@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#741942}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 3f773d0095872c44b5b975a66cba9527b9aac2e0
  • Loading branch information
Wez authored and Commit Bot committed Feb 17, 2020
1 parent d781f64 commit 7cf5a22
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 221 deletions.
3 changes: 2 additions & 1 deletion config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ group("common_deps") {
}

if (is_fuchsia) {
public_deps += [ "//third_party/fuchsia-sdk:runtime_library" ]
public_deps +=
[ "//third_party/fuchsia-sdk/sdk/build/config:runtime_library_group" ]
}
}

Expand Down
20 changes: 2 additions & 18 deletions config/fuchsia/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(current_os == "fuchsia")
assert(is_fuchsia)

declare_args() {
# Paths to Fuchsia SDKs.
fuchsia_sdk = "//third_party/fuchsia-sdk/sdk"

# TODO(steveroe): Make linux-x64 and linux-arm64 sdk paths match
# when the linux-arm64 sdk is retrieved from GCS.
fuchsia_arm64_sdk = "//third_party/fuchsia-sdk-arm64"
}

# Compute the arch-specific path to packages' dynamic library dependencies.
if (current_cpu == "arm64") {
dist_libroot = fuchsia_sdk + "/arch/arm64/dist"
} else if (current_cpu == "x64") {
dist_libroot = fuchsia_sdk + "/arch/x64/dist"
} else {
assert(false, "No libraries available for architecture: $current_cpu")
}
import("//third_party/fuchsia-sdk/sdk/build/config/config.gni")

# Compute the emulator paths.
aemu_root = "//third_party/aemu-${host_os}-${host_cpu}"
Expand Down
203 changes: 1 addition & 202 deletions config/fuchsia/fidl_library.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2,207 +2,6 @@
# 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 that should be prepended to
# |library_name|.
# deps - (optional) List of other fidl_library() targets that this
# FIDL library depends on.
# languages - Generate bindings for the given languages, defaults to
# [ "cpp" ]. Only "cpp" is currently supported.
#
# $namespace.$library_name must match the the library name specified in the FIDL
# files.

template("fidl_library") {
forward_variables_from(invoker, [ "languages" ])

_library_name = target_name
if (defined(invoker.library_name)) {
_library_name = invoker.library_name
}

if (defined(invoker.namespace)) {
_library_name = "${invoker.namespace}.${_library_name}"
}

_library_path = string_replace(_library_name, ".", "/")

if (!defined(invoker.languages)) {
languages = [ "cpp" ]
}

assert(languages == [ "cpp" ])
_define_cpp_action = true

_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.c"

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.
"${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",
]
}

if (_define_cpp_action) {
action("${target_name}_cpp_gen") {
visibility = [ ":${invoker.target_name}" ]
forward_variables_from(invoker, [ "testonly" ])

deps = [ ":${invoker.target_name}_compile" ]

inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
"${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, root_build_dir),
"-include-base",
rebase_path(_output_gen_dir, root_build_dir),
"-output-base",
rebase_path("${_output_base}", root_build_dir),
]
}
}

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" ]

foreach(language, languages) {
deps += [ ":${invoker.target_name}_${language}_gen" ]
}

if (!defined(public_deps)) {
public_deps = []
}
public_deps += [ "//third_party/fuchsia-sdk/sdk:fidl" ]
public_deps += [ "//third_party/fuchsia-sdk/sdk:fidl_cpp" ]

public_configs = [ ":${invoker.target_name}_config" ]
}
}
import("//third_party/fuchsia-sdk/sdk/build/fidl_library.gni")

0 comments on commit 7cf5a22

Please sign in to comment.