@@ -195,7 +195,7 @@ def main(argv):
195
195
196
196
if update_pod_repo and _IOS in platforms :
197
197
_run (["pod" , "repo" , "update" ])
198
-
198
+
199
199
config = config_reader .read_config ()
200
200
cmake_flags = _get_desktop_compiler_flags (FLAGS .compiler , config .compilers )
201
201
if _DESKTOP in platforms and FLAGS .use_vcpkg :
@@ -226,7 +226,7 @@ def main(argv):
226
226
227
227
228
228
def _build (
229
- testapp , platforms , api_config , output_dir , sdk_dir , ios_framework_exist ,
229
+ testapp , platforms , api_config , output_dir , sdk_dir , ios_framework_exist ,
230
230
timestamp , root_dir , ios_sdk , cmake_flags , execute_desktop_testapp ):
231
231
"""Builds one testapp on each of the specified platforms."""
232
232
testapp_dir = os .path .join (root_dir , api_config .testapp_path )
@@ -362,31 +362,46 @@ def _validate_android_environment_variables():
362
362
"""Checks environment variables that may be required for Android."""
363
363
# Ultimately we let the gradle build be the source of truth on what env vars
364
364
# are required, but try to repair holes and log warnings if we can't.
365
- logging .info ("Checking environment variables for the Android build" )
366
- if not os .environ .get (_ANDROID_NDK_HOME ):
367
- ndk_root = os .environ .get (_NDK_ROOT )
368
- if ndk_root : # Use NDK_ROOT as a backup for ANDROID_NDK_HOME
369
- os .environ [_ANDROID_NDK_HOME ] = ndk_root
370
- logging .info ("%s not found, using %s" , _ANDROID_NDK_HOME , _NDK_ROOT )
371
- else :
372
- logging .warning ("Neither %s nor %s is set." , _ANDROID_NDK_HOME , _NDK_ROOT )
365
+ android_home = os .environ .get (_ANDROID_HOME )
373
366
if not os .environ .get (_JAVA_HOME ):
374
367
logging .warning ("%s not set" , _JAVA_HOME )
375
368
if not os .environ .get (_ANDROID_SDK_HOME ):
376
- android_home = os .environ .get (_ANDROID_HOME )
377
369
if android_home : # Use ANDROID_HOME as backup for ANDROID_SDK_HOME
378
370
os .environ [_ANDROID_SDK_HOME ] = android_home
379
371
logging .info ("%s not found, using %s" , _ANDROID_SDK_HOME , _ANDROID_HOME )
380
372
else :
381
- logging .warning (
382
- "Neither %s nor %s is set" , _ANDROID_SDK_HOME , _ANDROID_HOME )
373
+ logging .warning ("Missing: %s and %s" , _ANDROID_SDK_HOME , _ANDROID_HOME )
374
+ # Different environments may have different NDK env vars specified. We look
375
+ # for these, in this order, and set the others to the first found.
376
+ # If none are set, we check the default location for the ndk.
377
+ ndk_path = None
378
+ ndk_vars = [_NDK_ROOT , _ANDROID_NDK_HOME ]
379
+ for env_var in ndk_vars :
380
+ val = os .environ .get (env_var )
381
+ if val :
382
+ ndk_path = val
383
+ break
384
+ if not ndk_path :
385
+ if android_home :
386
+ default_ndk_path = os .path .join (android_home , "ndk-bundle" )
387
+ if os .path .isdir (default_ndk_path ):
388
+ ndk_path = default_ndk_path
389
+ if ndk_path :
390
+ logging .info ("Found ndk: %s" , ndk_path )
391
+ for env_var in ndk_vars :
392
+ if os .environ .get (env_var ) != ndk_path :
393
+ logging .info ("Setting %s to %s" , env_var , ndk_path )
394
+ os .environ [env_var ] = ndk_path
395
+ else :
396
+ logging .warning ("No NDK env var set. Set one of %s" , ", " .join (ndk_vars ))
383
397
384
398
385
- # If sdk_dir contains no framework, consider it is Github repo, then
399
+ # If sdk_dir contains no framework, consider it is Github repo, then
386
400
# generate makefiles for ios frameworks
387
401
def _generate_makefiles_from_repo (sdk_dir ):
402
+ """Generates cmake makefiles for building iOS frameworks from SDK source."""
388
403
ios_framework_builder = os .path .join (
389
- sdk_dir , "build_scripts" , "ios" , "build.sh" )
404
+ sdk_dir , "build_scripts" , "ios" , "build.sh" )
390
405
391
406
framework_builder_args = [
392
407
ios_framework_builder ,
@@ -399,16 +414,19 @@ def _generate_makefiles_from_repo(sdk_dir):
399
414
400
415
# build required ios frameworks based on makefiles
401
416
def _build_ios_framework_from_repo (sdk_dir , api_config ):
417
+ """Builds iOS framework from SDK source."""
402
418
ios_framework_builder = os .path .join (
403
- sdk_dir , "build_scripts" , "ios" , "build.sh" )
404
-
419
+ sdk_dir , "build_scripts" , "ios" , "build.sh" )
420
+
405
421
# build only required targets to save time
406
422
target = set ()
423
+
407
424
for framework in api_config .frameworks :
425
+ # firebase_analytics.framework -> firebase_analytics
408
426
target .add (os .path .splitext (framework )[0 ])
409
427
# firebase is not a target in CMake, firebase_app is the target
410
- # firebase_app will be built by other target as well
411
- target .remove ("firebase" )
428
+ # firebase_app will be built by other target as well
429
+ target .remove ("firebase" )
412
430
413
431
framework_builder_args = [
414
432
ios_framework_builder ,
@@ -421,10 +439,10 @@ def _build_ios_framework_from_repo(sdk_dir, api_config):
421
439
422
440
def _build_ios (
423
441
sdk_dir , ios_framework_exist , project_dir , root_dir , api_config , ios_sdk ):
442
+ """Builds an iOS application (.app, .ipa or both)."""
424
443
if not ios_framework_exist :
425
444
_build_ios_framework_from_repo (sdk_dir , api_config )
426
445
427
- """Builds an iOS application (.app, .ipa or both)."""
428
446
build_dir = os .path .join (project_dir , "ios_build" )
429
447
os .makedirs (build_dir )
430
448
@@ -487,7 +505,8 @@ def _build_ios(
487
505
ios_sdk = _IOS_SDK_DEVICE ,
488
506
configuration = "Debug" ))
489
507
490
- xcodebuild .generate_unsigned_ipa (output_dir = build_dir , configuration = "Debug" )
508
+ xcodebuild .generate_unsigned_ipa (
509
+ output_dir = build_dir , configuration = "Debug" )
491
510
492
511
493
512
# This script is responsible for copying shared files into the integration
0 commit comments