Skip to content

Make it easier to consume sub-libraries within util #1065

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

Merged
merged 1 commit into from
Apr 11, 2018
Merged
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
42 changes: 28 additions & 14 deletions Firestore/core/src/firebase/firestore/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ cc_library(
## assert and log

cc_library(
firebase_firestore_util_stdio
firebase_firestore_util_log_stdio
SOURCES
firebase_assert.h
assert_stdio.cc
log.h
log_stdio.cc
DEPENDS
firebase_firestore_util_base
Expand All @@ -42,9 +44,11 @@ cc_library(
)

cc_library(
firebase_firestore_util_apple
firebase_firestore_util_log_apple
SOURCES
firebase_assert.h
assert_apple.mm
log.h
log_apple.mm
string_apple.h
DEPENDS
Expand All @@ -53,20 +57,24 @@ cc_library(
EXCLUDE_FROM_ALL
)

# Export a dependency on the correct logging library for this platform. All
# buildable libraries are built and tested but only the best fit is exported.
if(APPLE)
list(APPEND UTIL_DEPENDS firebase_firestore_util_apple)
set(
FIREBASE_FIRESTORE_UTIL_LOG
firebase_firestore_util_log_apple
)
else()
list(APPEND UTIL_DEPENDS firebase_firestore_util_stdio)
set(
FIREBASE_FIRESTORE_UTIL_LOG
firebase_firestore_util_log_stdio
)
endif()


## secure_random

check_symbol_exists(arc4random stdlib.h HAVE_ARC4RANDOM)
cc_library(
firebase_firestore_util_arc4random
firebase_firestore_util_random_arc4random
SOURCES
secure_random_arc4random.cc
)
Expand All @@ -77,18 +85,24 @@ get_target_property(
)
check_include_files(openssl/rand.h HAVE_OPENSSL_RAND_H)
cc_library(
firebase_firestore_util_openssl
firebase_firestore_util_random_openssl
SOURCES
secure_random_openssl.cc
DEPENDS
OpenSSL::Crypto
)

if(HAVE_ARC4RANDOM)
list(APPEND UTIL_DEPENDS firebase_firestore_util_arc4random)
set(
FIREBASE_FIRESTORE_UTIL_RANDOM
firebase_firestore_util_random_arc4random
)

elseif(HAVE_OPENSSL_RAND_H)
list(APPEND UTIL_DEPENDS firebase_firestore_util_openssl)
set(
FIREBASE_FIRESTORE_UTIL_RANDOM
firebase_firestore_util_random_openssl
)

else()
message(FATAL_ERROR "No implementation for SecureRandom available.")
Expand All @@ -97,6 +111,7 @@ endif()


## main library

configure_file(
config.h.in
config.h
Expand All @@ -112,9 +127,7 @@ cc_library(
comparison.cc
comparison.h
config.h
firebase_assert.h
iterator_adaptors.h
log.h
ordered_code.cc
ordered_code.h
secure_random.h
Expand All @@ -126,7 +139,8 @@ cc_library(
string_util.cc
string_util.h
DEPENDS
${UTIL_DEPENDS}
firebase_firestore_util_base
absl_base
firebase_firestore_util_base
${FIREBASE_FIRESTORE_UTIL_LOG}
${FIREBASE_FIRESTORE_UTIL_RANDOM}
)
54 changes: 30 additions & 24 deletions Firestore/core/test/firebase/firestore/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,52 @@ set(CMAKE_CXX_EXTENSIONS ON)
# Required to allow 0 length printf style strings for testing purposes.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format-zero-length")

## assert and log

if(APPLE)
cc_test(
firebase_firestore_util_log_apple_test
SOURCES
assert_test.cc
log_test.cc
DEPENDS
firebase_firestore_util_log_apple
)
endif(APPLE)

cc_test(
firebase_firestore_util_log_stdio_test
SOURCES
assert_test.cc
log_test.cc
DEPENDS
firebase_firestore_util_log_stdio
)

## secure random

if(HAVE_ARC4RANDOM)
cc_test(
firebase_firestore_util_arc4random_test
firebase_firestore_util_random_arc4random_test
SOURCES
secure_random_test.cc
DEPENDS
firebase_firestore_util_arc4random
firebase_firestore_util_random_arc4random
)
endif()

if(HAVE_OPENSSL_RAND_H)
cc_test(
firebase_firestore_util_openssl_test
firebase_firestore_util_random_openssl_test
SOURCES
secure_random_test.cc
DEPENDS
firebase_firestore_util_openssl
firebase_firestore_util_random_openssl
)
endif()

## main library

cc_test(
firebase_firestore_util_test
SOURCES
Expand All @@ -56,23 +82,3 @@ cc_test(
firebase_firestore_util
gmock
)

if(APPLE)
cc_test(
firebase_firestore_util_apple_test
SOURCES
assert_test.cc
log_test.cc
DEPENDS
firebase_firestore_util_apple
)
endif(APPLE)

cc_test(
firebase_firestore_util_stdio_test
SOURCES
assert_test.cc
log_test.cc
DEPENDS
firebase_firestore_util_stdio
)