Skip to content

Add cmake code for performance module #707

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

Open
wants to merge 2 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ __pycache__/
### Gradle ###
.gradle
**/build/
local.properties

# Unencrypted secret files
google-services.json
Expand All @@ -20,6 +21,7 @@ gcs_key_file.json
*_build/
*cmake-build-debug/
testing/test_framework/external/
**/.externalNativeBuild/

# XCode user specific folders
**/xcuserdata/
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make the default setting false for this? Since it's not officially supported, users should have to explicitly opt in to include this module (at least for now).

option(FIREBASE_INCLUDE_REMOTE_CONFIG
"Include the Firebase Remote Config library."
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions ios_pod/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this to the latest version, 8.9.1? (also resolve the merge conflict in this file)

pod 'Firebase/RemoteConfig', '8.8.0'
pod 'Firebase/Storage', '8.8.0'

Expand Down
143 changes: 143 additions & 0 deletions performance/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Copyright 2019 Google
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2021, as that was when the file was created

#
# 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()
94 changes: 94 additions & 0 deletions performance/build.gradle
Original file line number Diff line number Diff line change
@@ -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')
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ include ':app',
':installations',
':messaging',
':messaging:messaging_java',
':performance',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also like to ensure that this isn't included in Android builds by default; I think the simplest way is to leave this line commented-out? (You can add a note to the readme about how to enable it.)

':remote_config',
':storage',
':storage:storage_resources'