15
15
# limitations under the License.
16
16
"""
17
17
Standalone self-sufficient (no external dependencies) python script that can ease
18
- building desktop apps depending on firebase , by either using the firebase cpp
19
- source (firebase-cpp-sdk github repo) or the prebuilt release firebase libraries.
18
+ building desktop apps depending on Firebase , by either using the Firebase cpp
19
+ source (firebase-cpp-sdk github repo) or the prebuilt release Firebase libraries.
20
20
21
21
Note that this script works with only Python3 (3.6+).
22
+ Also note, that since this script runs a cmake configure step, it is advised to
23
+ run it with a fresh clean build directory.
24
+
22
25
Known side effects:
23
- If building against firebase cpp source, this script might checkout a specific
26
+ If building against Firebase cpp source, this script might checkout a specific
24
27
branch on github containing vcpkg. This will not be required once vcpkg is in the
25
28
main branch.
26
29
27
30
Example usage:
28
- Let's say we want to build the quickstart cpp example for firebase database.
29
- As specified above, there are 2 options - build against the firebase source or
30
- prebuilt firebase libraries.
31
+ Let's say we want to build the quickstart cpp example for Firebase database.
32
+ As specified above, there are 2 options - build against the Firebase source or
33
+ prebuilt Firebase libraries.
31
34
32
- # Build against the firebase cpp sdk source
35
+ # Build against the Firebase cpp sdk source
33
36
python3 scripts/build_desktop_app_with_firebase.py --app_dir ~/quickstart-cpp/database/testapp
34
37
--sdk_dir . --build_dir build_source
35
38
36
39
(or)
37
40
38
- # Build against the prebuilt released firebase libraries
41
+ # Build against the prebuilt released Firebase libraries
39
42
python3 scripts/build_desktop_app_with_firebase.py --app_dir ~/quickstart-cpp/database/testapp
40
43
--sdk_dir ~/prebuilt/firebase_cpp_sdk_6.15.1/
41
44
--build_dir build_prebuilt
@@ -59,7 +62,7 @@ def is_path_valid_for_cmake(path):
59
62
return os .path .exists (os .path .join (path , 'CMakeLists.txt' ))
60
63
61
64
def is_sdk_path_source (sdk_dir ):
62
- """Validate if firebase sdk dir is firebase cpp source dir"""
65
+ """Validate if Firebase sdk dir is Firebase cpp source dir"""
63
66
# Not the most reliable way to detect if the sdk path is source or prebuilt but
64
67
# should work for our purpose.
65
68
return os .path .exists (os .path .join (sdk_dir , 'build_tools' ))
@@ -69,12 +72,12 @@ def validate_prebuilt_args(arch, config):
69
72
# Some options are not available when using prebuilt libraries"""
70
73
if platform .system () == 'Darwin' :
71
74
if arch == 'x86' or config == 'Debug' :
72
- raise ValueError ("Prebuilt mac firebase libraries are built for x64 and Release mode only. "
75
+ raise ValueError ("Prebuilt mac Firebase libraries are built for x64 and Release mode only. "
73
76
"Please fix the command line arguments and try again" )
74
77
75
78
if platform .system () == 'Linux' :
76
79
if config == 'Debug' :
77
- raise ValueError ("Prebuilt linux firebase libraries are built with Release mode only. "
80
+ raise ValueError ("Prebuilt linux Firebase libraries are built with Release mode only. "
78
81
"Please fix the --config command line argument and try again." )
79
82
80
83
def get_vcpkg_triplet (arch , msvc_runtime_library = 'static' ):
@@ -85,7 +88,7 @@ def get_vcpkg_triplet(arch, msvc_runtime_library='static'):
85
88
msvc_runtime_library (str): Runtime library for MSVC (eg: 'static', 'dynamic').
86
89
87
90
Raises:
88
- ValueError: If current OS is not win,mac or linux.
91
+ ValueError: If current OS is not win, mac or linux.
89
92
90
93
Returns:
91
94
(str): Triplet name.
@@ -110,7 +113,7 @@ def get_vcpkg_triplet(arch, msvc_runtime_library='static'):
110
113
return triplet_name
111
114
112
115
def build_source_vcpkg_dependencies (sdk_source_dir , arch , msvc_runtime_library ):
113
- """Build C++ dependencies for firebase source SDK using vcpkg.
116
+ """Build C++ dependencies for Firebase source SDK using vcpkg.
114
117
115
118
Args:
116
119
sdk_source_dir (str): Path to Firebase C++ source directory.
@@ -119,6 +122,7 @@ def build_source_vcpkg_dependencies(sdk_source_dir, arch, msvc_runtime_library):
119
122
"""
120
123
# TODO: Remove this once dev branch of firebase-cpp-sdk repo has been merged
121
124
# onto main branch. This is required because vcpkg lives only in dev branch currently.
125
+ # b/174141707
122
126
subprocess .run (['git' , 'checkout' , 'dev' ],
123
127
cwd = sdk_source_dir , check = True )
124
128
subprocess .run (['git' , 'pull' ], cwd = sdk_source_dir , check = True )
@@ -133,14 +137,14 @@ def build_source_vcpkg_dependencies(sdk_source_dir, arch, msvc_runtime_library):
133
137
def build_app_with_source (app_dir , sdk_source_dir , build_dir , arch ,
134
138
msvc_runtime_library = 'static' , config = None ,
135
139
target_format = None ):
136
- """Build desktop app directly against the firebase C++ SDK source.
140
+ """Build desktop app directly against the Firebase C++ SDK source.
137
141
138
- Since this invovles a cmake configure, it is advised to run this on a clean
142
+ Since this involves a cmake configure, it is advised to run this on a clean
139
143
build directory.
140
144
141
145
Args:
142
146
app_dir (str): Path to directory containing application's CMakeLists.txt.
143
- sdk_source_dir (str): Path to firebase C++ SDK source directory (root of github repo).
147
+ sdk_source_dir (str): Path to Firebase C++ SDK source directory (root of github repo).
144
148
build_dir (str): Output build directory.
145
149
arch (str): Platform Architecture (example: 'x64').
146
150
msvc_runtime_library (str): Runtime library for MSVC (eg: 'static', 'dynamic').
@@ -197,18 +201,18 @@ def build_app_with_source(app_dir, sdk_source_dir, build_dir, arch,
197
201
198
202
def build_app_with_prebuilt (app_dir , sdk_prebuilt_dir , build_dir , arch ,
199
203
msvc_runtime_library = 'static' , config = None ):
200
- """Build desktop app directly against the prebuilt firebase C++ libraries.
204
+ """Build desktop app directly against the prebuilt Firebase C++ libraries.
201
205
202
206
Since this invovles a cmake configure, it is advised to run this on a clean
203
207
build directory.
204
208
205
209
Args:
206
210
app_dir (str): Path to directory containing application's CMakeLists.txt.
207
- sdk_prebuilt_dir (str): Path to prebuilt firebase C++ libraries.
211
+ sdk_prebuilt_dir (str): Path to prebuilt Firebase C++ libraries.
208
212
build_dir (str): Output build directory.
209
- arch (str): Platform Architecture (example : 'x64').
213
+ arch (str): Platform Architecture (eg : 'x64').
210
214
msvc_runtime_library (str): Runtime library for MSVC (eg: 'static', 'dynamic').
211
- config (str): Release/Debug config.
215
+ config (str): Release/Debug config (eg: 'Release', 'Debug')
212
216
If its not specified, cmake's default is used (most likely Debug).
213
217
"""
214
218
@@ -248,7 +252,7 @@ def main():
248
252
sys .exit (1 )
249
253
250
254
if is_sdk_path_source (args .sdk_dir ):
251
- print ("SDK path provided is Firebase C++ source directory. Building..." )
255
+ print ("SDK path provided is a Firebase C++ source directory. Building..." )
252
256
build_source_vcpkg_dependencies (args .sdk_dir , args .arch , args .msvc_runtime_library )
253
257
build_app_with_source (args .app_dir , args .sdk_dir , args .build_dir , args .arch ,
254
258
args .msvc_runtime_library , args .config , args .target_format )
@@ -259,7 +263,7 @@ def main():
259
263
args .msvc_runtime_library , args .config )
260
264
261
265
print ("Build successful!\n "
262
- "Please find your executables in build directory: {0}" .format
266
+ "Please find your executables in the build directory: {0}" .format
263
267
(os .path .join (args .app_dir , args .build_dir )))
264
268
265
269
def parse_cmdline_args ():
0 commit comments