Skip to content

Commit 1dc5842

Browse files
Fix cmake installation location of java and go features (#19773)
* Fix cmake installation location of java and go features Fixes #19735, will be backported to 29.x PiperOrigin-RevId: 708420839 * Regenerate stale files
1 parent 8e7e6b0 commit 1dc5842

File tree

5 files changed

+50
-8
lines changed

5 files changed

+50
-8
lines changed

cmake/install.cmake

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ set(protobuf_HEADERS
8989
${descriptor_proto_proto_srcs}
9090
${plugin_proto_proto_srcs}
9191
${java_features_proto_proto_srcs}
92+
${go_features_proto_proto_srcs}
9293
)
9394
if (protobuf_BUILD_LIBUPB)
9495
list(APPEND protobuf_HEADERS ${libupb_hdrs})
@@ -101,14 +102,22 @@ if (protobuf_BUILD_LIBUPB)
101102
COMPONENT protobuf-headers
102103
)
103104
endif ()
105+
set(protobuf_STRIP_PREFIXES
106+
"/src"
107+
"/java/core/src/main/resources"
108+
"/go"
109+
"/"
110+
)
104111
foreach(_header ${protobuf_HEADERS})
105-
string(FIND ${_header} "${protobuf_SOURCE_DIR}/src" _find_src)
106-
string(FIND ${_header} "${protobuf_SOURCE_DIR}" _find_nosrc)
107-
if (_find_src GREATER -1)
108-
set(_from_dir "${protobuf_SOURCE_DIR}/src")
109-
elseif (_find_nosrc GREATER -1)
110-
set(_from_dir "${protobuf_SOURCE_DIR}")
111-
endif()
112+
foreach(_strip_prefix ${protobuf_STRIP_PREFIXES})
113+
string(FIND ${_header} "${protobuf_SOURCE_DIR}${_strip_prefix}" _find_src)
114+
if(_find_src GREATER -1)
115+
set(_from_dir "${protobuf_SOURCE_DIR}${_strip_prefix}")
116+
break()
117+
endif()
118+
endforeach()
119+
message(${_from_dir} "-" ${_header})
120+
112121
# Escape _from_dir for regex special characters in the directory name.
113122
string(REGEX REPLACE "([$^.[|*+?()]|])" "\\\\\\1" _from_dir_regexp "${_from_dir}")
114123
# On some platforms `_form_dir` ends up being just "protobuf", which can

go/BUILD.bazel

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
load("//bazel:proto_library.bzl", "proto_library")
2+
13
filegroup(
24
name = "go_features_proto_srcs",
3-
srcs = ["go_features.proto"],
5+
srcs = ["google/protobuf/go_features.proto"],
46
visibility = ["//:__subpackages__"],
57
)
8+
9+
proto_library(
10+
name = "go_features_proto",
11+
srcs = ["google/protobuf/go_features.proto"],
12+
strip_import_prefix = "/go",
13+
visibility = [
14+
"//pkg:__pkg__",
15+
],
16+
deps = ["//:descriptor_proto"],
17+
)

pkg/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ gen_file_lists(
121121
"//src/google/protobuf:descriptor_proto": "descriptor_proto",
122122
"//src/google/protobuf/compiler:plugin_proto": "plugin_proto",
123123
"//java/core:java_features_proto": "java_features_proto,src/google/protobuf/compiler/java/",
124+
"//go:go_features_proto": "go_features_proto,go/",
124125

125126
# Test libraries:
126127
":common_test": "common_test",

src/file_lists.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,26 @@ set(java_features_proto_files
928928
${protobuf_SOURCE_DIR}/java/core/java_features_proto-descriptor-set.proto.bin
929929
)
930930

931+
# @//go:go_features_proto
932+
set(go_features_proto_proto_srcs
933+
${protobuf_SOURCE_DIR}/go/google/protobuf/go_features.proto
934+
)
935+
936+
# @//go:go_features_proto
937+
set(go_features_proto_srcs
938+
${protobuf_SOURCE_DIR}/go/go_features.proto.pb.cc
939+
)
940+
941+
# @//go:go_features_proto
942+
set(go_features_proto_hdrs
943+
${protobuf_SOURCE_DIR}/go/go_features.proto.pb.h
944+
)
945+
946+
# @//go:go_features_proto
947+
set(go_features_proto_files
948+
${protobuf_SOURCE_DIR}/go/go_features_proto-descriptor-set.proto.bin
949+
)
950+
931951
# @//pkg:common_test
932952
set(common_test_srcs
933953
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface_tester.cc

0 commit comments

Comments
 (0)