Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Shared builds on windows #108

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ cmake -G "Ninja" ^
-S . -B build ^
-DGOOGLE_CLOUD_CPP_ENABLE=__ga_libraries__ ^
-DBUILD_TESTING=OFF ^
-DBUILD_SHARED_LIBS=OFF ^
-DBUILD_SHARED_LIBS=ON ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_CXX_STANDARD=17 ^
-DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^
-DCMAKE_MODULE_PATH="%LIBRARY_PREFIX%/lib/cmake" ^
-DCMAKE_INSTALL_LIBDIR=lib ^
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON ^
-DGOOGLE_CLOUD_CPP_ENABLE_EXAMPLES=OFF ^
-DGOOGLE_CLOUD_CPP_ENABLE_WERROR=OFF
if %ERRORLEVEL% neq 0 exit 1
Expand Down
5 changes: 2 additions & 3 deletions recipe/build-libgoogle-cloud.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ set BUILD_PREFIX="%BUILD_PREFIX:\=/%"
set SRC_DIR="%SRC_DIR:\=/%"

if [%PKG_NAME%] == [libgoogle-cloud] (
@rem cmake --install build_cmake --component google_cloud_cpp_runtime
cmake --install build --component google_cloud_cpp_runtime
if %ERRORLEVEL% neq 0 exit 1
) else (
@rem cmake --install build_cmake --component google_cloud_cpp_development
cmake --install build
cmake --install build --component google_cloud_cpp_development
if %ERRORLEVEL% neq 0 exit 1
)
67 changes: 37 additions & 30 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ source:
- patches/0001-disable-libraries.patch # [libprotobuf == "3.21"]
# backport https://github.com/googleapis/google-cloud-cpp/pull/11782
- patches/0002-fix-better-support-for-cross-compilation-11782.patch
# don't try to build the protobuf-heavy googleapis as shared on win
- patches/0003-do-not-try-to-build-external-googleapis-as-shared.patch # [win]

build:
number: 1
# debug
skip: true # [not win]

requirements:
build:
- {{ compiler('c') }}
Expand All @@ -41,7 +46,7 @@ requirements:

outputs:
- name: libgoogle-cloud
script: build-libgoogle-cloud.sh # [unix]
script: build-libgoogle-cloud.sh # [unix]
script: build-libgoogle-cloud.bat # [win]
build:
run_exports:
Expand All @@ -66,26 +71,25 @@ outputs:
- google-cloud-cpp {{ version }} *_{{ PKG_BUILDNUM }}
test:
commands:
- test -f $PREFIX/lib/libgoogle_cloud_cpp_storage.{{ version }}.dylib # [osx]
- test -f $PREFIX/lib/libgoogle_cloud_cpp_storage.so.{{ version }} # [linux]
- test ! -f $PREFIX/lib/pkgconfig/google_cloud_cpp_storage.pc # [not win]
- test ! -f $PREFIX/lib/cmake/google_cloud_cpp_storage/google_cloud_cpp_storage-config.cmake # [not win]
- test ! -f $PREFIX/include/google/cloud/storage/version.h # [not win]
- test -f $PREFIX/lib/libgoogle_cloud_cpp_bigtable.{{ version }}.dylib # [osx]
- test -f $PREFIX/lib/libgoogle_cloud_cpp_bigtable.so.{{ version }} # [linux]
- test ! -f $PREFIX/lib/cmake/google_cloud_cpp_bigtable/google_cloud_cpp_bigtable-config.cmake # [not win]
- test ! -f $PREFIX/include/google/cloud/bigtable/version.h # [not win]
# Currently, the windows build is static.
#- if not exist %LIBRARY_PREFIX%\\bin\\libgoogle_cloud_cpp_storage.dll exit 1 # [win]
#- if not exist %LIBRARY_PREFIX%\\lib\\pkgconfig\\google_cloud_cpp_storage.pc exit 1 # [win]
- if exist %LIBRARY_PREFIX%\\lib\\cmake\\google_cloud_cpp_storage\\google_cloud_cpp_storage-config.cmake exit 1 # [win]
- if exist %LIBRARY_PREFIX%\\include\\google\\cloud\\storage\\version.h exit 1 # [win]
#- if not exist %LIBRARY_PREFIX%\\bin\\libgoogle_cloud_cpp_bigtable.dll exit 1 # [win]
- if exist %LIBRARY_PREFIX%\\lib\\cmake\\google_cloud_cpp_bigtable\\google_cloud_cpp_bigtable-config.cmake exit 1 # [win]
- if exist %LIBRARY_PREFIX%\\include\\google\\cloud\\bigtable\\version.h exit 1 # [win]
{% for component in ["bigtable", "storage"] %}
# shared libs
- test -f $PREFIX/lib/libgoogle_cloud_cpp_{{ component }}.so.{{ version }} # [linux]
- test -f $PREFIX/lib/libgoogle_cloud_cpp_{{ component }}.{{ version }}.dylib # [osx]
- if not exist %LIBRARY_BIN%\\libgoogle_cloud_cpp_{{ component }}.dll exit 1 # [win]
- if not exist %LIBRARY_LIB%\\libgoogle_cloud_cpp_{{ component }}.lib exit 1 # [win]
# absence of headers
- test ! -f $PREFIX/include/google/cloud/{{ component }}/version.h # [unix]
- if exist %LIBRARY_INC%\\google\\cloud\\{{ component }}\\version.h exit 1 # [win]
# absence of metadata (pkgconfig)
- test ! -f $PREFIX/lib/pkgconfig/google_cloud_cpp_{{ component }}.pc # [unix]
- if exist %LIBRARY_LIB%\\pkgconfig\\google_cloud_cpp_{{ component }}.pc exit 1 # [win]
# absence of metadata (CMake)
- test ! -f $PREFIX/lib/cmake/google_cloud_cpp_{{ component }}/google_cloud_cpp_{{ component }}-config.cmake # [unix]
- if exist %LIBRARY_LIB%\\cmake\\google_cloud_cpp_{{ component }}\\google_cloud_cpp_{{ component }}-config.cmake exit 1 # [win]
{% endfor %}

- name: google-cloud-cpp
script: build-libgoogle-cloud.sh # [unix]
script: build-libgoogle-cloud.sh # [unix]
script: build-libgoogle-cloud.bat # [win]
build:
run_exports:
Expand Down Expand Up @@ -114,17 +118,6 @@ outputs:
# as required; if possible, this should be removed upstream
- zlib
test:
commands:
- ./run_test_google_cloud_cpp.sh # [unix]
- ./run_test_google_cloud_cpp.bat # [win]
- test -f $PREFIX/lib/cmake/google_cloud_cpp_storage/google_cloud_cpp_storage-config.cmake # [not win]
- test -f $PREFIX/include/google/cloud/storage/version.h # [not win]
- test -f $PREFIX/lib/cmake/google_cloud_cpp_bigtable/google_cloud_cpp_bigtable-config.cmake # [not win]
- test -f $PREFIX/include/google/cloud/bigtable/version.h # [not win]
- if not exist %LIBRARY_PREFIX%\\lib\\cmake\\google_cloud_cpp_storage\\google_cloud_cpp_storage-config.cmake exit 1 # [win]
- if not exist %LIBRARY_PREFIX%\\include\\google\\cloud\\storage\\version.h exit 1 # [win]
- if not exist %LIBRARY_PREFIX%\\lib\\cmake\\google_cloud_cpp_bigtable\\google_cloud_cpp_bigtable-config.cmake exit 1 # [win]
- if not exist %LIBRARY_PREFIX%\\include\\google\\cloud\\bigtable\\version.h exit 1 # [win]
requires:
- {{ compiler('cxx') }}
- cmake
Expand All @@ -135,6 +128,20 @@ outputs:
source_files:
- google/cloud/storage/quickstart/*.cc
- google/cloud/storage/quickstart/CMakeLists.txt
commands:
- ./run_test_google_cloud_cpp.sh # [unix]
- ./run_test_google_cloud_cpp.bat # [win]
{% for component in ["bigtable", "storage"] %}
# headers
- test -f $PREFIX/include/google/cloud/{{ component }}/version.h # [unix]
- if not exist %LIBRARY_INC%\\google\\cloud\\{{ component }}\\version.h exit 1 # [win]
# pkgconfig
- test -f $PREFIX/lib/pkgconfig/google_cloud_cpp_{{ component }}.pc # [unix]
- if not exist %LIBRARY_LIB%\\pkgconfig\\google_cloud_cpp_{{ component }}.pc exit 1 # [win]
# CMake
- test -f $PREFIX/lib/cmake/google_cloud_cpp_{{ component }}/google_cloud_cpp_{{ component }}-config.cmake # [unix]
- if not exist %LIBRARY_LIB%\\cmake\\google_cloud_cpp_{{ component }}\\google_cloud_cpp_{{ component }}-config.cmake exit 1 # [win]
{% endfor %}

about:
home: https://github.com/googleapis/google-cloud-cpp
Expand Down
2 changes: 1 addition & 1 deletion recipe/patches/0001-disable-libraries.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From f014c88e7ea57ec2907edf26752264566ef7fa0a Mon Sep 17 00:00:00 2001
From: Carlos O'Ryan <coryan@google.com>
Date: Tue, 7 Feb 2023 01:35:26 +0000
Subject: [PATCH 1/2] disable libraries
Subject: [PATCH 1/3] disable libraries

---
cmake/GoogleCloudCppFeatures.cmake | 6 +++---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From ddfa37bdafcf5ae551157676f5086518f720417d Mon Sep 17 00:00:00 2001
From: Carlos O'Ryan <coryan@google.com>
Date: Tue, 6 Jun 2023 11:30:17 -0400
Subject: [PATCH 2/2] fix: better support for cross-compilation (#11782)
Subject: [PATCH 2/3] fix: better support for cross-compilation (#11782)

Allow overrides for the `protobuf::protoc` and `gRPC::grpc_cpp_plugin`
targets. On cross-compilation builds the targets point to the binaries
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From d9f5e22ce65f427a42d5988fa7227d2dc257b7db Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Wed, 31 Aug 2022 19:00:34 +0200
Subject: [PATCH 3/3] do not try to build external/googleapis as shared

---
CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 028802691d..59fb481451 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -207,7 +207,10 @@ host environment.
"find_dependency(Protobuf)")
find_package(Protobuf REQUIRED)
endif ()
+ # do not try to build googleapis shared on windows
+ set(BUILD_SHARED_LIBS OFF)
add_subdirectory(external/googleapis)
+ set(BUILD_SHARED_LIBS ON)
endif ()

# Enable testing in this directory so we can do a top-level `make test`. This