Skip to content

Commit 6811831

Browse files
committed
addressed PR comments
1 parent 80fce3a commit 6811831

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

scripts/build_desktop_app_with_firebase.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,30 @@
1515
# limitations under the License.
1616
"""
1717
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.
2020
2121
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+
2225
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
2427
branch on github containing vcpkg. This will not be required once vcpkg is in the
2528
main branch.
2629
2730
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.
3134
32-
# Build against the firebase cpp sdk source
35+
# Build against the Firebase cpp sdk source
3336
python3 scripts/build_desktop_app_with_firebase.py --app_dir ~/quickstart-cpp/database/testapp
3437
--sdk_dir . --build_dir build_source
3538
3639
(or)
3740
38-
# Build against the prebuilt released firebase libraries
41+
# Build against the prebuilt released Firebase libraries
3942
python3 scripts/build_desktop_app_with_firebase.py --app_dir ~/quickstart-cpp/database/testapp
4043
--sdk_dir ~/prebuilt/firebase_cpp_sdk_6.15.1/
4144
--build_dir build_prebuilt
@@ -59,7 +62,7 @@ def is_path_valid_for_cmake(path):
5962
return os.path.exists(os.path.join(path, 'CMakeLists.txt'))
6063

6164
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"""
6366
# Not the most reliable way to detect if the sdk path is source or prebuilt but
6467
# should work for our purpose.
6568
return os.path.exists(os.path.join(sdk_dir, 'build_tools'))
@@ -69,12 +72,12 @@ def validate_prebuilt_args(arch, config):
6972
# Some options are not available when using prebuilt libraries"""
7073
if platform.system() == 'Darwin':
7174
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. "
7376
"Please fix the command line arguments and try again")
7477

7578
if platform.system() == 'Linux':
7679
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. "
7881
"Please fix the --config command line argument and try again.")
7982

8083
def get_vcpkg_triplet(arch, msvc_runtime_library='static'):
@@ -85,7 +88,7 @@ def get_vcpkg_triplet(arch, msvc_runtime_library='static'):
8588
msvc_runtime_library (str): Runtime library for MSVC (eg: 'static', 'dynamic').
8689
8790
Raises:
88-
ValueError: If current OS is not win,mac or linux.
91+
ValueError: If current OS is not win, mac or linux.
8992
9093
Returns:
9194
(str): Triplet name.
@@ -110,7 +113,7 @@ def get_vcpkg_triplet(arch, msvc_runtime_library='static'):
110113
return triplet_name
111114

112115
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.
114117
115118
Args:
116119
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):
119122
"""
120123
# TODO: Remove this once dev branch of firebase-cpp-sdk repo has been merged
121124
# onto main branch. This is required because vcpkg lives only in dev branch currently.
125+
# b/174141707
122126
subprocess.run(['git', 'checkout', 'dev'],
123127
cwd=sdk_source_dir, check=True)
124128
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):
133137
def build_app_with_source(app_dir, sdk_source_dir, build_dir, arch,
134138
msvc_runtime_library='static', config=None,
135139
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.
137141
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
139143
build directory.
140144
141145
Args:
142146
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).
144148
build_dir (str): Output build directory.
145149
arch (str): Platform Architecture (example: 'x64').
146150
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,
197201

198202
def build_app_with_prebuilt(app_dir, sdk_prebuilt_dir, build_dir, arch,
199203
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.
201205
202206
Since this invovles a cmake configure, it is advised to run this on a clean
203207
build directory.
204208
205209
Args:
206210
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.
208212
build_dir (str): Output build directory.
209-
arch (str): Platform Architecture (example: 'x64').
213+
arch (str): Platform Architecture (eg: 'x64').
210214
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')
212216
If its not specified, cmake's default is used (most likely Debug).
213217
"""
214218

@@ -248,7 +252,7 @@ def main():
248252
sys.exit(1)
249253

250254
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...")
252256
build_source_vcpkg_dependencies(args.sdk_dir, args.arch, args.msvc_runtime_library)
253257
build_app_with_source(args.app_dir, args.sdk_dir, args.build_dir, args.arch,
254258
args.msvc_runtime_library, args.config, args.target_format)
@@ -259,7 +263,7 @@ def main():
259263
args.msvc_runtime_library, args.config)
260264

261265
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
263267
(os.path.join(args.app_dir, args.build_dir)))
264268

265269
def parse_cmdline_args():

scripts/gha/build_desktop.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ def cmake_configure(build_dir, arch, msvc_runtime_library='static',
180180
cmd.append('-A')
181181
cmd.append('Win32') if arch == 'x86' else cmd.append('x64')
182182

183-
# Use our special cmake option for /MD (dynamic).
184-
# If this option is not specified, the default value is /MT (static).
183+
# Use our special cmake flag to specify /MD vs /MT
185184
if msvc_runtime_library == "static":
186185
cmd.append('-DMSVC_RUNTIME_LIBRARY_STATIC=ON')
187186

0 commit comments

Comments
 (0)