Skip to content

Commit

Permalink
Merge pull request conda-forge#24970 from coryan/feat-shard-google-cl…
Browse files Browse the repository at this point in the history
…oud-cpp-bigquery

feat: add `google-cloud-cpp-bigquery` feedstock
  • Loading branch information
h-vetinari authored Feb 10, 2024
2 parents 0120af9 + 00bdd49 commit 210f7f9
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 0 deletions.
23 changes: 23 additions & 0 deletions recipes/google-cloud-cpp-bigquery/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@echo on
setlocal EnableDelayedExpansion

:: CMake does not like paths with \ characters
set LIBRARY_PREFIX=%LIBRARY_PREFIX:\=/%

cmake -G "Ninja" ^
-S . -B build ^
-DGOOGLE_CLOUD_CPP_ENABLE=bigquery ^
-DGOOGLE_CLOUD_CPP_USE_INSTALLED_COMMON=ON ^
-DBUILD_TESTING=OFF ^
-DBUILD_SHARED_LIBS=OFF ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_CXX_STANDARD=17 ^
-DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^
-DCMAKE_MODULE_PATH="%LIBRARY_PREFIX%/lib/cmake" ^
-DCMAKE_INSTALL_LIBDIR=lib ^
-DGOOGLE_CLOUD_CPP_ENABLE_EXAMPLES=OFF ^
-DGOOGLE_CLOUD_CPP_ENABLE_WERROR=OFF
if %ERRORLEVEL% neq 0 exit 1

cmake --build build --config Release
if %ERRORLEVEL% neq 0 exit 1
26 changes: 26 additions & 0 deletions recipes/google-cloud-cpp-bigquery/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -euo pipefail

export OPENSSL_ROOT_DIR=$PREFIX

if [[ "${target_platform}" == osx-* ]]; then
# See https://conda-forge.org/docs/maintainer/knowledge_base.html#newer-c-features-with-old-sdk
CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY"
fi

cmake ${CMAKE_ARGS} \
-GNinja -S . -B build \
-DGOOGLE_CLOUD_CPP_ENABLE=bigquery \
-DGOOGLE_CLOUD_CPP_USE_INSTALLED_COMMON=ON \
-DBUILD_TESTING=OFF \
-DBUILD_SHARED_LIBS=ON \
-DOPENSSL_ROOT_DIR=$PREFIX \
-DCMAKE_BUILD_TYPE=release \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_INSTALL_LIBDIR=lib \
-DProtobuf_PROTOC_EXECUTABLE=$BUILD_PREFIX/bin/protoc \
-DGOOGLE_CLOUD_CPP_GRPC_PLUGIN_EXECUTABLE=$BUILD_PREFIX/bin/grpc_cpp_plugin \
-DGOOGLE_CLOUD_CPP_ENABLE_WERROR=OFF
cmake --build build
4 changes: 4 additions & 0 deletions recipes/google-cloud-cpp-bigquery/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The default at [1] is 10.9 and abseil does not compile with that
# [1]: https://github.com/conda-forge/conda-forge-pinning-feedstock/blob/main/recipe/conda_build_config.yaml
MACOSX_DEPLOYMENT_TARGET:
- 10.13 # [osx and x86_64]
22 changes: 22 additions & 0 deletions recipes/google-cloud-cpp-bigquery/install-libgoogle-cloud.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@echo on
setlocal EnableDelayedExpansion

:: CMake does not like paths with \ characters
set LIBRARY_PREFIX="%LIBRARY_PREFIX:\=/%"
set BUILD_PREFIX="%BUILD_PREFIX:\=/%"
set SRC_DIR="%SRC_DIR:\=/%"

:: Once DLLs are working, we should install the non-devel packages using
:: cmake --install .b --component google_cloud_cpp_runtime
:: and the devel packages using
:: cmake --install .b --component google_cloud_cpp_development

if [%PKG_NAME%] == [libgoogle-cloud-bigquery-devel] (
cmake --install build
if %ERRORLEVEL% neq 0 exit 1
) else if [%PKG_NAME%] == [libgoogle-cloud-bigquery] (
@REM TODO: fix when DLL support comes along
) else (
@ECHO Unknown package name %PKG_NAME%
exit 1
)
16 changes: 16 additions & 0 deletions recipes/google-cloud-cpp-bigquery/install-libgoogle-cloud.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -euo pipefail

case "${PKG_NAME}" in
libgoogle-cloud-bigquery-devel)
cmake --install build --component google_cloud_cpp_development
;;
libgoogle-cloud-bigquery)
cmake --install build --component google_cloud_cpp_runtime
;;
*)
echo Unknown package name "${PKG_NAME}"
exit 1
;;
esac
114 changes: 114 additions & 0 deletions recipes/google-cloud-cpp-bigquery/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{% set version = "2.17.0" %}

package:
name: google-cloud-cpp-bigquery
version: {{ version }}

source:
url: https://github.com/googleapis/google-cloud-cpp/archive/v{{ version }}.tar.gz
sha256: 8cb87ec2947e691a7f8631877e78453bcfda51b3d3cd4940794a376741888d37
patches:
# This is an upstream fix to allow sharding google/cloud/oauth2
- patches/0001-Backport-12911-from-upstream.patch

build:
number: 0
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake
- ninja
- libgrpc
- libprotobuf
- zlib # Needed by gRPC
host:
- libgoogle-cloud-devel =={{ version }}
- libabseil
- libcurl
- libgrpc
- libprotobuf
- openssl
- nlohmann_json
- zlib # Needed by gRPC

outputs:
- name: libgoogle-cloud-bigquery
script: install-libgoogle-cloud.sh # [unix]
script: install-libgoogle-cloud.bat # [win]
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake
- ninja
host:
- libgoogle-cloud-devel =={{ version }}
- libabseil
- libprotobuf
- libgrpc
test:
commands:
# presence of shared library (unix)
- test -f $PREFIX/lib/libgoogle_cloud_cpp_bigquery.{{ version }}.dylib # [osx]
- test -f $PREFIX/lib/libgoogle_cloud_cpp_bigquery.so.{{ version }} # [linux]

# absence of static library (windows). It belongs only in devel package.
- if exist %LIBRARY_LIB%\google_cloud_cpp_bigquery.lib exit 1 # [win]

# absence of headers (they belong in devel package)
- test ! -f $PREFIX/include/google/cloud/bigquery/storage/v1/bigquery_read_client.h # [unix]
- if exist %LIBRARY_INC%\google\cloud\bigquery\storage\v1\bigquery_read_client.h exit 1 # [win]

# absence of metadata for CMake & pkgconfig (belongs in devel package)
- test ! -f $PREFIX/lib/pkgconfig/google_cloud_cpp_bigquery.pc # [unix]
- test ! -f $PREFIX/lib/cmake/google_cloud_cpp_common/google_cloud_cpp_bigquery-config.cmake # [unix]
- if exist %LIBRARY_LIB%\cmake\google_cloud_cpp_common\google_cloud_cpp_bigquery-config.cmake exit 1 # [win]

- name: libgoogle-cloud-bigquery-devel
script: install-libgoogle-cloud.sh # [unix]
script: install-libgoogle-cloud.bat # [win]
build:
run_exports:
# patch versions guaranteed to be ABI-compatible, see
# https://github.com/googleapis/google-cloud-cpp/blob/main/doc/adr/2023-05-03-patch-releases-are-ABI-compatible.md
- {{ pin_subpackage("libgoogle-cloud-bigquery", max_pin="x.x") }}
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake
- ninja
host:
- libgoogle-cloud-devel =={{ version }}
run:
- {{ pin_subpackage("libgoogle-cloud-bigquery", exact=True) }}
test:
commands:
# build an example
- ./run_test_feature.sh # [unix]
- ./run_test_feature.bat # [win]
requires:
- {{ compiler('cxx') }}
- cmake
- ninja
- libgoogle-cloud-devel =={{ version }}
files:
- run_test_feature.sh
- run_test_feature.bat
source_files:
- google/cloud/bigquery/quickstart/*.cc
- google/cloud/bigquery/quickstart/CMakeLists.txt

about:
home: https://github.com/googleapis/google-cloud-cpp
license: Apache-2.0
license_family: Apache
license_file: LICENSE
summary: Google Cloud Client Library for C++

extra:
feedstock-name: google-cloud-cpp-bigquery
recipe-maintainers:
- coryan
- conda-forge/google-cloud-cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
From 379266c74e0a3fce4e48b4788ad32508b02ec626 Mon Sep 17 00:00:00 2001
From: Carlos O'Ryan <[email protected]>
Date: Wed, 20 Dec 2023 16:57:10 +0000
Subject: [PATCH] Backport #12911 from upstream

---
cmake/GoogleCloudCppFeatures.cmake | 3 ---
1 file changed, 3 deletions(-)

diff --git a/cmake/GoogleCloudCppFeatures.cmake b/cmake/GoogleCloudCppFeatures.cmake
index a69cd85a..e86b9d03 100644
--- a/cmake/GoogleCloudCppFeatures.cmake
+++ b/cmake/GoogleCloudCppFeatures.cmake
@@ -361,9 +361,6 @@ macro (google_cloud_cpp_enable_cleanup)
OR (sql IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
OR (generator IN_LIST GOOGLE_CLOUD_CPP_ENABLE))
set(GOOGLE_CLOUD_CPP_ENABLE_REST ON)
- # Backwards compatibility. In the original release of `oauth2` we
- # automatically compiled the library if REST was enabled
- list(APPEND GOOGLE_CLOUD_CPP_ENABLE oauth2)
endif ()

list(REMOVE_DUPLICATES GOOGLE_CLOUD_CPP_ENABLE)
19 changes: 19 additions & 0 deletions recipes/google-cloud-cpp-bigquery/run_test_feature.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo on
setlocal EnableDelayedExpansion

:: CMake does not like paths with \ characters
set LIBRARY_PREFIX="%LIBRARY_PREFIX:\=/%"

set FEATURE=%PKG_NAME:libgoogle-cloud-=%
set FEATURE=%FEATURE:-devel=%

cmake -GNinja ^
-S "google/cloud/%FEATURE%/quickstart" -B .build ^
-DCMAKE_CXX_STANDARD=17 ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^
-DCMAKE_MODULE_PATH="%LIBRARY_PREFIX%/lib/cmake"
if %ERRORLEVEL% neq 0 exit 1

cmake --build .build --config Release
if %ERRORLEVEL% neq 0 exit 1
19 changes: 19 additions & 0 deletions recipes/google-cloud-cpp-bigquery/run_test_feature.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Stop on first error
set -euo pipefail

if [[ "${target_platform}" == osx-* ]]; then
# as in build.sh
CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY"
fi

feature=${PKG_NAME/#libgoogle-cloud-/}
feature=${feature/%-devel/}

cmake -GNinja \
-S "google/cloud/${feature}/quickstart" -B .build \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_PREFIX_PATH="$PREFIX" \
-DCMAKE_MODULE_PATH="$PREFIX/lib/cmake"
cmake --build .build

0 comments on commit 210f7f9

Please sign in to comment.