Skip to content

Commit

Permalink
Fix cmake installation location of java and go features
Browse files Browse the repository at this point in the history
Fixes #19735, will be backported to 29.x

PiperOrigin-RevId: 708166250
  • Loading branch information
mkruskal-google authored and copybara-github committed Dec 20, 2024
1 parent 3b2bb51 commit 49336ce
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
23 changes: 16 additions & 7 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ set(protobuf_HEADERS
${descriptor_proto_proto_srcs}
${plugin_proto_proto_srcs}
${java_features_proto_proto_srcs}
${go_features_proto_proto_srcs}
)
if (protobuf_BUILD_LIBUPB)
list(APPEND protobuf_HEADERS ${libupb_hdrs})
Expand All @@ -105,14 +106,22 @@ if (protobuf_BUILD_LIBUPB)
COMPONENT protobuf-headers
)
endif ()
set(protobuf_STRIP_PREFIXES
"/src"
"/java/core/src/main/resources"
"/go"
"/"
)
foreach(_header ${protobuf_HEADERS})
string(FIND ${_header} "${protobuf_SOURCE_DIR}/src" _find_src)
string(FIND ${_header} "${protobuf_SOURCE_DIR}" _find_nosrc)
if (_find_src GREATER -1)
set(_from_dir "${protobuf_SOURCE_DIR}/src")
elseif (_find_nosrc GREATER -1)
set(_from_dir "${protobuf_SOURCE_DIR}")
endif()
foreach(_strip_prefix ${protobuf_STRIP_PREFIXES})
string(FIND ${_header} "${protobuf_SOURCE_DIR}${_strip_prefix}" _find_src)
if(_find_src GREATER -1)
set(_from_dir "${protobuf_SOURCE_DIR}${_strip_prefix}")
break()
endif()
endforeach()
message(${_from_dir} "-" ${_header})

# Escape _from_dir for regex special characters in the directory name.
string(REGEX REPLACE "([$^.[|*+?()]|])" "\\\\\\1" _from_dir_regexp "${_from_dir}")
# On some platforms `_form_dir` ends up being just "protobuf", which can
Expand Down
14 changes: 13 additions & 1 deletion go/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
load("//bazel:proto_library.bzl", "proto_library")

filegroup(
name = "go_features_proto_srcs",
srcs = ["go_features.proto"],
srcs = ["google/protobuf/go_features.proto"],
visibility = ["//:__subpackages__"],
)

proto_library(
name = "go_features_proto",
srcs = ["google/protobuf/go_features.proto"],
strip_import_prefix = "/go",
visibility = [
"//pkg:__pkg__",
],
deps = ["//:descriptor_proto"],
)
File renamed without changes.
1 change: 1 addition & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ gen_file_lists(
"//src/google/protobuf:descriptor_proto": "descriptor_proto",
"//src/google/protobuf/compiler:plugin_proto": "plugin_proto",
"//java/core:java_features_proto": "java_features_proto,src/google/protobuf/compiler/java/",
"//go:go_features_proto": "go_features_proto,go/",

# Test libraries:
":common_test": "common_test",
Expand Down

0 comments on commit 49336ce

Please sign in to comment.