Skip to content

Commit 4c217f4

Browse files
Merge branch 'dev' into feature/ak-simplify-flags
2 parents 2a28c4c + 38d860c commit 4c217f4

File tree

8 files changed

+106
-35
lines changed

8 files changed

+106
-35
lines changed

build_scripts/desktop/get_variant.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ arch=
3030
arch_win=
3131
debugmode=Release
3232
msvc_runtime_library=MD
33-
vs=VS2015
33+
vs=VS2019
3434
stl=c++
3535
linux_abi=legacy
3636

37-
for c in $(echo "${filename}" | tr "_.-" "\n\n\n"); do
37+
for c in $(echo "${filename}" | tr "[:upper:]" "[:lower:]" | tr "_.-" "\n\n\n"); do
3838
case $c in
3939
# Operating systems
4040
ios)
@@ -115,15 +115,9 @@ for c in $(echo "${filename}" | tr "_.-" "\n\n\n"); do
115115
release)
116116
debugmode=Release
117117
;;
118-
Release)
119-
debugmode=Release
120-
;;
121118
debug)
122119
debugmode=Debug
123120
;;
124-
Debug)
125-
debugmode=Debug
126-
;;
127121
# Android STL variant
128122
c++)
129123
stl=c++
@@ -143,6 +137,18 @@ for c in $(echo "${filename}" | tr "_.-" "\n\n\n"); do
143137
legacy)
144138
linux_abi=legacy
145139
;;
140+
vs2019)
141+
vs=VS2019
142+
;;
143+
vs2017)
144+
vs=VS2017
145+
;;
146+
vs2015)
147+
vs=VS2015
148+
;;
149+
vs2013)
150+
vs=VS2013
151+
;;
146152
esac
147153
done
148154

cmake/external/leveldb.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ if(TARGET leveldb)
1818
return()
1919
endif()
2020

21-
set(version 1.22)
21+
set(version e0d5f83a4f80060fe5b5d80025f0ad049bca430e)
2222

2323
ExternalProject_Add(
2424
leveldb
2525

2626
DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR}
2727
DOWNLOAD_NAME leveldb-${version}.tar.gz
2828
URL https://github.com/google/leveldb/archive/${version}.tar.gz
29-
URL_HASH SHA256=55423cac9e3306f4a9502c738a001e4a339d1a38ffbee7572d4a07d5d63949b2
3029

3130
PREFIX ${PROJECT_BINARY_DIR}
3231

cmake/external_rules.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ function(download_external_sources)
112112
"\n#include <stdlib.h>\n")
113113
endif()
114114
endif()
115+
if (FIREBASE_INCLUDE_FIRESTORE)
116+
# Tweak Firestore's included version of leveldb to match our own.
117+
file(INSTALL "${PROJECT_SOURCE_DIR}/cmake/external/leveldb.cmake"
118+
DESTINATION "${PROJECT_BINARY_DIR}/external/src/firestore/cmake/external")
119+
endif()
115120
endif()
116121
endfunction()
117122

firestore/CMakeLists.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ set(android_SRCS
162162
src/jni/throwable.h
163163
src/jni/traits.h)
164164

165-
set(ios_SRCS
165+
set(ios_and_desktop_SRCS
166166
src/ios/collection_reference_ios.cc
167167
src/ios/collection_reference_ios.h
168168
src/ios/converter_ios.h
@@ -203,13 +203,24 @@ set(wrapper_assertions_SRCS
203203
src/common/wrapper_assertions.cc
204204
src/common/wrapper_assertions.h)
205205

206+
set(ios_only_SRCS
207+
src/ios/create_firebase_metadata_provider_apple.mm)
208+
209+
set(desktop_only_SRCS
210+
src/ios/create_firebase_metadata_provider_desktop.cc
211+
src/ios/firebase_metadata_provider_desktop.cc)
212+
206213
if(ANDROID)
207214
set(firestore_platform_SRCS "${android_SRCS}")
208215

209216
else()
210-
# The iOS implementation is actually portable to desktop environments as
211-
# well.
212-
set(firestore_platform_SRCS "${ios_SRCS}")
217+
if (IOS)
218+
set(firestore_platform_SRCS "${ios_and_desktop_SRCS}" "${ios_only_SRCS}")
219+
else()
220+
# The iOS implementation is actually portable to desktop environments as
221+
# well.
222+
set(firestore_platform_SRCS "${ios_and_desktop_SRCS}" "${desktop_only_SRCS}")
223+
endif()
213224
endif()
214225

215226
add_library(firebase_firestore STATIC
@@ -268,10 +279,17 @@ else()
268279
)
269280
endif()
270281

282+
set(FIREBASE_FIRESTORE_CPP_DEFINES -DINTERNAL_EXPERIMENTAL=1)
283+
284+
if (WIN32 AND NOT ANDROID AND NOT IOS)
285+
# On Windows, gRPC gives a compiler error in firebase_metadata_provider_desktop.cc
286+
# unless _WIN32_WINNT is defined to this value (0x0600, Windows Vista).
287+
set(FIREBASE_FIRESTORE_CPP_DEFINES ${FIREBASE_FIRESTORE_CPP_DEFINES} -D_WIN32_WINNT=0x0600)
288+
endif()
271289

272290
target_compile_definitions(firebase_firestore
273291
PRIVATE
274-
-DINTERNAL_EXPERIMENTAL=1
292+
${FIREBASE_FIRESTORE_CPP_DEFINES}
275293
)
276294

277295
if(ANDROID)

release_build_files/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ elseif(MSVC)
4545
else()
4646
set(MSVC_CONFIG Debug)
4747
endif()
48-
set(MSVC_VS_VERSION VS2015)
48+
set(MSVC_VS_VERSION VS2019)
4949
set(FIREBASE_SDK_LIBDIR
5050
${FIREBASE_CPP_SDK_DIR}/libs/windows/${MSVC_VS_VERSION}/${MSVC_RUNTIME_MODE}/${MSVC_CPU}/${MSVC_CONFIG})
5151
else()

release_build_files/readme.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ Firebase Instance ID (stub) | firebase_instance_id.lib
413413
Firebase Cloud Messaging (stub) | firebase_messaging.lib
414414
| firebase_app.lib
415415

416-
The provided libraries have been tested using Visual Studio 2015 and 2017. When
416+
The provided libraries have been tested using Visual Studio 2019. When
417417
building C++ desktop apps on Windows, you will need to link the following
418418
Windows SDK libraries (consult your compiler documentation for more
419419
information):
@@ -562,6 +562,15 @@ code.
562562
### 7.0.0
563563
- Changes
564564
- General (iOS): iOS SDKs are now built using Xcode 11.7.
565+
- General (Desktop): Windows libraries are now built using Visual
566+
Studio 2019. While VS 2019 is binary-compatible with VS 2015 and
567+
VS 2017, you must use VS 2019 or newer to link the desktop SDK.
568+
The libraries have been moved from libs/windows/VS2015 to
569+
libs/windows/VS2019 to reflect this.
570+
- General (Desktop): Linux libraries are now built with both the
571+
C++11 ABI and the legacy ABI. The libraries have been moved
572+
from libs/linux/${arch} to libs/linux/${arch}/legacy and
573+
libs/linux/${arch}/cxx11 to reflect this.
565574
- AdMob (Android): Fix a JNI error when initializing without Firebase App.
566575
- Analytics: Remove deprecated SetMinimumSessionDuration call.
567576
- Installations: Added Installations SDK. See [Documentations](http://firebase.google.com/docs/reference/cpp/namespace/firebase/installations) for

scripts/gha/build_testapps.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,12 @@ def _summarize_results(testapps, platforms, failures, output_dir):
311311

312312

313313
def _build_desktop(sdk_dir, cmake_flags):
314-
_run(["cmake", ".", "-DFIREBASE_CPP_SDK_DIR=" + sdk_dir] + cmake_flags)
315-
_run(["cmake", "--build", "."])
314+
cmake_configure_cmd = ["cmake", ".", "-DCMAKE_BUILD_TYPE=Debug",
315+
"-DFIREBASE_CPP_SDK_DIR=" + sdk_dir]
316+
if utils.is_windows_os():
317+
cmake_configure_cmd += ["-A", "x64"]
318+
_run(cmake_configure_cmd + cmake_flags)
319+
_run(["cmake", "--build", ".", "--config", "Debug"])
316320

317321

318322
def _get_desktop_compiler_flags(compiler, compiler_table):

scripts/merge_libraries.py

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,20 @@
9595
"two libraries. C++ symbols in the appropriate namespaces will be renamed "
9696
"even if they are external. Otherwise, only symbols defined in the library "
9797
"are renamed.")
98+
flags.DEFINE_bool(
99+
"skip_creating_archives", False,
100+
"Skip creating archive files (.a or .lib) and instead just leave the object "
101+
"files (.o or .obj) in the output directory.")
98102

99103
# Never rename 'std::' by default when --auto_hide_cpp_namespaces is enabled.
100104
IMPLICIT_CPP_NAMESPACES_TO_IGNORE = {"std"}
101105

102106
DEFAULT_ENCODING = "ascii"
103107

108+
# Once a binutils command fails due to an ambiguous target, use this explicit target
109+
# when running all subsequent binutils commands.
110+
binutils_force_target_format = None
111+
104112

105113
class Demangler(object):
106114
"""Spins up a C++ demangler and pipes symboles to/from it to demangle them.
@@ -258,19 +266,20 @@ def create_archive(output_archive_file, object_files, old_archive=None):
258266
Empty list if there are no errors, or error text if there was an error.
259267
"""
260268
errors = []
261-
if old_archive:
269+
if old_archive and FLAGS.platform != "windows":
262270
# Copy the old archive to the new archive, then clear the files from it.
263271
# This preserves the file format of the old archive file.
272+
# On Windows, we'll always create a new archive.
264273
shutil.copy(old_archive, output_archive_file)
265274
(old_contents, errors) = list_objects_in_archive(output_archive_file)
266-
run_command(
275+
run_binutils_command(
267276
[FLAGS.binutils_ar_cmd, "d", output_archive_file] + old_contents,
268277
errors)
269-
run_command(
278+
run_binutils_command(
270279
[FLAGS.binutils_ar_cmd, "rs", output_archive_file] + object_files,
271280
errors)
272281
else:
273-
run_command(
282+
run_binutils_command(
274283
[FLAGS.binutils_ar_cmd, "rcs", output_archive_file] + object_files,
275284
errors)
276285

@@ -738,7 +747,17 @@ def run_binutils_command(cmdline, error_output=None, ignore_errors=False):
738747
Returns:
739748
A list of lines of text of the command's stdout.
740749
"""
741-
output = run_command(cmdline, error_output, True)
750+
global binutils_force_target_format
751+
if binutils_force_target_format:
752+
# Once we've had to force the format once, assume all subsequent
753+
# files use the same format. Also we will need to explicitly specify this
754+
# format when creating an archive with "ar".
755+
# If we've never had to force a format, let binutils autodetect.
756+
output = run_command([cmdline[0]] + ["--target=%s" % binutils_force_target_format] + cmdline[1:],
757+
error_output, ignore_errors)
758+
else:
759+
# Otherwise, if we've never had to force a format, use the default.
760+
output = run_command(cmdline, error_output, True)
742761
if error_output and not output:
743762
# There are some expected errors: "Bad value" or "File format is ambiguous".
744763
#
@@ -748,20 +767,22 @@ def run_binutils_command(cmdline, error_output=None, ignore_errors=False):
748767
# depending on whether the file is 32-bit or 64-bit.
749768
#
750769
# Line 0: filename.o: Bad value
751-
if error_output and "Bad value" in error_output[0]:
770+
if not binutils_force_target_format and error_output and "Bad value" in error_output[0]:
752771
# Workaround for MIPS, force elf32-little and/or elf64-little.
753772
error_output = []
754773
logging.debug("Bad value when running %s %s",
755774
os.path.basename(cmdline[0]), " ".join(cmdline[1:]))
756775
logging.debug("Retrying with --target=elf32-little")
757776
output = run_command([cmdline[0]] + ["--target=elf32-little"] +
758777
cmdline[1:], error_output, True)
778+
binutils_force_target_format='elf32-little'
759779
if error_output:
760780
# Oops, it wasn't 32-bit, try 64-bit instead.
761781
error_output = []
762782
logging.debug("Retrying with --target=elf64-little")
763783
output = run_command([cmdline[0]] + ["--target=elf64-little"] +
764784
cmdline[1:], error_output, ignore_errors)
785+
binutils_force_target_format='elf64-little'
765786
# In other cases, we sometimes get an expected error about ambiguous file
766787
# format, which also includes a list of matching formats:
767788
#
@@ -770,7 +791,7 @@ def run_binutils_command(cmdline, error_output=None, ignore_errors=False):
770791
#
771792
# If this occurs, we will run the command again, passing in the
772793
# target format that we believe we should use instead.
773-
elif (len(error_output) >= 2 and
794+
elif not binutils_force_target_format and (len(error_output) >= 2 and
774795
"ile format is ambiguous" in error_output[0]):
775796
m = re.search("Matching formats: (.+)", error_output[1])
776797
if m:
@@ -783,14 +804,14 @@ def run_binutils_command(cmdline, error_output=None, ignore_errors=False):
783804
BINUTILS_PREFERRED_FORMAT_PREFIX_IF_AMBIGUOUS[FLAGS.platform])
784805
]
785806
# Or if for some reason none was found, just take the default (first).
786-
retry_format = (preferred_formats[0]
787-
if len(preferred_formats) > 0
788-
else all_formats[0])
807+
binutils_force_target_format=(preferred_formats[0]
808+
if len(preferred_formats) > 0
809+
else all_formats[0])
789810
error_output = []
790-
logging.debug("Ambiguous file format when running %s %s",
791-
os.path.basename(cmdline[0]), " ".join(cmdline[1:]))
792-
logging.debug("Retrying with --target=%s", retry_format)
793-
output = run_command([cmdline[0]] + ["--target=%s" % retry_format] + cmdline[1:],
811+
logging.debug("Ambiguous file format when running %s %s (%s)",
812+
os.path.basename(cmdline[0]), " ".join(cmdline[1:]), ", ".join(all_formats))
813+
logging.debug("Retrying with --target=%s", binutils_force_target_format)
814+
output = run_command([cmdline[0]] + ["--target=%s" % binutils_force_target_format] + cmdline[1:],
794815
error_output, ignore_errors)
795816
if error_output and not ignore_errors:
796817
# If we failed any other way, or if the second run failed, bail.
@@ -1014,8 +1035,17 @@ def main(argv):
10141035
if os.path.isfile(output_path):
10151036
os.remove(output_path)
10161037

1017-
logging.debug("Creating output archive %s", output_path)
1018-
create_archive(output_path, all_obj_files, input_path[1])
1038+
if (FLAGS.skip_creating_archives):
1039+
output_path_dir = output_path + ".dir"
1040+
logging.debug("Copying object files to %s", output_path_dir)
1041+
if not os.path.exists(output_path_dir):
1042+
os.makedirs(output_path_dir)
1043+
for obj_file in all_obj_files:
1044+
logging.debug("Copy %s to %s" % (obj_file, os.path.join(output_path_dir, os.path.basename(obj_file))))
1045+
shutil.copyfile(obj_file, os.path.join(output_path_dir, os.path.basename(obj_file)))
1046+
else:
1047+
logging.debug("Creating output archive %s", output_path)
1048+
create_archive(output_path, all_obj_files, input_path[1])
10191049

10201050
shutdown_cache()
10211051

0 commit comments

Comments
 (0)