diff --git a/.gitignore b/.gitignore index d325bc25e1..30a2780847 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ __pycache__/ ### Gradle ### .gradle **/build/ +local.properties # Unencrypted secret files google-services.json @@ -20,6 +21,7 @@ gcs_key_file.json *_build/ *cmake-build-debug/ testing/test_framework/external/ +**/.externalNativeBuild/ # XCode user specific folders **/xcuserdata/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ba7b8b7ad..940a215228 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,9 @@ option(FIREBASE_INCLUDE_INSTALLATIONS option(FIREBASE_INCLUDE_MESSAGING "Include the Firebase Cloud Messaging library." ${FIREBASE_INCLUDE_LIBRARY_DEFAULT}) +option(FIREBASE_INCLUDE_PERFORMANCE + "Include the Firebase Performance library." + ${FIREBASE_INCLUDE_LIBRARY_DEFAULT}) option(FIREBASE_INCLUDE_REMOTE_CONFIG "Include the Firebase Remote Config library." ${FIREBASE_INCLUDE_LIBRARY_DEFAULT}) @@ -620,6 +623,9 @@ endif() if (FIREBASE_INCLUDE_MESSAGING) add_subdirectory(messaging) endif() +if (FIREBASE_INCLUDE_PERFORMANCE) + add_subdirectory(performance) +endif() if (FIREBASE_INCLUDE_REMOTE_CONFIG) add_subdirectory(remote_config) endif() diff --git a/ios_pod/Podfile b/ios_pod/Podfile index 643c021a30..08a5f8db06 100644 --- a/ios_pod/Podfile +++ b/ios_pod/Podfile @@ -14,6 +14,7 @@ target 'GetPods' do pod 'Firebase/Functions', '8.8.0' pod 'Firebase/Installations', '8.8.0' pod 'Firebase/Messaging', '8.8.0' + pod 'Firebase/Performance', '8.8.0' pod 'Firebase/RemoteConfig', '8.8.0' pod 'Firebase/Storage', '8.8.0' diff --git a/performance/CMakeLists.txt b/performance/CMakeLists.txt new file mode 100644 index 0000000000..0b2409f386 --- /dev/null +++ b/performance/CMakeLists.txt @@ -0,0 +1,143 @@ +# Copyright 2019 Google +# +# 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. + +# CMake file for the firebase_performance library + +# Common source files used by all platforms +set(common_SRCS + src/performance_common.cc) + +# Source files used by the Android implementation. +set(android_SRCS + ${performance_resources_source} + src/android/firebase_performance.cc + src/android/http_metric.cc + src/android/trace.cc) + +# Source files used by the iOS implementation. +set(ios_SRCS + src/ios/firebase_performance.mm + src/ios/http_metric.mm + src/ios/trace.mm) + +# Source files used by the desktop implementation. +set(desktop_SRCS + src/stubs/http_metric_stub.cc + src/stubs/performance_stub.cc + src/stubs/trace_stub.cc) + +if(ANDROID) + set(performance_platform_SRCS + "${android_SRCS}") +elseif(IOS) + set(performance_platform_SRCS + "${ios_SRCS}") +else() + set(performance_platform_SRCS + "${desktop_SRCS}") +endif() + +if(ANDROID OR IOS) + set(additional_include_DIR) + set(additional_link_LIB) + set(additional_DEFINES) +else() + set(additional_include_DIR + ${OPENSSL_INCLUDE_DIR}) + + set(additional_link_LIB + firebase_rest_lib + OpenSSL::SSL + OpenSSL::Crypto) + + set(additional_DEFINES + -DFIREBASE_TARGET_DESKTOP=1) +endif() + +if(MSVC) + set(additional_DEFINES + "${additional_DEFINES}" + -DWIN32_LEAN_AND_MEAN # Ensure that windows doesn't include winsock.h by + # default, as it can cause issues when libraries try + # to include winsock2.h later on in the process. + ) +endif() + +add_library(firebase_performance STATIC + ${common_SRCS} + ${performance_platform_SRCS}) + +set_property(TARGET firebase_performance PROPERTY FOLDER "Firebase Cpp") + +# Set up the dependency on Firebase App. +target_link_libraries(firebase_performance + PUBLIC + firebase_app + PRIVATE + ${additional_link_LIB} +) +# Public headers all refer to each other relative to the src/include directory, +# while private headers are relative to the entire C++ SDK directory. +target_include_directories(firebase_performance + PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/src/include + PRIVATE + ${FIREBASE_CPP_SDK_ROOT_DIR} + ${additional_include_DIR} +) +target_compile_definitions(firebase_performance + PRIVATE + -DINTERNAL_EXPERIMENTAL=1 + ${additional_DEFINES} +) +# Automatically include headers that might not be declared. +if(MSVC) + add_definitions(/FI"assert.h" /FI"string.h" /FI"stdint.h") +else() + add_definitions(-include assert.h -include string.h) +endif() + +if(ANDROID) + firebase_cpp_proguard_file(database) +elseif(IOS) + # Enable Automatic Reference Counting (ARC) and Bitcode. + target_compile_options(firebase_performance + PUBLIC "-fobjc-arc" "-fembed-bitcode") + target_link_libraries(firebase_performance + PUBLIC "-fembed-bitcode") + + setup_pod_headers( + firebase_performance + POD_NAMES + FirebaseCore + FirebasePerformance + ) + if (FIREBASE_XCODE_TARGET_FORMAT STREQUAL "frameworks") + set_target_properties(firebase_performance PROPERTIES + FRAMEWORK TRUE + ) + endif() +endif() + +if(FIREBASE_CPP_BUILD_TESTS) + # Add the tests subdirectory + add_subdirectory(tests) +endif() + +cpp_pack_library(firebase_performance "") +cpp_pack_public_headers() +if (NOT ANDROID AND NOT IOS) + cpp_pack_library(uv_a "deps/performance/external") + cpp_pack_library(libuWS "deps/performance/external") +endif() diff --git a/performance/build.gradle b/performance/build.gradle new file mode 100644 index 0000000000..c8b63ae117 --- /dev/null +++ b/performance/build.gradle @@ -0,0 +1,94 @@ +// Copyright 2019 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. + +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.3.3' + } +} +allprojects { + repositories { + google() + jcenter() + } +} + +apply plugin: 'com.android.library' + +ext { + firebaseAndroidStl = System.getenv('FIREBASE_ANDROID_STL') + firebaseAndroidStl = firebaseAndroidStl != null ? firebaseAndroidStl : '' +} + +android { + compileSdkVersion 28 + buildToolsVersion '28.0.3' + + sourceSets { + main { + manifest.srcFile '../android_build_files/AndroidManifest.xml' + } + } + + externalNativeBuild { + cmake { + path '../CMakeLists.txt' + } + } + + defaultConfig { + // This is the platform API where NativeActivity was introduced. + minSdkVersion 9 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + + buildTypes { + release { + minifyEnabled false + } + } + + externalNativeBuild { + cmake { + targets 'firebase_performance' + // Args are: Re-use app library prebuilt by app gradle project. + // Don't configure all the cmake subprojects. + // Only include needed project. + arguments '-DFIREBASE_CPP_USE_PRIOR_GRADLE_BUILD=ON', + '-DFIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF', + '-DFIREBASE_INCLUDE_PERFORMANCE=ON', + "-DFIREBASE_ANDROID_STL=${firebaseAndroidStl}" + } + } + } + + lintOptions { + abortOnError false + } +} + +dependencies { + implementation project(':app') +} +apply from: "$rootDir/android_build_files/android_abis.gradle" +apply from: "$rootDir/android_build_files/extract_and_dex.gradle" +apply from: "$rootDir/android_build_files/generate_proguard.gradle" +project.afterEvaluate { + generateProguardFile('performance') +} diff --git a/settings.gradle b/settings.gradle index 07828daea2..093aaf3aca 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,6 +17,7 @@ include ':app', ':installations', ':messaging', ':messaging:messaging_java', + ':performance', ':remote_config', ':storage', ':storage:storage_resources' \ No newline at end of file