From 002136e7505af89d36907254cdeff58e794b2815 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 3 Aug 2023 21:40:01 -0700 Subject: [PATCH 01/33] Add a couple of workarounds for Swift on Windows The C++ Interop efforts in Swift currently have some limitations. In particular, it cannot support trivial types with non-trivial destructors. As a workaround, provide a copy constructor which can be used by the Swift interop while using the regular semantics for all other cases. A second issue arises in the handling of futures. Unfortunately, it is not currently possible to pass an indirect block parameter which prevents the construction of a callback. Workaround this by providing an inline shim to use a direct parameter (i.e. indirect value through a pointer) which then allows a callback to be formed. Both of these items are being tracked upstream but seem to be potentially sufficient to enable the use of Swift for using the C++ SDK for desktop scenarios. --- app/src/include/firebase/future.h | 15 +++++++++++++++ auth/CMakeLists.txt | 1 + auth/src/auth_swift.cc | 26 ++++++++++++++++++++++++++ auth/src/include/firebase/auth.h | 7 +++++++ 4 files changed, 49 insertions(+) create mode 100644 auth/src/auth_swift.cc diff --git a/app/src/include/firebase/future.h b/app/src/include/firebase/future.h index 0d09fc079a..d28984e724 100644 --- a/app/src/include/firebase/future.h +++ b/app/src/include/firebase/future.h @@ -407,6 +407,11 @@ class Future : public FutureBase { /// when you set up the callback. typedef void (*TypedCompletionCallback)(const Future& result_data, void* user_data); +#if defined(__swift__) + // TODO(apple/swift#67662) indirect block parameters are unsupported + typedef void (*TypedCompletionCallback_SwiftWorkaround)( + const Future* result_data, void* user_data); +#endif /// Construct a future. Future() {} @@ -464,6 +469,16 @@ class Future : public FutureBase { inline void OnCompletion(TypedCompletionCallback callback, void* user_data) const; +#if defined(__swift__) + // TODO(apple/swift#67662) indirect block parameters are unsupported + inline void OnCompletion_SwiftWorkaround( + TypedCompletionCallback_SwiftWorkaround callback, void* user_data) const { + OnCompletion([callback, user_data](const Future& future) { + callback(&future, user_data); + }); + } +#endif + #if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) /// Register a single callback that will be called at most once, when the /// future is completed. diff --git a/auth/CMakeLists.txt b/auth/CMakeLists.txt index 2dc7c4e255..8ee2a9641e 100644 --- a/auth/CMakeLists.txt +++ b/auth/CMakeLists.txt @@ -51,6 +51,7 @@ build_flatbuffers("${flatbuffer_schemas}" # Common source files used by all platforms set(common_SRCS src/auth.cc + src/auth_swift.cc src/credential.cc src/common.cc src/common.h diff --git a/auth/src/auth_swift.cc b/auth/src/auth_swift.cc new file mode 100644 index 0000000000..a6cedcd5eb --- /dev/null +++ b/auth/src/auth_swift.cc @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Google LLC + * + * 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. + */ + +#define __swift__ 50000 +#include "auth/src/include/firebase/auth.h" + +#if FIREBASE_PLATFORM_WINDOWS +namespace firebase { +namespace auth { +Auth::Auth(const Auth &) noexcept = default; +} +} // namespace firebase +#endif diff --git a/auth/src/include/firebase/auth.h b/auth/src/include/firebase/auth.h index f9c8bfbf36..29ae65a468 100644 --- a/auth/src/include/firebase/auth.h +++ b/auth/src/include/firebase/auth.h @@ -148,6 +148,13 @@ class Auth { ~Auth(); +#if defined(__swift__) +#if FIREBASE_PLATFORM_WINDOWS + // TODO(apple/swift#67288) support trivial C++ types with non-trivial dtors + Auth(const Auth&) noexcept; +#endif +#endif + /// Synchronously gets the cached current user, or returns an object where /// is_valid() == false if there is none. /// From b636756baeb9f89e79042dbb885f9a0dec9eea36 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 7 Aug 2023 13:14:10 -0700 Subject: [PATCH 02/33] GHA: add a custom build of firebase This adds a minimal build of firebase statically for use with Swift on Windows to provide the required base libraries. We build a release only build intended for re-distribution as a basis for building a library to access the Firebase APIs from Swift. --- .github/workflows/bcny-firebase.yml | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/bcny-firebase.yml diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml new file mode 100644 index 0000000000..9489159c48 --- /dev/null +++ b/.github/workflows/bcny-firebase.yml @@ -0,0 +1,54 @@ +name: firebase + +on: + workflow_dispatch: + +jobs: + windows: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + path: ${{ github.workspace }}/SourceCache/firebase-cpp-sdk + ref: refs/heads/main + repository: firebase/firebase-cpp-sdk + + - uses: compnerd/gha-setup-vsdevenv@main + with: + host_arch: amd64 + components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' + arch: amd64 + + - uses: actions/setup-python@v4 + with: + python-version: 3.9 + architecture: 'x64' + + - name: Install absl-py + run: pip install absl-py + + - name: Configure firebase + run: + cmake -B ${{ github.workspace }}/BinaryCache/firebase ` + -D BUILD_SHARED_LIBS=NO ` + -D CMAKE_BUILD_TYPE=Release ` + -D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/firebase/usr ` + -G "Visual Studio 17 2022" ` + -A x64 ` + -S ${{ github.workspace }}/SourceCache/firebase-cpp-sdk ` + -D FIREBASE_CPP_BUILD_PACKAGE=YES ` + -D FIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF ` + -D FIREBASE_INCLUDE_AUTH=YES ` + -D FIREBASE_INCLUDE_FIRESTORE=YES ` + -D FIREBASE_USE_BORINGSSL=YES + - name: Build firebase + run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config Release + - name: Install firebase + run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config Release --target install + + - uses: actions/upload-artifact@v3 + with: + name: firebase-windows-amd64 + path: ${{ github.workspace }}/BuildRoot/Library/firebase From 5966d59391f8ed896b606427669166917c379cfc Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 17 Aug 2023 14:31:18 -0700 Subject: [PATCH 03/33] Update bcny-firebase.yml --- .github/workflows/bcny-firebase.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 9489159c48..bf6e5d0e77 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -12,7 +12,7 @@ jobs: with: fetch-depth: 1 path: ${{ github.workspace }}/SourceCache/firebase-cpp-sdk - ref: refs/heads/main + ref: refs/heads/compnerd/swift repository: firebase/firebase-cpp-sdk - uses: compnerd/gha-setup-vsdevenv@main From 7d9b1a163e29f5078c7014c35563b1d89ac9cc42 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 17 Aug 2023 14:34:54 -0700 Subject: [PATCH 04/33] Update bcny-firebase.yml Fix repository URL --- .github/workflows/bcny-firebase.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index bf6e5d0e77..be81fa2ebd 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -13,7 +13,7 @@ jobs: fetch-depth: 1 path: ${{ github.workspace }}/SourceCache/firebase-cpp-sdk ref: refs/heads/compnerd/swift - repository: firebase/firebase-cpp-sdk + repository: thebrowsercompany/firebase-cpp-sdk - uses: compnerd/gha-setup-vsdevenv@main with: From a25930c1e6d00df0d8dd8999e068038c41064b8f Mon Sep 17 00:00:00 2001 From: Brian Michel Date: Mon, 28 Aug 2023 17:46:10 -0400 Subject: [PATCH 05/33] Adding copy constructor for Firestore --- firestore/CMakeLists.txt | 3 ++- firestore/src/common/firestore_swift.cc | 26 ++++++++++++++++++++++ firestore/src/include/firebase/firestore.h | 7 ++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 firestore/src/common/firestore_swift.cc diff --git a/firestore/CMakeLists.txt b/firestore/CMakeLists.txt index 0cea8d1435..88caacf6b0 100644 --- a/firestore/CMakeLists.txt +++ b/firestore/CMakeLists.txt @@ -34,6 +34,7 @@ set(common_SRCS src/common/field_path.cc src/common/field_value.cc src/common/firestore.cc + src/common/firestore_swift.cc src/common/firestore_exceptions_common.h src/common/futures.cc src/common/futures.h @@ -340,7 +341,7 @@ if(IOS) set(FIREBASE_FIRESTORE_CORE_HEADER_DIR ${FIREBASE_POD_DIR}/Pods/FirebaseFirestore/Firestore/core/include ) - + else() # Desktop and Android get their public headers from the CMake build in # firebase-ios-sdk. diff --git a/firestore/src/common/firestore_swift.cc b/firestore/src/common/firestore_swift.cc new file mode 100644 index 0000000000..cac22bf31f --- /dev/null +++ b/firestore/src/common/firestore_swift.cc @@ -0,0 +1,26 @@ +/* + * Copyright 2020 Google LLC + * + * 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. + */ + +#define __swift__ 50000 +#include "firestore/src/include/firebase/firestore.h" + +#if FIREBASE_PLATFORM_WINDOWS +namespace firebase { +namespace firstore { +Firestore::Firestore(const Firestore&) noexcept = default; +} +} // namespace firebase +#endif diff --git a/firestore/src/include/firebase/firestore.h b/firestore/src/include/firebase/firestore.h index 7cc0274812..ede071590e 100644 --- a/firestore/src/include/firebase/firestore.h +++ b/firestore/src/include/firebase/firestore.h @@ -194,7 +194,14 @@ class Firestore { * Deleted copy constructor; Firestore must be created with * Firestore::GetInstance(). */ +#if defined(__swift__) +#if FIREBASE_PLATFORM_WINDOWS + Firestore(const Firestore& src) noexcept; +#else Firestore(const Firestore& src) = delete; +#else + Firestore(const Firestore& src) = delete; +#endif /** * Deleted copy assignment operator; Firestore must be created with From 7e10724f95e5e0244b62cac1f29a2e9292cea0f6 Mon Sep 17 00:00:00 2001 From: Brian Michel Date: Mon, 28 Aug 2023 18:34:40 -0400 Subject: [PATCH 06/33] Actually scope the changes correctly. (#3) --- firestore/src/include/firebase/firestore.h | 1 + 1 file changed, 1 insertion(+) diff --git a/firestore/src/include/firebase/firestore.h b/firestore/src/include/firebase/firestore.h index ede071590e..8478f25a2d 100644 --- a/firestore/src/include/firebase/firestore.h +++ b/firestore/src/include/firebase/firestore.h @@ -199,6 +199,7 @@ class Firestore { Firestore(const Firestore& src) noexcept; #else Firestore(const Firestore& src) = delete; +#endif #else Firestore(const Firestore& src) = delete; #endif From 449dad810d7f3f134047eb347688fa1ed8e1c626 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 28 Aug 2023 16:24:52 -0700 Subject: [PATCH 07/33] Update firestore_swift.cc Correct enclosing namespace for `Firestore`. --- firestore/src/common/firestore_swift.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firestore/src/common/firestore_swift.cc b/firestore/src/common/firestore_swift.cc index cac22bf31f..7e3d25be4a 100644 --- a/firestore/src/common/firestore_swift.cc +++ b/firestore/src/common/firestore_swift.cc @@ -19,8 +19,8 @@ #if FIREBASE_PLATFORM_WINDOWS namespace firebase { -namespace firstore { -Firestore::Firestore(const Firestore&) noexcept = default; +namespace firestore { +Firestore::Firestore(const Firestore &) noexcept = default; } } // namespace firebase #endif From 202d02200124c3db9f4daecb8b58b7c29c46b6de Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 31 Aug 2023 12:46:41 -0700 Subject: [PATCH 08/33] Update bcny-firebase.yml Distribute firestore dependency headers --- .github/workflows/bcny-firebase.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index be81fa2ebd..b85d21c9f7 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -47,7 +47,11 @@ jobs: run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config Release - name: Install firebase run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config Release --target install - + - name: Install firebase (manual) + run: | + Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/firestore_errors.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/firestore_errors.h" + Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/geo_point.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/geo_point.h" + Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/timestamp.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/timestamp.h" - uses: actions/upload-artifact@v3 with: name: firebase-windows-amd64 From 4023d3ea2e65f72919b86c7e19dbdf97f20e5d17 Mon Sep 17 00:00:00 2001 From: Brian Michel Date: Tue, 19 Sep 2023 14:42:59 -0400 Subject: [PATCH 09/33] Copy in firestore libs --- .github/workflows/bcny-firebase.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index b85d21c9f7..c9ef2e61c8 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -52,6 +52,9 @@ jobs: Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/firestore_errors.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/firestore_errors.h" Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/geo_point.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/geo_point.h" Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/timestamp.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/timestamp.h" + Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore-build/Firestore/core/Release/firestore_nanopb.lib" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows/firestore_nanopb.lib" + Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore-build/Firestore/core/Release/firestore_util.lib" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows/firestore_util.lib" + Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore-build/Firestore/core/Release/firestore_core.lib" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows/firestore_core.lib" - uses: actions/upload-artifact@v3 with: name: firebase-windows-amd64 From 4135f29a2edde6142e8c8e0f0a1fe105d4eadafb Mon Sep 17 00:00:00 2001 From: Brian Michel Date: Tue, 19 Sep 2023 16:24:17 -0400 Subject: [PATCH 10/33] Copy all lib files --- .github/workflows/bcny-firebase.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index c9ef2e61c8..bd6ce8e70a 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -52,9 +52,18 @@ jobs: Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/firestore_errors.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/firestore_errors.h" Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/geo_point.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/geo_point.h" Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/timestamp.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/timestamp.h" - Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore-build/Firestore/core/Release/firestore_nanopb.lib" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows/firestore_nanopb.lib" - Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore-build/Firestore/core/Release/firestore_util.lib" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows/firestore_util.lib" - Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore-build/Firestore/core/Release/firestore_core.lib" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows/firestore_core.lib" + + Write-Host "Copying .lib files into place..." + $sourceDirectory = "${{ github.workspace }}/BinaryCache/firebase" + $destinationDirectory = "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows" + + $libFiles = Get-ChildItem -Path $sourceDirectory -File -Recurse -Filter *.lib + + foreach ($file in $libFiles) { + $destinationPath = Join-Path -Path $destinationDirectory -ChildPath $file.Name + Copy-Item -Path $file.FullName -Destination $destinationPath -Force + Write-Host "Copy operation completed for ${destinationPath}" + } - uses: actions/upload-artifact@v3 with: name: firebase-windows-amd64 From 525211e1d38401c989c93b2524aabb590c7e4c4e Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 29 Sep 2023 21:56:08 -0700 Subject: [PATCH 11/33] Update bcny-firebase.yml Enable support for ARM64. Add a matrix to allow building the x64 and ARM64 slices of the SDK. --- .github/workflows/bcny-firebase.yml | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index bd6ce8e70a..38a78a4ecc 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -7,6 +7,15 @@ jobs: windows: runs-on: windows-latest + strategy: + fail-fast: false + matrix: + include: + - arch: 'amd64' + platform: 'x64' + - arch: 'arm64' + platform: 'ARM64' + steps: - uses: actions/checkout@v3 with: @@ -18,8 +27,8 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@main with: host_arch: amd64 - components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' - arch: amd64 + components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' + arch: ${{ matrix.arch }} - uses: actions/setup-python@v4 with: @@ -36,7 +45,7 @@ jobs: -D CMAKE_BUILD_TYPE=Release ` -D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/firebase/usr ` -G "Visual Studio 17 2022" ` - -A x64 ` + -A ${{ matrix.platform }} ` -S ${{ github.workspace }}/SourceCache/firebase-cpp-sdk ` -D FIREBASE_CPP_BUILD_PACKAGE=YES ` -D FIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF ` @@ -53,18 +62,15 @@ jobs: Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/geo_point.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/geo_point.h" Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/timestamp.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/timestamp.h" - Write-Host "Copying .lib files into place..." - $sourceDirectory = "${{ github.workspace }}/BinaryCache/firebase" - $destinationDirectory = "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows" - - $libFiles = Get-ChildItem -Path $sourceDirectory -File -Recurse -Filter *.lib - - foreach ($file in $libFiles) { - $destinationPath = Join-Path -Path $destinationDirectory -ChildPath $file.Name - Copy-Item -Path $file.FullName -Destination $destinationPath -Force - Write-Host "Copy operation completed for ${destinationPath}" + Write-Host "Copying static libraries ..." + $source = "${{ github.workspace }}/BinaryCache/firebase" + $libraries = Get-ChildItem -Path $source -File -Recurse -Filter *.lib + foreach ($library in $libraries) { + $destination = Join-Path -Path "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows" -ChildPath $library.Name + Copy-Item -Path $library.FullName -Destination $destination -Force + Write-Host "... copied ${destination}" } - uses: actions/upload-artifact@v3 with: - name: firebase-windows-amd64 + name: firebase-windows-${{ matrix.arch }} path: ${{ github.workspace }}/BuildRoot/Library/firebase From 95d3f3e77673c22b09c04ee520ed83c3c2b60644 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 20 Oct 2023 09:21:46 -0700 Subject: [PATCH 12/33] boringssl: disable C4746 for building boringssl on ARM64 --- scripts/git/patches/boringssl/0001-disable-warnings.patch | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/git/patches/boringssl/0001-disable-warnings.patch b/scripts/git/patches/boringssl/0001-disable-warnings.patch index e8063cf487..b45f0ac4fb 100644 --- a/scripts/git/patches/boringssl/0001-disable-warnings.patch +++ b/scripts/git/patches/boringssl/0001-disable-warnings.patch @@ -9,6 +9,9 @@ + "C4191" # 'operator/operation' : unsafe conversion from 'type of + # expression' to 'type required' + "C5264" # 'const' variable is not used ++ "C4746" # volatile access of 'label' is subject to /volatile: ++ # setting; consider using __iso_volatile_load/store intrinsic ++ # functions "C4267" # conversion from 'size_t' to 'int', possible loss of data "C4371" # layout of class may have changed from a previous version of the # compiler due to better packing of member '...' From df5f0586aeaf4e7e89d4d1dbb582e8a88318a450 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 20 Oct 2023 09:23:00 -0700 Subject: [PATCH 13/33] Update bcny-firebase.yml Indicate that the build is performed in CI, explicitly disable the static MSVC library linkage. --- .github/workflows/bcny-firebase.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 38a78a4ecc..e4104d0efd 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -48,10 +48,12 @@ jobs: -A ${{ matrix.platform }} ` -S ${{ github.workspace }}/SourceCache/firebase-cpp-sdk ` -D FIREBASE_CPP_BUILD_PACKAGE=YES ` + -D FIREBASE_GITHUB_ACTION_BUILD=YES ` -D FIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF ` -D FIREBASE_INCLUDE_AUTH=YES ` -D FIREBASE_INCLUDE_FIRESTORE=YES ` - -D FIREBASE_USE_BORINGSSL=YES + -D FIREBASE_USE_BORINGSSL=YES ` + -D MSVC_RUNTIME_LIBRARY_STATIC=NO - name: Build firebase run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config Release - name: Install firebase From 230723589b9af651131c8a4f72f929b2ca097be2 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 20 Oct 2023 09:31:18 -0700 Subject: [PATCH 14/33] boringssl: attempt to tweak the patch a bit further --- scripts/git/patches/boringssl/0001-disable-warnings.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/git/patches/boringssl/0001-disable-warnings.patch b/scripts/git/patches/boringssl/0001-disable-warnings.patch index b45f0ac4fb..9d4551df98 100644 --- a/scripts/git/patches/boringssl/0001-disable-warnings.patch +++ b/scripts/git/patches/boringssl/0001-disable-warnings.patch @@ -1,6 +1,6 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -197,6 +197,11 @@ elseif(MSVC) +@@ -197,6 +197,14 @@ elseif(MSVC) # possible loss of data "C4244" # 'function' : conversion from 'int' to 'uint8_t', # possible loss of data From 46713355e9961d62a970e573a36368bfd0d18605 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 20 Oct 2023 10:44:03 -0700 Subject: [PATCH 15/33] Update bcny-firebase.yml Use explicit path to python interpreter. --- .github/workflows/bcny-firebase.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index e4104d0efd..37f33a10c7 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -31,6 +31,7 @@ jobs: arch: ${{ matrix.arch }} - uses: actions/setup-python@v4 + id: python with: python-version: 3.9 architecture: 'x64' @@ -53,7 +54,8 @@ jobs: -D FIREBASE_INCLUDE_AUTH=YES ` -D FIREBASE_INCLUDE_FIRESTORE=YES ` -D FIREBASE_USE_BORINGSSL=YES ` - -D MSVC_RUNTIME_LIBRARY_STATIC=NO + -D MSVC_RUNTIME_LIBRARY_STATIC=NO ` + -D Python3_EXECUTABLE=${{ steps.python.outputs.python-path }} - name: Build firebase run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config Release - name: Install firebase From d9b6df3a461a4fc43e603bf56657f633b5948b88 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 20 Oct 2023 12:55:26 -0700 Subject: [PATCH 16/33] build: propagate the python version Ensure that we use the same python version across the sub-builds as `Python3_EXECUTABLE` can be explicitly passed to control the version of python in use. --- cmake/external_rules.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/external_rules.cmake b/cmake/external_rules.cmake index bdd38b0eda..2ce5a13e48 100644 --- a/cmake/external_rules.cmake +++ b/cmake/external_rules.cmake @@ -235,6 +235,10 @@ function(build_external_dependencies) # Propagate the PIC setting, as the dependencies need to match it set(CMAKE_SUB_CONFIGURE_OPTIONS ${CMAKE_SUB_CONFIGURE_OPTIONS} -DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}) + if(Python3_EXECUTABLE) + set(CMAKE_SUB_CONFIGURE_OPTIONS ${CMAKE_SUB_CONFIGURE_OPTIONS} + -DPython3_EXECUTABLE=${Python3_EXECUTABLE}) + endif() message(STATUS "Sub-configure options: ${CMAKE_SUB_CONFIGURE_OPTIONS}") message(STATUS "Sub-build options: ${CMAKE_SUB_BUILD_OPTIONS}") From af01005a9e7f64a9ae31217ae089e2645d93040b Mon Sep 17 00:00:00 2001 From: Brian Michel Date: Thu, 9 Nov 2023 12:04:50 +0000 Subject: [PATCH 17/33] Ensure we pass our python path to CMake (#12) --- .github/workflows/bcny-firebase.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 37f33a10c7..441802a6cb 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -55,7 +55,7 @@ jobs: -D FIREBASE_INCLUDE_FIRESTORE=YES ` -D FIREBASE_USE_BORINGSSL=YES ` -D MSVC_RUNTIME_LIBRARY_STATIC=NO ` - -D Python3_EXECUTABLE=${{ steps.python.outputs.python-path }} + -D FIREBASE_PYTHON_HOST_EXECUTABLE:FILEPATH=${{ steps.python.outputs.python-path }} - name: Build firebase run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config Release - name: Install firebase From 3cd53b1660d8ce3c4ad79700a76d74bc0ba7c055 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 16 Nov 2023 11:26:14 -0800 Subject: [PATCH 18/33] GHA: disable flatc build We would like to cross-compile to ARM64, so we need to ensure that we disable the flatc build. --- .github/workflows/bcny-firebase.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 441802a6cb..8beb11da7a 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -48,6 +48,7 @@ jobs: -G "Visual Studio 17 2022" ` -A ${{ matrix.platform }} ` -S ${{ github.workspace }}/SourceCache/firebase-cpp-sdk ` + -D FLATBUFFERS_BUILD_FLATC=NO ` -D FIREBASE_CPP_BUILD_PACKAGE=YES ` -D FIREBASE_GITHUB_ACTION_BUILD=YES ` -D FIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF ` From c6a696c073e5b95c24946068c9b0a833a424fb8e Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 16 Nov 2023 14:43:46 -0800 Subject: [PATCH 19/33] GHA: build and use flatc for the build Prebuild flatc manually and use that to build the flatbuffer code. This should help us with the cross-compilation for ARM64. --- .github/workflows/bcny-firebase.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 8beb11da7a..fb50c0974b 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -17,6 +17,13 @@ jobs: platform: 'ARM64' steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + path: ${{ github.workspace }}/SourceCache/flatbuffers + ref: master + repository: google/flatbuffers + - uses: actions/checkout@v3 with: fetch-depth: 1 @@ -39,6 +46,16 @@ jobs: - name: Install absl-py run: pip install absl-py + - name: Configure flatbuffers + run: + cmake -B ${{ github.workspace }}/BinaryCache/flatbuffers ` + -D CMAKE_BUILD_TYPE=Release ` + -G "Visual Studio 17 2022" ` + -A x64 ` + -S ${{ github.workspace }}/SourceCache/flatbuffers + - name: Build flatc + run: cmake --build ${{ github.workspace }}/BinaryCache/flatbuffers --config Release --target flatc + - name: Configure firebase run: cmake -B ${{ github.workspace }}/BinaryCache/firebase ` @@ -56,7 +73,8 @@ jobs: -D FIREBASE_INCLUDE_FIRESTORE=YES ` -D FIREBASE_USE_BORINGSSL=YES ` -D MSVC_RUNTIME_LIBRARY_STATIC=NO ` - -D FIREBASE_PYTHON_HOST_EXECUTABLE:FILEPATH=${{ steps.python.outputs.python-path }} + -D FIREBASE_PYTHON_HOST_EXECUTABLE:FILEPATH=${{ steps.python.outputs.python-path }} ` + -D FLATBUFFERS_FLATC_EXECUTABLE=${{ github.workspace }}/BinaryCache/flatbuffers/Release/flatc.exe - name: Build firebase run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config Release - name: Install firebase From d76bbd499ffaf181c100e17a935e5eaa0985775c Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 16 Nov 2023 14:45:42 -0800 Subject: [PATCH 20/33] GHA: pin flatbuffer to the same revision as the dependency This pins the flatc build to the same revision that will be used in the build of firebase. --- .github/workflows/bcny-firebase.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index fb50c0974b..0917748d20 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -21,7 +21,7 @@ jobs: with: fetch-depth: 1 path: ${{ github.workspace }}/SourceCache/flatbuffers - ref: master + ref: 99aa1ef21dd9dc3f9d4fb0eb82f4b59d0bb5e4c5 repository: google/flatbuffers - uses: actions/checkout@v3 From 4ef92e8c7a576250376ef71a059567dcb0367f40 Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 28 Nov 2023 16:03:54 -0800 Subject: [PATCH 21/33] Update bcny-firebase.yml Make some pdbs --- .github/workflows/bcny-firebase.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 0917748d20..ef3a997c2e 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -76,9 +76,9 @@ jobs: -D FIREBASE_PYTHON_HOST_EXECUTABLE:FILEPATH=${{ steps.python.outputs.python-path }} ` -D FLATBUFFERS_FLATC_EXECUTABLE=${{ github.workspace }}/BinaryCache/flatbuffers/Release/flatc.exe - name: Build firebase - run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config Release + run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config RelWithDebInfo - name: Install firebase - run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config Release --target install + run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config RelWithDebInfo --target install - name: Install firebase (manual) run: | Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/firestore_errors.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/firestore_errors.h" @@ -93,6 +93,13 @@ jobs: Copy-Item -Path $library.FullName -Destination $destination -Force Write-Host "... copied ${destination}" } + + $pdbs = Get-ChildItem -Path $source -File -Recurse -Filter *.pdb + foreach ($pdb in $pdbs) { + $destination = Join-Path -Path "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows" -ChildPath $pdb.Name + Copy-Item -Path $pdb.FullName -Destination $destination -Force + Write-Host "... copied ${destination}" + } - uses: actions/upload-artifact@v3 with: name: firebase-windows-${{ matrix.arch }} From 6692a0df8e5d55bdceae046aaf5d35eea269dcd4 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 29 Nov 2023 09:26:14 -0800 Subject: [PATCH 22/33] Update CMakeLists.txt Enable CMP0141 to allow us to embed debug information for Firebase. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74644b5711..8e211b4963 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ # Top level CMake file that defines the entire Firebase C++ SDK build. +if(POLICY CMP0141) + cmake_policy(SET CMP0141 NEW) +endif() + cmake_minimum_required (VERSION 3.1) set (CMAKE_CXX_STANDARD 14) From b6a951c5bd899afab4d46bd181e4122221299e46 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 29 Nov 2023 09:27:16 -0800 Subject: [PATCH 23/33] Update bcny-firebase.yml --- .github/workflows/bcny-firebase.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index ef3a997c2e..201133c550 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -60,7 +60,6 @@ jobs: run: cmake -B ${{ github.workspace }}/BinaryCache/firebase ` -D BUILD_SHARED_LIBS=NO ` - -D CMAKE_BUILD_TYPE=Release ` -D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/firebase/usr ` -G "Visual Studio 17 2022" ` -A ${{ matrix.platform }} ` @@ -73,6 +72,7 @@ jobs: -D FIREBASE_INCLUDE_FIRESTORE=YES ` -D FIREBASE_USE_BORINGSSL=YES ` -D MSVC_RUNTIME_LIBRARY_STATIC=NO ` + -D CMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded ` -D FIREBASE_PYTHON_HOST_EXECUTABLE:FILEPATH=${{ steps.python.outputs.python-path }} ` -D FLATBUFFERS_FLATC_EXECUTABLE=${{ github.workspace }}/BinaryCache/flatbuffers/Release/flatc.exe - name: Build firebase From 030b6bc8021f0b2c87200eabe68f17ca7227c4de Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 29 Nov 2023 09:27:40 -0800 Subject: [PATCH 24/33] Update bcny-firebase.yml --- .github/workflows/bcny-firebase.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 201133c550..c26cc329cd 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -93,13 +93,6 @@ jobs: Copy-Item -Path $library.FullName -Destination $destination -Force Write-Host "... copied ${destination}" } - - $pdbs = Get-ChildItem -Path $source -File -Recurse -Filter *.pdb - foreach ($pdb in $pdbs) { - $destination = Join-Path -Path "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/windows" -ChildPath $pdb.Name - Copy-Item -Path $pdb.FullName -Destination $destination -Force - Write-Host "... copied ${destination}" - } - uses: actions/upload-artifact@v3 with: name: firebase-windows-${{ matrix.arch }} From d4f69704b7579864baf962553e4b96a89478c987 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 29 Nov 2023 10:24:19 -0800 Subject: [PATCH 25/33] Update bcny-firebase.yml --- .github/workflows/bcny-firebase.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index c26cc329cd..03f8f32a00 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -60,6 +60,7 @@ jobs: run: cmake -B ${{ github.workspace }}/BinaryCache/firebase ` -D BUILD_SHARED_LIBS=NO ` + -D CMAKE_BUILD_TYPE=Release ` -D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/firebase/usr ` -G "Visual Studio 17 2022" ` -A ${{ matrix.platform }} ` From bd49521279efd07c65b3e06feda9e8ee1cf07dca Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi <56735936+hjyamauchi@users.noreply.github.com> Date: Wed, 6 Dec 2023 12:01:12 -0800 Subject: [PATCH 26/33] Add using for some types to work around compiler crash SR70253 (#14) Reference some types so that they are included in the CXX module. --- .../src/include/firebase/firestore/map_field_value.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/firestore/src/include/firebase/firestore/map_field_value.h b/firestore/src/include/firebase/firestore/map_field_value.h index 8c67c05a10..a63cfe70d9 100644 --- a/firestore/src/include/firebase/firestore/map_field_value.h +++ b/firestore/src/include/firebase/firestore/map_field_value.h @@ -31,6 +31,15 @@ using MapFieldValue = std::unordered_map; /** @brief A map of `FieldValue`s indexed by field paths. */ using MapFieldPathValue = std::unordered_map; +#if defined(__swift__) +// Reference the following types so that they are included in the CXX +// module. A workaround for deserialization cross reference compiler +// crashes https://github.com/apple/swift/issues/70253 +using FieldValueVector = std::vector; +using FieldValueVectorConstIterator = std::_Vector_const_iterator>>; +using StringVectorConstIterator = std::vector::const_iterator; +#endif + } // namespace firestore } // namespace firebase From 3e770ab978ee4a9f618f7eea79766864fdf2b319 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 6 Dec 2023 16:46:07 -0800 Subject: [PATCH 27/33] GHA: package up the content as a nuget package This introduces an initial nuget packaging for simpler distribution of the artifacts. --- .github/workflows/bcny-firebase.yml | 139 ++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 03f8f32a00..75d3d31faa 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -98,3 +98,142 @@ jobs: with: name: firebase-windows-${{ matrix.arch }} path: ${{ github.workspace }}/BuildRoot/Library/firebase + + - name: Package firebase-cpp-sdk + run: | + @" + + + + com.google.firebase.windows.${{ matrix.arch }} + 0.0.0.0 + Firebase C++ SDK + C++ Firebase SDK + Google, Inc. + https://firebase.google.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "@ | Out-File -Encoding UTF8 firebase.nuspec + nuget pack -Properties BUILDROOT=${{ github.workspace }}\BuildRoot\Library\firebase -Suffix (git log -1 --format=%h) firebase.nuspec + shell: pwsh + - uses: actions/upload-artifact@v3 + with: + name: windows-${{ matrix.arch }}.nupkg + path: com.google.firebase.windows.${{ matrix.arch }}.*.nupkg From 313e3b400f9edf40c1d9041fd178ece463ebcc02 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 8 Dec 2023 11:31:17 -0800 Subject: [PATCH 28/33] GHA: add publish nuget package step for CI This will publish the package to ease the consumption of it in the client. --- .github/workflows/bcny-firebase.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 75d3d31faa..249438d00e 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -231,9 +231,26 @@ jobs: "@ | Out-File -Encoding UTF8 firebase.nuspec - nuget pack -Properties BUILDROOT=${{ github.workspace }}\BuildRoot\Library\firebase -Suffix (git log -1 --format=%h) firebase.nuspec + nuget pack -Properties BUILDROOT=${{ github.workspace }}\BuildRoot\Library\firebase -Suffix (git -C ${{ github.workspace }}/SourceCache/firebase-cpp-sdk log -1 --format=%h) firebase.nuspec shell: pwsh - uses: actions/upload-artifact@v3 with: name: windows-${{ matrix.arch }}.nupkg path: com.google.firebase.windows.${{ matrix.arch }}.*.nupkg + + - name: Publish NuGet Packages + env: + NUGET_SOURCE_NAME: TheBrowserCompany + NUGET_SOURCE_URL: https://nuget.pkg.github.com/thebrowsercompany/index.json + NUGET_SOURCE_USERNAME: thebrowsercompany-bot2 + NUGET_SOURCE_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + NUGET_API_KEY: ${{ secrets.GITHUB_TOKEN }} + run: | + if ((nuget sources List | Select-String "${env:NUGET_SOURCE_NAME}").Count -gt 0) { + nuget sources Remove -Name "${env:NUGET_SOURCE_NAME}" + } + nuget sources Add -Name ${env:NUGET_SOURCE_NAME} -Source ${env:NUGET_SOURCE_URL} -Username ${env:NUGET_SOURCE_USERNAME} -Password ${env:NUGET_SOURCE_PASSWORD} -StorePasswordInClearText + nuget setApiKey ${env:NUGET_API_KEY} -Source ${env:NUGET_SOURCE_URL} + $pkgs = Get-ChildItem -Path com.google.firebase.windows.${{ matrix.arch }}.*.nupkg + nuget push $pkgs[0].Name -Source ${env:NUGET_SOURCE_URL} -SkipDuplicate + shell: pwsh From 4f3bf5184a98598da33ba41a187c10a362342f70 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 14 Dec 2023 15:32:07 -0800 Subject: [PATCH 29/33] Update bcny-firebase.yml Remove an extraneous `include` in the path. --- .github/workflows/bcny-firebase.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 249438d00e..bd00627c7e 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -151,7 +151,7 @@ jobs: - + From 30521a10b44735291be96519f62fba28aff7edae Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 18 Dec 2023 09:23:10 -0800 Subject: [PATCH 30/33] Update bcny-firebase.yml Add missing `firebase_util.lib` to the packaging. Thanks to @jeffdav for identifying the missing library. --- .github/workflows/bcny-firebase.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index bd00627c7e..3df0dc3521 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -160,6 +160,7 @@ jobs: + From dece3ca27997a620098eaf1734011869228b5a44 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 18 Dec 2023 10:07:24 -0800 Subject: [PATCH 31/33] Update bcny-firebase.yml Correct the library name to `firestore_util.lib`. --- .github/workflows/bcny-firebase.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 3df0dc3521..735dacc65a 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -160,10 +160,10 @@ jobs: - + From f6d6ee2690040b9762d7454dc7ed9286d54bd985 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Wed, 6 Mar 2024 06:45:28 -0800 Subject: [PATCH 32/33] Override build settings to specify /Z7 instead of /Zi for embedded PDBs in the BCNY windows build (#20) * [windows][build] add a helper script to adjust MSVC debug flags to be Z7 instead of Zi * [bcny][gh workflow] build firebase with /Z7 for embedded debug information on windows * roll back to the mainline branch --- .github/workflows/bcny-firebase.yml | 33 +++++++++++++++++++ .../windows/fix_cmake_debugflags.ps1 | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 build_scripts/windows/fix_cmake_debugflags.ps1 diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 735dacc65a..7a7d47bdfb 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -56,6 +56,9 @@ jobs: - name: Build flatc run: cmake --build ${{ github.workspace }}/BinaryCache/flatbuffers --config Release --target flatc + - name: Adjust cmake build settings for debugging + run: powershell ${{ github.workspace }}/SourceCache/firebase-cpp-sdk/build_scripts/windows/fix_cmake_debugflags.ps1 ${{ github.workspace }}/SourceCache/firebase-cpp-sdk/CMakeLists.txt + - name: Configure firebase run: cmake -B ${{ github.workspace }}/BinaryCache/firebase ` @@ -76,6 +79,36 @@ jobs: -D CMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded ` -D FIREBASE_PYTHON_HOST_EXECUTABLE:FILEPATH=${{ steps.python.outputs.python-path }} ` -D FLATBUFFERS_FLATC_EXECUTABLE=${{ github.workspace }}/BinaryCache/flatbuffers/Release/flatc.exe + + - name: Adjust external project build settings for debugging + run: | + $names = Get-ChildItem -Path "${{ github.workspace }}/BinaryCache/firebase" -File -Recurse -Filter CMakeLists.txt + foreach ($name in $names) { + $fullName = $name.FullName + powershell ${{ github.workspace }}/SourceCache/firebase-cpp-sdk/build_scripts/windows/fix_cmake_debugflags.ps1 $fullName + Write-Host "... fixed up debug options for ${fullName}" + } + + - name: Configure firebase after build setting adjustments + run: + cmake -B ${{ github.workspace }}/BinaryCache/firebase ` + -D BUILD_SHARED_LIBS=NO ` + -D CMAKE_BUILD_TYPE=Release ` + -D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/firebase/usr ` + -G "Visual Studio 17 2022" ` + -A ${{ matrix.platform }} ` + -S ${{ github.workspace }}/SourceCache/firebase-cpp-sdk ` + -D FLATBUFFERS_BUILD_FLATC=NO ` + -D FIREBASE_CPP_BUILD_PACKAGE=YES ` + -D FIREBASE_GITHUB_ACTION_BUILD=YES ` + -D FIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF ` + -D FIREBASE_INCLUDE_AUTH=YES ` + -D FIREBASE_INCLUDE_FIRESTORE=YES ` + -D FIREBASE_USE_BORINGSSL=YES ` + -D MSVC_RUNTIME_LIBRARY_STATIC=NO ` + -D CMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded ` + -D FIREBASE_PYTHON_HOST_EXECUTABLE:FILEPATH=${{ steps.python.outputs.python-path }} ` + -D FLATBUFFERS_FLATC_EXECUTABLE=${{ github.workspace }}/BinaryCache/flatbuffers/Release/flatc.exe - name: Build firebase run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --config RelWithDebInfo - name: Install firebase diff --git a/build_scripts/windows/fix_cmake_debugflags.ps1 b/build_scripts/windows/fix_cmake_debugflags.ps1 new file mode 100644 index 0000000000..d2591d65a0 --- /dev/null +++ b/build_scripts/windows/fix_cmake_debugflags.ps1 @@ -0,0 +1,33 @@ +# Path to the CMakeLists.txt file +$filePath = $args[0] + +# Lines to add after the line starting with "cmake_minimum_required" +$newLines = @( + 'string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")', + 'string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")', + 'string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")', + 'string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")' +) + +# Read the content of the file +$content = Get-Content -Path $filePath + +# New content holder +$newContent = @() + +# Flag to check if lines are added +$linesAdded = $false + +foreach ($line in $content) { + # Add the current line to new content + $newContent += $line + + # Check if the line starts with "cmake_minimum_required" and add new lines after it + if ($line -match '^cmake_minimum_required' -and -not $linesAdded) { + $newContent += $newLines + $linesAdded = $true + } +} + +# Write the new content back to the file +$newContent | Set-Content -Path $filePath From 2f7065719f34fec9a946ab54a2da98ddc8e6b2fa Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 6 Mar 2024 07:15:07 -0800 Subject: [PATCH 33/33] GHA: add Android builds for firebase-cpp-sdk Introduce the Android builds so that we could start exploring the use of firebase on Android native code. --- .github/workflows/bcny-firebase.yml | 105 ++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/.github/workflows/bcny-firebase.yml b/.github/workflows/bcny-firebase.yml index 7a7d47bdfb..e4d0930c47 100644 --- a/.github/workflows/bcny-firebase.yml +++ b/.github/workflows/bcny-firebase.yml @@ -5,6 +5,8 @@ on: jobs: windows: + if: false + runs-on: windows-latest strategy: @@ -288,3 +290,106 @@ jobs: $pkgs = Get-ChildItem -Path com.google.firebase.windows.${{ matrix.arch }}.*.nupkg nuget push $pkgs[0].Name -Source ${env:NUGET_SOURCE_URL} -SkipDuplicate shell: pwsh + + android: + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + include: + - arch: 'aarch64' + platform: 'arm64-v8a' + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + path: ${{ github.workspace }}/SourceCache/flatbuffers + ref: 99aa1ef21dd9dc3f9d4fb0eb82f4b59d0bb5e4c5 + repository: google/flatbuffers + + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + path: ${{ github.workspace }}/SourceCache/firebase-cpp-sdk + ref: refs/heads/compnerd/swift + repository: thebrowsercompany/firebase-cpp-sdk + + # NOTE(compnerd) we use setup-vsdevenv to get CMake and Ninja into `Path` + - uses: compnerd/gha-setup-vsdevenv@main + with: + host_arch: amd64 + + - uses: actions/setup-python@v4 + id: python + with: + python-version: 3.9 + architecture: 'x64' + + - name: Install absl-py + run: pip install absl-py + + - name: Configure flatbuffers + run: + cmake -B ${{ github.workspace }}/BinaryCache/flatbuffers ` + -D CMAKE_BUILD_TYPE=Release ` + -G "Visual Studio 17 2022" ` + -A x64 ` + -S ${{ github.workspace }}/SourceCache/flatbuffers + - name: Build flatc + run: cmake --build ${{ github.workspace }}/BinaryCache/flatbuffers --config Release --target flatc + + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - uses: android-actions/setup-android@v3 + + - name: Configure firebase + run: | + $ANDROID_NDK_ROOT = cygpath -m $env:ANDROID_NDK + + cmake -B ${{ github.workspace }}/BinaryCache/firebase ` + -D BUILD_SHARED_LIBS=NO ` + -D CMAKE_BUILD_TYPE=RelWithDebInfo ` + -D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/firebase/usr ` + -D CMAKE_MAKE_PROGRAM=$((Get-Command Ninja).Source) ` + -D CMAKE_SYSTEM_NAME=Android ` + -D CMAKE_ANDROID_API=28 ` + -D CMAKE_ANDROID_ARCH_ABI=${{ matrix.platform }} ` + -D CMAKE_ANDROID_NDK=$ANDROID_NDK_ROOT ` + -G Ninja ` + -S ${{ github.workspace }}/SourceCache/firebase-cpp-sdk ` + -D FLATBUFFERS_BUILD_FLATC=NO ` + -D FIREBASE_CPP_BUILD_PACKAGE=YES ` + -D FIREBASE_GITHUB_ACTION_BUILD=YES ` + -D FIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF ` + -D FIREBASE_INCLUDE_AUTH=YES ` + -D FIREBASE_INCLUDE_FIRESTORE=YES ` + -D FIREBASE_USE_BORINGSSL=YES ` + -D FIREBASE_PYTHON_HOST_EXECUTABLE:FILEPATH=${{ steps.python.outputs.python-path }} ` + -D FLATBUFFERS_FLATC_EXECUTABLE=${{ github.workspace }}/BinaryCache/flatbuffers/Release/flatc.exe + - name: Build firebase + run: cmake --build ${{ github.workspace }}/BinaryCache/firebase + - name: Install firebase + run: cmake --build ${{ github.workspace }}/BinaryCache/firebase --target install + - name: Install firebase (manual) + run: | + Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/firestore_errors.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/firestore_errors.h" + Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/geo_point.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/geo_point.h" + Copy-Item "${{ github.workspace }}/BinaryCache/firebase/external/src/firestore/Firestore/core/include/firebase/firestore/timestamp.h" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/include/firebase/firestore/timestamp.h" + + Write-Host "Copying static libraries ..." + $source = "${{ github.workspace }}/BinaryCache/firebase" + $libraries = Get-ChildItem -Path $source -File -Recurse -Filter *.a + foreach ($library in $libraries) { + $destination = Join-Path -Path "${{ github.workspace }}/BuildRoot/Library/firebase/usr/libs/android" -ChildPath $library.Name + Copy-Item -Path $library.FullName -Destination $destination -Force + Write-Host "... copied ${destination}" + } + - uses: actions/upload-artifact@v3 + with: + name: firebase-android-${{ matrix.arch }} + path: ${{ github.workspace }}/BuildRoot/Library/firebase