Clean-up pkgconfig (#31660)

* Clean-up pkgconfig

* Removed run_distrib_test_cmake_module_install_pkgconfig.sh

* Proper re2

* Clean up pkgconfig.sh test script
pull/31746/head
Esun Kim 2 years ago committed by GitHub
parent e9b287997a
commit 5fb4c2364d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      CMakeLists.txt
  2. 1
      cmake/pkg-config-template.pc.in
  3. 4
      examples/cpp/compression/Makefile
  4. 4
      examples/cpp/helloworld/Makefile
  5. 4
      examples/cpp/load_balancing/Makefile
  6. 4
      examples/cpp/metadata/Makefile
  7. 4
      examples/cpp/route_guide/Makefile
  8. 26
      templates/CMakeLists.txt.template
  9. 48
      test/distrib/cpp/run_distrib_test_cmake_module_install_pkgconfig.sh
  10. 21
      test/distrib/cpp/run_distrib_test_cmake_pkgconfig.sh
  11. 5
      tools/run_tests/artifacts/distribtest_targets.py

26
CMakeLists.txt generated

@ -24691,12 +24691,13 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/etc/roots.pem
DESTINATION ${gRPC_INSTALL_SHAREDIR})
# Function to generate pkg-config files.
function(generate_pkgconfig name description version requires
function(generate_pkgconfig name description version requires requires_private
libs libs_private output_filename)
set(PC_NAME "${name}")
set(PC_DESCRIPTION "${description}")
set(PC_VERSION "${version}")
set(PC_REQUIRES "${requires}")
set(PC_REQUIRES_PRIVATE "${requires_private}")
set(PC_LIB "${libs}")
set(PC_LIBS_PRIVATE "${libs_private}")
set(output_filepath "${grpc_BINARY_DIR}/libs/opt/pkgconfig/${output_filename}")
@ -24714,6 +24715,7 @@ generate_pkgconfig(
"gRPC platform support library"
"${gRPC_CORE_VERSION}"
"absl_base absl_cord absl_core_headers absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant"
""
"-lgpr"
""
"gpr.pc")
@ -24723,9 +24725,10 @@ generate_pkgconfig(
"gRPC"
"high performance general RPC framework"
"${gRPC_CORE_VERSION}"
"gpr openssl absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant"
"-lgrpc -laddress_sorting -lre2 -lupb -lcares -lz"
""
"gpr absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant"
"openssl re2 libcares zlib"
"-lgrpc"
"-laddress_sorting -lupb"
"grpc.pc")
# grpc_unsecure .pc file
@ -24734,8 +24737,9 @@ generate_pkgconfig(
"high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}"
"gpr absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant"
"re2 libcares zlib"
"-lgrpc_unsecure"
""
"-laddress_sorting -lupb"
"grpc_unsecure.pc")
# grpc++ .pc file
@ -24744,6 +24748,7 @@ generate_pkgconfig(
"C++ wrapper for gRPC"
"${gRPC_CPP_VERSION}"
"grpc absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant"
""
"-lgrpc++"
""
"grpc++.pc")
@ -24754,16 +24759,7 @@ generate_pkgconfig(
"C++ wrapper for gRPC without SSL"
"${gRPC_CPP_VERSION}"
"grpc_unsecure absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant"
""
"-lgrpc++_unsecure"
""
"grpc++_unsecure.pc")
# grpc_authorization_provider.pc file
generate_pkgconfig(
"grpc_authorization_provider"
"A library that adds authorization"
"${gRPC_CPP_VERSION}"
"grpc_authorization_provider absl_any_invocable absl_base absl_cleanup absl_cord absl_core_headers absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant"
"-lgrpc_authorization_provider -lre2"
""
"grpc_authorization_provider.pc")

@ -8,5 +8,6 @@ Description: @PC_DESCRIPTION@
Version: @PC_VERSION@
Cflags: -I${includedir}
Requires: @PC_REQUIRES@
Requires.private: @PC_REQUIRES_PRIVATE@
Libs: -L${libdir} @PC_LIB@
Libs.private: @PC_LIBS_PRIVATE@

@ -20,11 +20,11 @@ CXX = g++
CPPFLAGS += `pkg-config --cflags protobuf grpc`
CXXFLAGS += -std=c++14
ifeq ($(SYSTEM),Darwin)
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
LDFLAGS += -L/usr/local/lib `pkg-config --libs --static protobuf grpc++ grpc`\
-lgrpc++_reflection\
-ldl
else
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
LDFLAGS += -L/usr/local/lib `pkg-config --libs --static protobuf grpc++ grpc`\
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-ldl
endif

@ -20,12 +20,12 @@ CXX = g++
CPPFLAGS += `pkg-config --cflags protobuf grpc`
CXXFLAGS += -std=c++14
ifeq ($(SYSTEM),Darwin)
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`\
LDFLAGS += -L/usr/local/lib `pkg-config --libs --static protobuf grpc++`\
-pthread\
-lgrpc++_reflection\
-ldl
else
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`\
LDFLAGS += -L/usr/local/lib `pkg-config --libs --static protobuf grpc++`\
-pthread\
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-ldl

@ -20,11 +20,11 @@ CXX = g++
CPPFLAGS += `pkg-config --cflags protobuf grpc`
CXXFLAGS += -std=c++14
ifeq ($(SYSTEM),Darwin)
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
LDFLAGS += -L/usr/local/lib `pkg-config --libs --static protobuf grpc++ grpc`\
-lgrpc++_reflection\
-ldl
else
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
LDFLAGS += -L/usr/local/lib `pkg-config --libs --static protobuf grpc++ grpc`\
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-ldl
endif

@ -19,11 +19,11 @@ CXX = g++
CPPFLAGS += `pkg-config --cflags protobuf grpc`
CXXFLAGS += -std=c++14
ifeq ($(SYSTEM),Darwin)
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
LDFLAGS += -L/usr/local/lib `pkg-config --libs --static protobuf grpc++ grpc`\
-lgrpc++_reflection\
-ldl
else
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
LDFLAGS += -L/usr/local/lib `pkg-config --libs --static protobuf grpc++ grpc`\
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-ldl
endif

@ -20,12 +20,12 @@ CXX = g++
CPPFLAGS += `pkg-config --cflags protobuf grpc`
CXXFLAGS += -std=c++14
ifeq ($(SYSTEM),Darwin)
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`\
LDFLAGS += -L/usr/local/lib `pkg-config --libs --static protobuf grpc++`\
-pthread\
-lgrpc++_reflection\
-ldl
else
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`\
LDFLAGS += -L/usr/local/lib `pkg-config --libs --static protobuf grpc++`\
-pthread\
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-ldl

@ -847,12 +847,13 @@
DESTINATION <%text>${gRPC_INSTALL_SHAREDIR}</%text>)
# Function to generate pkg-config files.
function(generate_pkgconfig name description version requires
function(generate_pkgconfig name description version requires requires_private
libs libs_private output_filename)
set(PC_NAME "<%text>${name}</%text>")
set(PC_DESCRIPTION "<%text>${description}</%text>")
set(PC_VERSION "<%text>${version}</%text>")
set(PC_REQUIRES "<%text>${requires}</%text>")
set(PC_REQUIRES_PRIVATE "<%text>${requires_private}</%text>")
set(PC_LIB "<%text>${libs}</%text>")
set(PC_LIBS_PRIVATE "<%text>${libs_private}</%text>")
set(output_filepath "<%text>${grpc_BINARY_DIR}/libs/opt/pkgconfig/${output_filename}</%text>")
@ -870,6 +871,7 @@
"gRPC platform support library"
"<%text>${gRPC_CORE_VERSION}</%text>"
"${" ".join(list_abseil_pkg_targets("gpr"))}"
""
"${" ".join(("-l" + l) for l in ["gpr"])}"
""
"gpr.pc")
@ -879,9 +881,10 @@
"gRPC"
"high performance general RPC framework"
"<%text>${gRPC_CORE_VERSION}</%text>"
"${" ".join(["gpr", "openssl"] + list_abseil_pkg_targets("grpc"))}"
"${" ".join(("-l" + l) for l in ["grpc", "address_sorting", "re2", "upb", "cares", "z"])}"
""
"${" ".join(["gpr"] + list_abseil_pkg_targets("grpc"))}"
"${" ".join(["openssl", "re2", "libcares", "zlib"])}"
"${" ".join(("-l" + l) for l in ["grpc",])}"
"${" ".join(("-l" + l) for l in ["address_sorting", "upb"])}"
"grpc.pc")
# grpc_unsecure .pc file
@ -890,8 +893,9 @@
"high performance general RPC framework without SSL"
"<%text>${gRPC_CORE_VERSION}</%text>"
"${" ".join(["gpr"] + list_abseil_pkg_targets("grpc_unsecure"))}"
"${" ".join(["re2", "libcares", "zlib"])}"
"${" ".join(("-l" + l) for l in ["grpc_unsecure"])}"
""
"${" ".join(("-l" + l) for l in ["address_sorting", "upb"])}"
"grpc_unsecure.pc")
# grpc++ .pc file
@ -900,6 +904,7 @@
"C++ wrapper for gRPC"
"<%text>${gRPC_CPP_VERSION}</%text>"
"${" ".join(["grpc"] + list_abseil_pkg_targets("grpc++"))}"
""
"${" ".join(("-l" + l) for l in ["grpc++"])}"
""
"grpc++.pc")
@ -910,16 +915,7 @@
"C++ wrapper for gRPC without SSL"
"<%text>${gRPC_CPP_VERSION}</%text>"
"${" ".join(["grpc_unsecure"] + list_abseil_pkg_targets("grpc++_unsecure"))}"
""
"${" ".join(("-l" + l) for l in ["grpc++_unsecure"])}"
""
"grpc++_unsecure.pc")
# grpc_authorization_provider.pc file
generate_pkgconfig(
"grpc_authorization_provider"
"A library that adds authorization"
"<%text>${gRPC_CPP_VERSION}</%text>"
"${" ".join(["grpc_authorization_provider"] + list_abseil_pkg_targets("grpc_authorization_provider"))}"
"${" ".join(("-l" + l) for l in ["grpc_authorization_provider", "re2"])}"
""
"grpc_authorization_provider.pc")

@ -1,48 +0,0 @@
#!/bin/bash
# Copyright 2017 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
cd "$(dirname "$0")/../../.."
# Install openssl (to use instead of boringssl)
apt-get update && apt-get install -y libssl-dev
# Install CMake 3.16
apt-get update && apt-get install -y wget
wget -q -O cmake-linux.sh https://github.com/Kitware/CMake/releases/download/v3.16.1/cmake-3.16.1-Linux-x86_64.sh
sh cmake-linux.sh -- --skip-license --prefix=/usr
rm cmake-linux.sh
# Use externally provided env to determine build parallelism, otherwise use default.
GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS=${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS:-4}
# Install gRPC and its dependencies
mkdir -p "cmake/build"
pushd "cmake/build"
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DgRPC_SSL_PROVIDER=package \
../..
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
popd
# Build helloworld example using make & pkg-config
cd examples/cpp/helloworld
export PKG_CONFIG_PATH=/usr/local/grpc/lib/pkgconfig
export PATH=$PATH:/usr/local/grpc/bin
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}"

@ -44,6 +44,13 @@ cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ..
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
popd
# Install re2 pkg-config using `make install`
# because its `cmake install` doesn't install it
# https://github.com/google/re2/issues/399
pushd "third_party/re2"
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
popd
# Install re2
mkdir -p "third_party/re2/cmake/build"
pushd "third_party/re2/cmake/build"
@ -81,16 +88,22 @@ cmake \
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}" install
popd
# Build helloworld example using Makefile and pkg-config
pushd examples/cpp/helloworld
# Set pkgconfig envs
export PKG_CONFIG_PATH=/usr/local/grpc/lib/pkgconfig
export PATH=$PATH:/usr/local/grpc/bin
# Show pkg-config configuration
pkg-config --cflags grpc
pkg-config --libs --static grpc
pkg-config --cflags grpc++
pkg-config --libs --static grpc++
# Build helloworld example using Makefile and pkg-config
pushd examples/cpp/helloworld
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}"
popd
# Build route_guide example using Makefile and pkg-config
pushd examples/cpp/route_guide
export PKG_CONFIG_PATH=/usr/local/grpc/lib/pkgconfig
export PATH=$PATH:/usr/local/grpc/bin
make "-j${GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS}"
popd

@ -369,11 +369,6 @@ def targets():
'stretch',
'cmake_module_install',
presubmit=True),
CppDistribTest('linux',
'x64',
'stretch',
'cmake_module_install_pkgconfig',
presubmit=True),
CppDistribTest('linux',
'x64',
'stretch',

Loading…
Cancel
Save