@@ -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,45 @@ 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 ):
388
402
ios_framework_builder = os .path .join (
389
- sdk_dir , "build_scripts" , "ios" , "build.sh" )
403
+ sdk_dir , "build_scripts" , "ios" , "build.sh" )
390
404
391
405
framework_builder_args = [
392
406
ios_framework_builder ,
@@ -400,15 +414,15 @@ def _generate_makefiles_from_repo(sdk_dir):
400
414
# build required ios frameworks based on makefiles
401
415
def _build_ios_framework_from_repo (sdk_dir , api_config ):
402
416
ios_framework_builder = os .path .join (
403
- sdk_dir , "build_scripts" , "ios" , "build.sh" )
404
-
417
+ sdk_dir , "build_scripts" , "ios" , "build.sh" )
418
+
405
419
# build only required targets to save time
406
420
target = set ()
407
421
for framework in api_config .frameworks :
408
422
target .add (os .path .splitext (framework )[0 ])
409
423
# 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" )
424
+ # firebase_app will be built by other target as well
425
+ target .remove ("firebase" )
412
426
413
427
framework_builder_args = [
414
428
ios_framework_builder ,
@@ -421,10 +435,10 @@ def _build_ios_framework_from_repo(sdk_dir, api_config):
421
435
422
436
def _build_ios (
423
437
sdk_dir , ios_framework_exist , project_dir , root_dir , api_config , ios_sdk ):
438
+ """Builds an iOS application (.app, .ipa or both)."""
424
439
if not ios_framework_exist :
425
440
_build_ios_framework_from_repo (sdk_dir , api_config )
426
441
427
- """Builds an iOS application (.app, .ipa or both)."""
428
442
build_dir = os .path .join (project_dir , "ios_build" )
429
443
os .makedirs (build_dir )
430
444
@@ -475,7 +489,8 @@ def _build_ios(
475
489
ios_sdk = _IOS_SDK_DEVICE ,
476
490
configuration = "Debug" ))
477
491
478
- xcodebuild .generate_unsigned_ipa (output_dir = build_dir , configuration = "Debug" )
492
+ xcodebuild .generate_unsigned_ipa (
493
+ output_dir = build_dir , configuration = "Debug" )
479
494
480
495
481
496
# This script is responsible for copying shared files into the integration
0 commit comments