Skip to content

Commit

Permalink
gn: add link_deps support
Browse files Browse the repository at this point in the history
To simplify CL https://r.android.com/3286638, I extracted GN template
change for link_deps from the CL to this CL.

Meaning of deps and link_deps will be updated like
https://crrev.com/c/5897794/11/third_party/protobuf/proto_library.gni

Bug: 366137880
Change-Id: I3195a500ab0bb3953a72782e2585a144a3063588
  • Loading branch information
atetubou committed Oct 7, 2024
1 parent 993ddf5 commit 6552adc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
28 changes: 21 additions & 7 deletions gn/proto_library.gni
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ template("protozero_library") {
deps = []
}

link_deps = []

# omit_protozero_dep is intended to be used when protozero_library
# is used in Chrome (for generation of code for proto extensions)
# to avoid ODR violations in case of component builds. The embedder
Expand All @@ -93,7 +95,11 @@ template("protozero_library") {
#
# TODO(b/173041866): use fine-grained components instead when available
if (!(defined(invoker.omit_protozero_dep) && invoker.omit_protozero_dep)) {
deps += [ perfetto_root_path + "src/protozero" ]
link_deps += [ perfetto_root_path + "src/protozero" ]
}

if (defined(invoker.link_deps)) {
link_deps += invoker.link_deps
}

forward_variables_from(invoker,
Expand Down Expand Up @@ -132,11 +138,16 @@ template("protozero_cpp_library") {
component_build_force_source_set = true
}

deps = [
link_deps = [
"$perfetto_root_path/gn:default_deps",
"$perfetto_root_path/include/perfetto/base",
"$perfetto_root_path/src/protozero",
]
if (defined(invoker.link_deps)) {
link_deps += invoker.link_deps
}

deps = []

if (defined(invoker.deps)) {
deps += invoker.deps
Expand Down Expand Up @@ -168,11 +179,12 @@ template("ipc_library") {
generator_plugin_label =
"$perfetto_root_path/src/ipc/protoc_plugin:ipc_plugin"
generator_plugin_suffix = ".ipc"
deps = [ "$perfetto_root_path/gn:default_deps" ]
deps = []
link_deps = [ "$perfetto_root_path/gn:default_deps" ]
if (perfetto_component_type == "static_library") {
deps += [ "$perfetto_root_path/src/ipc:perfetto_ipc" ]
link_deps += [ "$perfetto_root_path/src/ipc:perfetto_ipc" ]
} else {
deps += [ "$perfetto_root_path/src/ipc:common" ]
link_deps += [ "$perfetto_root_path/src/ipc:common" ]
}
if (is_win) {
# TODO(primiano): investigate this. In Windows standalone builds, some
Expand All @@ -183,9 +195,9 @@ template("ipc_library") {
# client-side IPC library. Perhaps we just should do this unconditionally
# on all platforms?
if (perfetto_component_type == "static_library") {
deps += [ "$perfetto_root_path/src/ipc:perfetto_ipc" ]
link_deps += [ "$perfetto_root_path/src/ipc:perfetto_ipc" ]
} else {
deps += [ "$perfetto_root_path/src/ipc:client" ]
link_deps += [ "$perfetto_root_path/src/ipc:client" ]
}
}

Expand All @@ -197,6 +209,7 @@ template("ipc_library") {
"defines",
"extra_configs",
"include_dirs",
"link_deps",
"proto_in_dir",
"proto_out_dir",
"generator_plugin_options",
Expand Down Expand Up @@ -274,6 +287,7 @@ template("perfetto_proto_library") {
"visibility",
"testonly",
"exclude_imports",
"link_deps",
]
expansion_token = "@TYPE@"

Expand Down
3 changes: 3 additions & 0 deletions gn/standalone/proto_library.gni
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ template("proto_library") {
if (defined(invoker.deps)) {
deps += invoker.deps
}
if (defined(invoker.link_deps)) {
deps += invoker.link_deps
}
} # source_set(source_set_name)
}
} # template

0 comments on commit 6552adc

Please sign in to comment.