Skip to content

Commit

Permalink
Update to C++14. (firebase#1250)
Browse files Browse the repository at this point in the history
* Update CXX_STANDARD to 14.

* Add CMAKE_CXX_STANDARD_REQUIRED setting.

* Update C++ version in testapps.

* Upgrade to grpc 150 and C++ 14 for firestore (firebase#1182)

* Upgrade to grpc 150 and C++ 14 for firestore

* Add firestore_dep_source to workflow

* Use C++14 make_unique

* Ensure CXX14

* Formatting

* CXX required in test

* C++14 for xcode project

* Ensures lineendings on windows so we can apply patch files

* Fix build error

* Add readme note about c++14.

* Remove C++ version warning header.

---------

Co-authored-by: wu-hui <[email protected]>
  • Loading branch information
jonsimantov and wu-hui authored Apr 25, 2023
1 parent 4318a1d commit 7f5a572
Show file tree
Hide file tree
Showing 52 changed files with 90 additions and 141 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ on:
description: 'Optional: Packaging run # to build against?'
test_pull_request:
description: 'Optional: Pull request # to build and test? (With optional commit hash, separated by a colon. Specify the FULL hash.)'
firestore_dep_source:
description: 'Optional: Where to get firestore iOS SDK from: "RELEASED", "TIP" or "<git-commit> from firestore-ios-sdk"'

env:
triggerLabelPrefix: "tests-requested: "
Expand Down Expand Up @@ -330,6 +332,8 @@ jobs:
if [[ "${{ github.event.schedule }}" == "0 11 * * *" ]]; then
# at 3am PST/4am PDT. Running firestore desktop integration test aginst tip-of-tree ios repo
additional_flags+=(--cmake_flag=-DFIRESTORE_DEP_SOURCE=TIP)
elif [[ "${{ github.event.inputs.firestore_dep_source }}" ]]; then
additional_flags+=(--cmake_flag=-DFIRESTORE_DEP_SOURCE=${{ github.event.inputs.firestore_dep_source }})
fi
python scripts/gha/build_testapps.py --p Desktop \
--t ${{ needs.check_and_prepare.outputs.apis }} \
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

cmake_minimum_required (VERSION 3.1)

set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

# Turn on virtual folders for visual studio
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand Down
5 changes: 3 additions & 2 deletions admob/integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ set(FIREBASE_INTEGRATION_TEST_SRCS
# The include directory for the testapp.
include_directories(src)

# Integration test uses some features that require C++ 11, such as lambdas.
set (CMAKE_CXX_STANDARD 11)
# Firebase C++ SDK requires C++14.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

# Download and unpack googletest (and googlemock) at configure time
set(GOOGLETEST_ROOT ${CMAKE_CURRENT_LIST_DIR}/external/googletest)
Expand Down
1 change: 0 additions & 1 deletion admob/src/include/firebase/admob.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "firebase/admob/rewarded_video.h"
#include "firebase/admob/types.h"
#include "firebase/app.h"
#include "firebase/cpp_version_warning.h"
#include "firebase/internal/common.h"

#if !defined(DOXYGEN) && !defined(SWIG)
Expand Down
5 changes: 3 additions & 2 deletions analytics/integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ set(FIREBASE_INTEGRATION_TEST_SRCS
# The include directory for the testapp.
include_directories(src)

# Integration test uses some features that require C++ 11, such as lambdas.
set (CMAKE_CXX_STANDARD 11)
# Firebase C++ SDK requires C++14.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

# Download and unpack googletest (and googlemock) at configure time
set(GOOGLETEST_ROOT ${CMAKE_CURRENT_LIST_DIR}/external/googletest)
Expand Down
1 change: 0 additions & 1 deletion analytics/src/include/firebase/analytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <string>

#include "firebase/app.h"
#include "firebase/cpp_version_warning.h"
#include "firebase/future.h"
#include "firebase/internal/common.h"
#include "firebase/variant.h"
Expand Down
1 change: 0 additions & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ endif()

set(internal_HDRS
src/include/firebase/app.h
src/include/firebase/cpp_version_warning.h
src/include/firebase/future.h
src/include/firebase/internal/common.h
src/include/firebase/internal/future_impl.h
Expand Down
5 changes: 3 additions & 2 deletions app/integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ set(FIREBASE_INTEGRATION_TEST_SRCS
# The include directory for the testapp.
include_directories(src)

# Integration test uses some features that require C++ 11, such as lambdas.
set (CMAKE_CXX_STANDARD 11)
# Firebase C++ SDK requires C++14.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

# Download and unpack googletest (and googlemock) at configure time
set(GOOGLETEST_ROOT ${CMAKE_CURRENT_LIST_DIR}/external/googletest)
Expand Down
4 changes: 3 additions & 1 deletion app/rest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# CMake file for the firebase_rest_lib library

cmake_minimum_required (VERSION 3.1)
set (CMAKE_CXX_STANDARD 11)
# Firebase C++ SDK requires C++14.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

project(firebase_rest_lib NONE)
enable_language(C)
Expand Down
1 change: 0 additions & 1 deletion app/src/include/firebase/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#ifndef FIREBASE_APP_SRC_INCLUDE_FIREBASE_APP_H_
#define FIREBASE_APP_SRC_INCLUDE_FIREBASE_APP_H_

#include "cpp_version_warning.h"
#include "firebase/internal/platform.h"

#if FIREBASE_PLATFORM_ANDROID
Expand Down
21 changes: 0 additions & 21 deletions app/src/include/firebase/cpp_version_warning.h

This file was deleted.

5 changes: 3 additions & 2 deletions app_check/integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ set(FIREBASE_INTEGRATION_TEST_SRCS
# The include directory for the testapp.
include_directories(src)

# Integration test uses some features that require C++ 11, such as lambdas.
set (CMAKE_CXX_STANDARD 11)
# Firebase C++ SDK requires C++14.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

# Download and unpack googletest (and googlemock) at configure time
set(GOOGLETEST_ROOT ${CMAKE_CURRENT_LIST_DIR}/external/googletest)
Expand Down
1 change: 0 additions & 1 deletion app_check/src/include/firebase/app_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <string>

#include "firebase/app.h"
#include "firebase/cpp_version_warning.h"
#include "firebase/future.h"

namespace firebase {
Expand Down
5 changes: 3 additions & 2 deletions auth/integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ set(FIREBASE_INTEGRATION_TEST_SRCS
# The include directory for the testapp.
include_directories(src)

# Integration test uses some features that require C++ 11, such as lambdas.
set (CMAKE_CXX_STANDARD 11)
# Firebase C++ SDK requires C++14.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

# Download and unpack googletest (and googlemock) at configure time
set(GOOGLETEST_ROOT ${CMAKE_CURRENT_LIST_DIR}/external/googletest)
Expand Down
1 change: 0 additions & 1 deletion auth/src/include/firebase/auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "firebase/app.h"
#include "firebase/auth/user.h"
#include "firebase/cpp_version_warning.h"
#include "firebase/future.h"
#include "firebase/internal/common.h"

Expand Down
1 change: 1 addition & 0 deletions cmake/external/firestore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function(GetTag t)
DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR}
GIT_REPOSITORY "https://github.com/firebase/firebase-ios-sdk.git"
GIT_TAG ${t}
GIT_CONFIG "core.autocrlf=input"
GIT_SHALLOW "ON"

PREFIX ${PROJECT_BINARY_DIR}
Expand Down
5 changes: 3 additions & 2 deletions database/integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ set(FIREBASE_INTEGRATION_TEST_SRCS
# The include directory for the testapp.
include_directories(src)

# Integration test uses some features that require C++ 11, such as lambdas.
set (CMAKE_CXX_STANDARD 11)
# Firebase C++ SDK requires C++14.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

# Download and unpack googletest (and googlemock) at configure time
set(GOOGLETEST_ROOT ${CMAKE_CURRENT_LIST_DIR}/external/googletest)
Expand Down
1 change: 0 additions & 1 deletion database/src/include/firebase/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define FIREBASE_DATABASE_SRC_INCLUDE_FIREBASE_DATABASE_H_

#include "firebase/app.h"
#include "firebase/cpp_version_warning.h"
#include "firebase/database/common.h"
#include "firebase/database/data_snapshot.h"
#include "firebase/database/database_reference.h"
Expand Down
5 changes: 3 additions & 2 deletions dynamic_links/integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ set(FIREBASE_INTEGRATION_TEST_SRCS
# The include directory for the testapp.
include_directories(src)

# Integration test uses some features that require C++ 11, such as lambdas.
set (CMAKE_CXX_STANDARD 11)
# Firebase C++ SDK requires C++14.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

# Download and unpack googletest (and googlemock) at configure time
set(GOOGLETEST_ROOT ${CMAKE_CURRENT_LIST_DIR}/external/googletest)
Expand Down
1 change: 0 additions & 1 deletion dynamic_links/src/include/firebase/dynamic_links.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <string>

#include "firebase/app.h"
#include "firebase/cpp_version_warning.h"
#include "firebase/internal/common.h"

#if !defined(DOXYGEN) && !defined(SWIG)
Expand Down
5 changes: 3 additions & 2 deletions firestore/integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ set(FIREBASE_INTEGRATION_TEST_SRCS
# The include directory for the testapp.
include_directories(src)

# Integration test uses some features that require C++ 11, such as lambdas.
set (CMAKE_CXX_STANDARD 11)
# Firebase C++ SDK requires C++14.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

# Download and unpack googletest (and googlemock) at configure time
set(GOOGLETEST_ROOT ${CMAKE_CURRENT_LIST_DIR}/external/googletest)
Expand Down
5 changes: 3 additions & 2 deletions firestore/integration_test_internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ include_directories(${ABSEIL_CPP_ROOT})
# Allow testing internal Firebase APIs.
add_definitions(-DINTERNAL_EXPERIMENTAL)

# Integration test uses some features that require C++ 11, such as lambdas.
set (CMAKE_CXX_STANDARD 11)
# Firebase C++ SDK requires C++14.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version.

# Download and unpack googletest (and googlemock) at configure time
set(GOOGLETEST_ROOT ${CMAKE_CURRENT_LIST_DIR}/external/googletest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
Expand Down Expand Up @@ -723,7 +723,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "firestore/src/android/exception_android.h"
#include "firestore/src/android/firestore_android.h"
#include "firestore/src/android/promise_factory_android.h"
#include "firestore/src/common/make_unique.h"
#include "firestore/src/include/firebase/firestore.h"
#include "firestore/src/jni/env.h"
#include "firestore/src/jni/integer.h"
Expand Down Expand Up @@ -210,7 +209,7 @@ class TestCompletion : public TestCompletionBase<PublicType, InternalType> {
if (result == nullptr) {
result_.reset(nullptr);
} else {
result_ = make_unique<PublicType>(*result);
result_ = std::make_unique<PublicType>(*result);
}
}

Expand Down
3 changes: 1 addition & 2 deletions firestore/integration_test_internal/src/jni/env_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "app/meta/move.h"
#include "firestore/src/android/exception_android.h"
#include "firestore/src/common/macros.h"
#include "firestore/src/common/make_unique.h"
#include "firestore/src/jni/array.h"
#include "firestore_integration_test.h"
#include "gtest/gtest.h"
Expand All @@ -33,7 +32,7 @@ namespace jni {

class EnvTest : public FirestoreIntegrationTest {
public:
EnvTest() : env_(make_unique<Env>(GetEnv())) {}
EnvTest() : env_(std::make_unique<Env>(GetEnv())) {}

~EnvTest() override {
// Ensure that after the test is done that any pending exception is cleared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/

#include <chrono> // NOLINT(build/c++11)
#include <memory>
#include <thread> // NOLINT(build/c++11)

#include "absl/memory/memory.h"
#include "app_framework.h"
#include "firebase/app.h"
#include "firebase/firestore.h"
Expand All @@ -37,8 +37,8 @@ struct TestFriend {
static FirestoreInternal* CreateTestFirestoreInternal(App* app) {
#if !defined(__ANDROID__)
return new FirestoreInternal(
app, absl::make_unique<credentials::EmptyAuthCredentialsProvider>(),
absl::make_unique<credentials::EmptyAppCheckCredentialsProvider>());
app, std::make_unique<credentials::EmptyAuthCredentialsProvider>(),
std::make_unique<credentials::EmptyAppCheckCredentialsProvider>());
#else
return new FirestoreInternal(app);
#endif // !defined(__ANDROID__)
Expand Down
3 changes: 1 addition & 2 deletions firestore/src/android/firestore_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#include "firestore/src/android/wrapper.h"
#include "firestore/src/android/write_batch_android.h"
#include "firestore/src/common/hard_assert_common.h"
#include "firestore/src/common/make_unique.h"
#include "firestore/src/include/firebase/firestore.h"
#include "firestore/src/jni/array.h"
#include "firestore/src/jni/array_list.h"
Expand Down Expand Up @@ -285,7 +284,7 @@ FirestoreInternal::FirestoreInternal(App* app) {
FIREBASE_ASSERT(java_user_callback_executor.get() != nullptr);
user_callback_executor_ = java_user_callback_executor;

promises_ = make_unique<PromiseFactory<AsyncFn>>(this);
promises_ = std::make_unique<PromiseFactory<AsyncFn>>(this);
}

/* static */
Expand Down
3 changes: 1 addition & 2 deletions firestore/src/android/promise_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "firestore/src/android/exception_android.h"
#include "firestore/src/android/firestore_android.h"
#include "firestore/src/android/query_snapshot_android.h"
#include "firestore/src/common/make_unique.h"
#include "firestore/src/jni/env.h"
#include "firestore/src/jni/object.h"
#include "firestore/src/jni/task.h"
Expand Down Expand Up @@ -98,7 +97,7 @@ class Promise {
ReferenceCountedFutureImpl* impl,
Completion* completion)
: firestore_ref_(firestore_ref),
completer_(make_unique<Completer<PublicType, InternalType>>(
completer_(std::make_unique<Completer<PublicType, InternalType>>(
firestore_ref, impl, completion)),
impl_(impl) {}

Expand Down
37 changes: 0 additions & 37 deletions firestore/src/common/make_unique.h

This file was deleted.

Loading

0 comments on commit 7f5a572

Please sign in to comment.