Skip to content

Commit ea0437d

Browse files
committed
Integrate Latest @ 233815175
Changes to all ... - Convert the testapps to use CMake for Android builds and obtain dependencies from Gradle script. Changes to auth/testapp ... - Added additional debug information for previously-signed-in user. CL: 233815175
1 parent 30caa52 commit ea0437d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1462
-2055
lines changed

admob/testapp/CMakeLists.txt

Lines changed: 75 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -15,88 +15,97 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR})
1515
message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information")
1616
endif()
1717

18-
# Windows runtime mode, either MD or MT depending on whether you are using
19-
# /MD or /MT. For more information see:
20-
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
21-
set(MSVC_RUNTIME_MODE MD)
22-
23-
project(firebase_testapp)
24-
2518
# Sample source files.
2619
set(FIREBASE_SAMPLE_COMMON_SRCS
2720
src/main.h
2821
src/common_main.cc
2922
)
3023

31-
# Platform abstraction layer for the sample.
32-
set(FIREBASE_SAMPLE_DESKTOP_SRCS
33-
src/desktop/desktop_main.cc
34-
)
24+
# The include directory for the testapp.
25+
include_directories(src)
3526

3627
# Sample uses some features that require C++ 11, such as lambdas.
3728
set (CMAKE_CXX_STANDARD 11)
3829

39-
# Determine the path to the library based on the platform and configuration.
40-
if(APPLE)
41-
set(FIREBASE_SDK_LIBDIR ${FIREBASE_CPP_SDK_DIR}/libs/darwin/universal)
42-
set(ADDITIONAL_LIBS pthread)
43-
elseif(MSVC)
44-
if(${CMAKE_CL_64})
45-
set(MSVC_CPU x64)
46-
else()
47-
set(MSVC_CPU x86)
48-
endif()
49-
if(CMAKE_BUILD_TYPE EQUAL Release)
50-
set(MSVC_CONFIG Release)
51-
else()
52-
set(MSVC_CONFIG Debug)
53-
endif()
54-
set(MSVC_VS_VERSION VS2015)
55-
set(FIREBASE_SDK_LIBDIR
56-
${FIREBASE_CPP_SDK_DIR}/libs/windows/${MSVC_VS_VERSION}/${MSVC_RUNTIME_MODE}/${MSVC_CPU}/${MSVC_CONFIG})
30+
if(ANDROID)
31+
# Build an Android application.
32+
33+
# Source files used for the Android build.
34+
set(FIREBASE_SAMPLE_ANDROID_SRCS
35+
src/android/android_main.cc
36+
)
37+
38+
# Build native_app_glue as a static lib
39+
add_library(native_app_glue STATIC
40+
${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
41+
42+
# Export ANativeActivity_onCreate(),
43+
# Refer to: https://github.com/android-ndk/ndk/issues/381.
44+
set(CMAKE_SHARED_LINKER_FLAGS
45+
"${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
46+
47+
# Define the target as a shared library, as that is what gradle expects.
48+
set(target_name "android_main")
49+
add_library(${target_name} SHARED
50+
${FIREBASE_SAMPLE_ANDROID_SRCS}
51+
${FIREBASE_SAMPLE_COMMON_SRCS}
52+
)
53+
54+
target_link_libraries(${target_name}
55+
log android atomic native_app_glue
56+
)
57+
58+
target_include_directories(${target_name} PRIVATE
59+
${ANDROID_NDK}/sources/android/native_app_glue)
60+
5761
set(ADDITIONAL_LIBS)
5862
else()
59-
# The Firebase libraries are not built with glibcxx11, so disable the ABI.
60-
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
61-
set(LINUX_CPU x86_64)
62-
set(FIREBASE_SDK_LIBDIR ${FIREBASE_CPP_SDK_DIR}/libs/linux/${LINUX_CPU})
63-
set(ADDITIONAL_LIBS pthread)
64-
endif()
63+
# Build a desktop application.
6564

66-
# Link Firebase libraries.
67-
# NOTE: firebase_app needs to be after all other Firebase libraries.
68-
link_directories(${FIREBASE_SDK_LIBDIR})
69-
set(FIREBASE_LIBS firebase_admob firebase_app)
65+
# Windows runtime mode, either MD or MT depending on whether you are using
66+
# /MD or /MT. For more information see:
67+
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
68+
set(MSVC_RUNTIME_MODE MD)
7069

71-
# Add the Firebase include directory.
72-
set(FIREBASE_SDK_INCLUDEDIR ${FIREBASE_CPP_SDK_DIR}/include)
73-
include_directories(${FIREBASE_SDK_INCLUDEDIR})
70+
# Platform abstraction layer for the desktop sample.
71+
set(FIREBASE_SAMPLE_DESKTOP_SRCS
72+
src/desktop/desktop_main.cc
73+
)
7474

75-
# The include directory for the testapp.
76-
include_directories(src)
75+
set(target_name "desktop_testapp")
76+
add_executable(${target_name}
77+
${FIREBASE_SAMPLE_DESKTOP_SRCS}
78+
${FIREBASE_SAMPLE_COMMON_SRCS}
79+
)
7780

78-
add_executable(desktop_testapp
79-
${FIREBASE_SAMPLE_DESKTOP_SRCS}
80-
${FIREBASE_SAMPLE_COMMON_SRCS}
81-
)
82-
target_link_libraries(desktop_testapp
83-
${FIREBASE_LIBS}
84-
${ADDITIONAL_LIBS}
85-
)
81+
if(APPLE)
82+
set(ADDITIONAL_LIBS pthread)
83+
elseif(MSVC)
84+
set(ADDITIONAL_LIBS)
85+
else()
86+
set(ADDITIONAL_LIBS pthread)
87+
endif()
8688

87-
# If a config file is present, copy it into the binary location so that it's
88-
# possible to create the default Firebase app.
89-
set(FOUND_JSON_FILE FALSE)
90-
foreach(config "google-services-desktop.json" "google-services.json")
91-
if (EXISTS ${config})
92-
add_custom_command(
93-
TARGET desktop_testapp POST_BUILD
94-
COMMAND ${CMAKE_COMMAND} -E copy
95-
${config} $<TARGET_FILE_DIR:desktop_testapp>)
96-
set(FOUND_JSON_FILE TRUE)
97-
break()
89+
# If a config file is present, copy it into the binary location so that it's
90+
# possible to create the default Firebase app.
91+
set(FOUND_JSON_FILE FALSE)
92+
foreach(config "google-services-desktop.json" "google-services.json")
93+
if (EXISTS ${config})
94+
add_custom_command(
95+
TARGET ${target_name} POST_BUILD
96+
COMMAND ${CMAKE_COMMAND} -E copy
97+
${config} $<TARGET_FILE_DIR:${target_name}>)
98+
set(FOUND_JSON_FILE TRUE)
99+
break()
100+
endif()
101+
endforeach()
102+
if(NOT FOUND_JSON_FILE)
103+
message(WARNING "Failed to find either google-services-desktop.json or google-services.json. See the readme.md for more information.")
98104
endif()
99-
endforeach()
100-
if(NOT FOUND_JSON_FILE)
101-
message(WARNING "Failed to find either google-services-desktop.json or google-services.json. See the readme.md for more information.")
102105
endif()
106+
107+
# Add the Firebase libraries to the target using the function from the SDK.
108+
add_subdirectory(${FIREBASE_CPP_SDK_DIR} bin/ EXCLUDE_FROM_ALL)
109+
# Note that firebase_app needs to be last in the list.
110+
set(firebase_libs firebase_admob firebase_app)
111+
target_link_libraries(${target_name} "${firebase_libs}" ${ADDITIONAL_LIBS})

admob/testapp/Podfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ source 'https://github.com/CocoaPods/Specs.git'
22
platform :ios, '8.0'
33
# AdMob test application.
44
target 'testapp' do
5-
pod 'Firebase/Core', '5.14.0'
6-
pod 'Firebase/AdMob', '5.14.0'
5+
pod 'Firebase/Core', '5.15.0'
6+
pod 'Firebase/AdMob', '5.15.0'
77
end

admob/testapp/build.gradle

Lines changed: 30 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -21,75 +21,44 @@ allprojects {
2121

2222
apply plugin: 'com.android.application'
2323

24-
project.ext {
25-
// Configure the Firebase C++ SDK location.
26-
firebase_cpp_sdk_dir = System.getProperty('firebase_cpp_sdk.dir')
27-
if (firebase_cpp_sdk_dir == null || firebase_cpp_sdk_dir.isEmpty()) {
28-
firebase_cpp_sdk_dir = System.getenv('FIREBASE_CPP_SDK_DIR')
29-
if (firebase_cpp_sdk_dir == null || firebase_cpp_sdk_dir.isEmpty()) {
30-
if ((new File('firebase_cpp_sdk')).exists()) {
31-
firebase_cpp_sdk_dir = 'firebase_cpp_sdk'
32-
} else {
33-
throw new StopActionException(
34-
'firebase_cpp_sdk.dir property or the FIREBASE_CPP_SDK_DIR ' +
35-
'environment variable must be set to reference the Firebase C++ ' +
36-
'SDK install directory. This is used to configure static library ' +
37-
'and C/C++ include paths for the SDK.')
38-
}
39-
}
40-
}
41-
if (!(new File(firebase_cpp_sdk_dir)).exists()) {
42-
throw new StopActionException(
43-
sprintf('Firebase C++ SDK directory %s does not exist',
44-
firebase_cpp_sdk_dir))
45-
}
46-
}
47-
4824
android {
49-
compileSdkVersion 26
50-
buildToolsVersion '28.0.3'
51-
52-
sourceSets {
53-
main {
54-
jniLibs.srcDirs = ['libs']
55-
manifest.srcFile 'AndroidManifest.xml'
56-
java.srcDirs = ['src/android/java']
57-
res.srcDirs = ['res']
58-
}
59-
}
25+
compileSdkVersion 26
26+
buildToolsVersion '28.0.3'
6027

61-
defaultConfig {
62-
applicationId 'com.google.android.admob.testapp'
63-
minSdkVersion 16
64-
targetSdkVersion 26
65-
versionCode 1
66-
versionName '1.0'
67-
externalNativeBuild.ndkBuild {
68-
arguments "FIREBASE_CPP_SDK_DIR=${project.ext.firebase_cpp_sdk_dir}",
69-
"NDK_APPLICTION_MK=jni/Application.mk",
70-
sprintf("APP_PLATFORM=android-%d",
71-
android.defaultConfig.minSdkVersion.mApiLevel)
72-
}
28+
sourceSets {
29+
main {
30+
jniLibs.srcDirs = ['libs']
31+
manifest.srcFile 'AndroidManifest.xml'
32+
java.srcDirs = ['src/android/java']
33+
res.srcDirs = ['res']
7334
}
35+
}
7436

75-
externalNativeBuild.ndkBuild {
76-
path 'jni/Android.mk'
37+
defaultConfig {
38+
applicationId 'com.google.android.admob.testapp'
39+
minSdkVersion 16
40+
targetSdkVersion 26
41+
versionCode 1
42+
versionName '1.0'
43+
externalNativeBuild.cmake {
44+
arguments "-DFIREBASE_CPP_SDK_DIR=$gradle.firebase_cpp_sdk_dir"
7745
}
78-
79-
buildTypes {
80-
release {
81-
minifyEnabled true
82-
proguardFile getDefaultProguardFile('proguard-android.txt')
83-
proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/app.pro")
84-
proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/admob.pro")
85-
proguardFile file('proguard.pro')
86-
}
46+
}
47+
externalNativeBuild.cmake {
48+
path 'CMakeLists.txt'
49+
}
50+
buildTypes {
51+
release {
52+
minifyEnabled true
53+
proguardFile getDefaultProguardFile('proguard-android.txt')
54+
proguardFile file('proguard.pro')
8755
}
56+
}
8857
}
8958

90-
dependencies {
91-
implementation 'com.google.firebase:firebase-core:16.0.6'
92-
implementation 'com.google.firebase:firebase-ads:17.1.2'
59+
apply from: "$gradle.firebase_cpp_sdk_dir/Android/firebase_dependencies.gradle"
60+
firebaseCpp.dependencies {
61+
admob
9362
}
9463

9564
apply plugin: 'com.google.gms.google-services'

admob/testapp/jni/Android.mk

Lines changed: 0 additions & 57 deletions
This file was deleted.

admob/testapp/jni/Application.mk

Lines changed: 0 additions & 20 deletions
This file was deleted.

admob/testapp/settings.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2018 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
def firebase_cpp_sdk_dir = System.getProperty('firebase_cpp_sdk.dir')
16+
if (firebase_cpp_sdk_dir == null || firebase_cpp_sdk_dir.isEmpty()) {
17+
firebase_cpp_sdk_dir = System.getenv('FIREBASE_CPP_SDK_DIR')
18+
if (firebase_cpp_sdk_dir == null || firebase_cpp_sdk_dir.isEmpty()) {
19+
if ((new File('firebase_cpp_sdk')).exists()) {
20+
firebase_cpp_sdk_dir = 'firebase_cpp_sdk'
21+
} else {
22+
throw new StopActionException(
23+
'firebase_cpp_sdk.dir property or the FIREBASE_CPP_SDK_DIR ' +
24+
'environment variable must be set to reference the Firebase C++ ' +
25+
'SDK install directory. This is used to configure static library ' +
26+
'and C/C++ include paths for the SDK.')
27+
}
28+
}
29+
}
30+
if (!(new File(firebase_cpp_sdk_dir)).exists()) {
31+
throw new StopActionException(
32+
sprintf('Firebase C++ SDK directory %s does not exist',
33+
firebase_cpp_sdk_dir))
34+
}
35+
gradle.ext.firebase_cpp_sdk_dir = "$firebase_cpp_sdk_dir"
36+
includeBuild "$firebase_cpp_sdk_dir"

0 commit comments

Comments
 (0)