6
6
$(error BUILDTYPE must be Debug or Release)
7
7
endif
8
8
9
+ buildtype := $(shell echo "$(BUILDTYPE ) " | tr "[A-Z]" "[a-z]")
10
+
9
11
ifeq ($(shell uname -s) , Darwin)
10
12
HOST_PLATFORM = macos
11
13
HOST_PLATFORM_VERSION = $(shell uname -m)
@@ -450,39 +452,36 @@ test-node: node
450
452
451
453
# ### Android targets ###########################################################
452
454
453
- MBGL_ANDROID_ABIS = arm-v5;armeabi;9
454
- MBGL_ANDROID_ABIS += arm-v7;armeabi-v7a;9
455
- MBGL_ANDROID_ABIS += arm-v8;arm64-v8a;21
456
- MBGL_ANDROID_ABIS += x86;x86;9
457
- MBGL_ANDROID_ABIS += x86-64;x86_64;21
458
- MBGL_ANDROID_ABIS += mips;mips;9
455
+ MBGL_ANDROID_ABIS = arm-v5;armeabi
456
+ MBGL_ANDROID_ABIS += arm-v7;armeabi-v7a
457
+ MBGL_ANDROID_ABIS += arm-v8;arm64-v8a
458
+ MBGL_ANDROID_ABIS += x86;x86
459
+ MBGL_ANDROID_ABIS += x86-64;x86_64
460
+ MBGL_ANDROID_ABIS += mips;mips
459
461
460
- MBGL_ANDROID_BUILD_DIR = build/android-$1-$3/$(BUILDTYPE )
461
462
MBGL_ANDROID_LOCAL_WORK_DIR = /data/local/tmp/core-tests
462
463
MBGL_ANDROID_LIBDIR = lib$(if $(filter arm-v8 x86-64,$1) ,64)
463
464
MBGL_ANDROID_DALVIKVM = dalvikvm$(if $(filter arm-v8 x86-64,$1) ,64,32)
464
465
MBGL_ANDROID_APK_SUFFIX = $(if $(filter Release,$(BUILDTYPE ) ) ,release-unsigned,debug)
465
- MBGL_ANDROID_CORE_TEST_DIR = $(MBGL_ANDROID_BUILD_DIR ) /core-tests
466
+ MBGL_ANDROID_CORE_TEST_DIR = platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/$(buildtype ) /$2/core-tests
467
+ MBGL_ANDROID_GRADLE = ./gradlew --parallel --max-workers=$(JOBS ) -Pmapbox.buildtype=$(buildtype )
468
+
469
+ # Lists all devices, and extracts the identifiers, then obtains the ABI for every one.
470
+ # Some devices return \r\n, so we'll have to remove the carriage return before concatenating.
471
+ MBGL_ANDROID_ACTIVE_ARCHS = $(shell adb devices | sed '1d;/^\* /d;s/[[:space:]].* //' | xargs -n 1 -I DEV `type -P adb` -s DEV shell getprop ro.product.cpu.abi | tr -d '\r')
466
472
467
473
.PHONY : android-help
468
474
android-help :
469
475
@echo
470
476
@echo " Available Android architecture targets:"
471
477
@echo
472
- @echo " make android-arm-v5-9"
473
- @echo " (android-arm-v5)"
474
- @echo " make android-arm-v7-9"
475
- @echo " (android, android-arm-v7)"
476
- @echo " make android-arm-v8-21"
477
- @echo " (android-arm-v8)"
478
- @echo " make android-mips-9"
479
- @echo " (android-mips)"
480
- @echo " make android-mips-64-21"
481
- @echo " (android-mips-64)"
482
- @echo " make android-x86-9"
483
- @echo " (android-x86)"
484
- @echo " make android-x86-64-21"
485
- @echo " (android-x86-64)"
478
+ @echo " make android-arm-v5"
479
+ @echo " make android-arm-v7, make android"
480
+ @echo " make android-arm-v8"
481
+ @echo " make android-mips"
482
+ @echo " make android-mips-64"
483
+ @echo " make android-x86"
484
+ @echo " make android-x86-64"
486
485
@echo " make apackage"
487
486
@echo
488
487
@@ -491,50 +490,30 @@ android-style-code:
491
490
node platform/android/scripts/generate-style-code.js
492
491
style-code : android-style-code
493
492
493
+ # Configuration file for running CMake from Gradle within Android Studio.
494
+ platform/android/configuration.gradle :
495
+ @echo " ext {\n node = '` which node` '\n npm = '` which npm` '\n ccache = '` which ccache` '\n}" > $@
496
+
494
497
define ANDROID_RULES
495
498
# $1 = arm-v7 (short arch)
496
499
# $2 = armeabi-v7a (internal arch)
497
- # $3 = 9 (platform version)
498
-
499
- $(MBGL_ANDROID_BUILD_DIR ) /env.sh: $(BUILD_DEPS ) platform/android/scripts/ndk.sh
500
- @mkdir -p $(MBGL_ANDROID_BUILD_DIR )
501
- platform/android/scripts/ndk.sh $1 $2 $3 > $(MBGL_ANDROID_BUILD_DIR ) /env.sh.tmp && \
502
- mv $(MBGL_ANDROID_BUILD_DIR ) /env.sh.tmp $(MBGL_ANDROID_BUILD_DIR ) /env.sh
503
-
504
- $(MBGL_ANDROID_BUILD_DIR ) /build.ninja: $(MBGL_ANDROID_BUILD_DIR ) /env.sh platform/android/config.cmake
505
- # Invoke CMake twice to fix issues from double inclusion of toolchain.cmake on the first run.
506
- . $(MBGL_ANDROID_BUILD_DIR ) /env.sh && \
507
- ([ -f $(MBGL_ANDROID_BUILD_DIR ) /build.ninja ] || $$$${CMAKE} \
508
- -H. \
509
- -B"$(MBGL_ANDROID_BUILD_DIR ) " \
510
- -G"$$$${CMAKE_GENERATOR}" \
511
- $$$${CMAKE_ARGS} \
512
- -DCMAKE_BUILD_TYPE=$(BUILDTYPE ) \
513
- -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
514
- -DMBGL_PLATFORM=android \
515
- -DMASON_PLATFORM=android) && \
516
- $$$${CMAKE} \
517
- -H. \
518
- -B"$(MBGL_ANDROID_BUILD_DIR ) "
519
500
520
501
.PHONY: android-test-lib-$1
521
- android-test-lib-$1: $( MBGL_ANDROID_BUILD_DIR ) /build.ninja
522
- . $( MBGL_ANDROID_BUILD_DIR ) /env.sh && $$$${CMAKE} --build $( MBGL_ANDROID_BUILD_DIR ) -- $( NINJA_ARGS ) -j $( JOBS ) mbgl-test
502
+ android-test-lib-$1: platform/android/configuration.gradle
503
+ cd platform/android && $( MBGL_ANDROID_GRADLE ) -Pmapbox.abis=$2 -Pmapbox.with_test=true :MapboxGLAndroidSDKTestApp:assemble $( BUILDTYPE )
523
504
524
505
.PHONY: android-lib-$1
525
- android-lib-$1: $( MBGL_ANDROID_BUILD_DIR ) /build.ninja
526
- . $( MBGL_ANDROID_BUILD_DIR ) /env.sh && $$$${CMAKE} --build $( MBGL_ANDROID_BUILD_DIR ) -- $( NINJA_ARGS ) -j $( JOBS ) mapbox-gl example-custom-layer
506
+ android-lib-$1: platform/android/configuration.gradle
507
+ cd platform/android && $( MBGL_ANDROID_GRADLE ) -Pmapbox.abis=$2 :MapboxGLAndroidSDK:assemble $( BUILDTYPE )
527
508
528
509
.PHONY: android-$1
529
- android-$1: android-lib-$1
530
- cd platform/android && ./gradlew --parallel --max-workers= $( JOBS ) :MapboxGLAndroidSDKTestApp:assemble$(BUILDTYPE )
510
+ android-$1: platform/ android/configuration.gradle
511
+ cd platform/android && $( MBGL_ANDROID_GRADLE ) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:assemble$(BUILDTYPE )
531
512
532
513
.PHONY: android-core-test-$1
533
514
android-core-test-$1: android-test-lib-$1
534
- mkdir -p $(MBGL_ANDROID_CORE_TEST_DIR )
535
-
536
515
# Compile main sources and extract the classes (using the test app to get all transitive dependencies in one place)
537
- cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:assemble $( BUILDTYPE )
516
+ mkdir -p $( MBGL_ANDROID_CORE_TEST_DIR )
538
517
unzip -o platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-$(MBGL_ANDROID_APK_SUFFIX ) .apk classes.dex -d $(MBGL_ANDROID_CORE_TEST_DIR )
539
518
540
519
# Compile Test runner
@@ -555,8 +534,8 @@ run-android-core-test-$1-%: android-core-test-$1
555
534
# Push all needed files to the device
556
535
adb push $(MBGL_ANDROID_CORE_TEST_DIR ) /test.jar $(MBGL_ANDROID_LOCAL_WORK_DIR ) > /dev/null 2>&1
557
536
adb push test/fixtures $(MBGL_ANDROID_LOCAL_WORK_DIR ) /test > /dev/null 2>&1
558
- adb push $( MBGL_ANDROID_BUILD_DIR ) /stripped /libmapbox-gl.so $(MBGL_ANDROID_LOCAL_WORK_DIR ) > /dev/null 2>&1
559
- adb push $( MBGL_ANDROID_BUILD_DIR ) /stripped /libmbgl-test.so $(MBGL_ANDROID_LOCAL_WORK_DIR ) > /dev/null 2>&1
537
+ adb push platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/$2 /libmapbox-gl.so $(MBGL_ANDROID_LOCAL_WORK_DIR ) > /dev/null 2>&1
538
+ adb push platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/$2 /libmbgl-test.so $(MBGL_ANDROID_LOCAL_WORK_DIR ) > /dev/null 2>&1
560
539
561
540
# Kick off the tests
562
541
adb shell "export LD_LIBRARY_PATH=/system/$(MBGL_ANDROID_LIBDIR ) :$(MBGL_ANDROID_LOCAL_WORK_DIR ) && cd $(MBGL_ANDROID_LOCAL_WORK_DIR ) && $(MBGL_ANDROID_DALVIKVM ) -cp $(MBGL_ANDROID_LOCAL_WORK_DIR ) /test.jar Main --gtest_filter=$$* "
@@ -571,84 +550,100 @@ run-android-core-test-$1-%: android-core-test-$1
571
550
run-android-core-test-$1: run-android-core-test-$1-*
572
551
573
552
.PHONY: run-android-$1
574
- run-android-$1: android-$1
553
+ run-android-$1: platform/ android/configuration.gradle
575
554
adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
576
- cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:install$(BUILDTYPE ) && adb shell am start -n com.mapbox.mapboxsdk.testapp/.activity.FeatureOverviewActivity
555
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:install$(BUILDTYPE ) && adb shell am start -n com.mapbox.mapboxsdk.testapp/.activity.FeatureOverviewActivity
556
+
557
+ .PHONY: android-ui-test-$1
558
+ android-ui-test-$1: platform/android/configuration.gradle
559
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:assembleDebug :MapboxGLAndroidSDKTestApp:assembleAndroidTest
560
+
561
+ # This test assumes that you have Android Simulator started locally.
562
+ .PHONY: run-android-ui-test-$1
563
+ run-android-ui-test-$1: platform/android/configuration.gradle
564
+ adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
565
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:connectedAndroidTest
566
+
567
+ run-android-ui-test-$1-%: platform/android/configuration.gradle
568
+ adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
569
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class="$* "
577
570
578
- apackage: android-lib-$1
579
571
endef
580
572
581
573
# Explodes the arguments into individual variables
582
574
define ANDROID_RULES_INVOKER
583
- $(call ANDROID_RULES,$(word 1,$1) ,$(word 2,$1) , $( word 3,$1) )
575
+ $(call ANDROID_RULES,$(word 1,$1) ,$(word 2,$1) )
584
576
endef
585
577
586
578
$(foreach abi,$(MBGL_ANDROID_ABIS),$(eval $(call ANDROID_RULES_INVOKER,$(subst ;, ,$(abi)))))
587
579
588
580
.PHONY : android
589
581
android : android-arm-v7
590
582
583
+ .PHONY : android-lib
584
+ android-lib : android-lib-arm-v7
585
+
591
586
.PHONY : run-android
592
587
run-android : run-android-arm-v7
593
588
594
- .PHONY : run-android-unit -test
595
- run-android-unit -test :
596
- cd platform/ android && ./gradlew :MapboxGLAndroidSDKTestApp:testDebugUnitTest --continue
589
+ .PHONY : run-android-ui -test
590
+ run-android-ui -test : run-android-ui-test-arm-v7
591
+ run- android-ui-test- % : run-android-ui-test-arm-v7- %
597
592
598
- run-android-unit-test-% :
599
- cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:testDebugUnitTest --tests " $* "
593
+ # Java-only test
594
+ .PHONY : run-android-unit-test
595
+ run-android-unit-test : platform/android/configuration.gradle
596
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=none :MapboxGLAndroidSDKTestApp:testDebugUnitTest
597
+ run-android-unit-test-% : platform/android/configuration.gradle
598
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=none :MapboxGLAndroidSDKTestApp:testDebugUnitTest --tests " $* "
600
599
600
+ # Java-only test
601
601
.PHONY : run-android-wear-unit-test
602
- run-android-wear-unit-test :
603
- cd platform/android && ./gradlew :MapboxGLAndroidSDKWearTestApp:testDebugUnitTest --continue
602
+ run-android-wear-unit-test : platform/android/configuration.gradle
603
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=none :MapboxGLAndroidSDKWearTestApp:testDebugUnitTest
604
+ run-android-wear-unit-test-% : platform/android/configuration.gradle
605
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=none :MapboxGLAndroidSDKWearTestApp:testDebugUnitTest --tests " $* "
604
606
605
- .PHONY : android-ui-test
606
- android-ui-test :
607
- cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:assembleDebug --continue && ./gradlew :MapboxGLAndroidSDKTestApp:assembleAndroidTest --continue
608
-
609
- .PHONY : run-android-ui-test
610
- run-android-ui-test :
611
- adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
612
- cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:connectedAndroidTest -i
607
+ .PHONY : run-android-ui-test-aws
608
+ run-android-ui-test-aws : platform/android/configuration.gradle
609
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=all devicefarmUpload
613
610
614
- run-android-ui-test- % :
615
- adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
616
- cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class= " $* "
611
+ .PHONY : apackage
612
+ apackage : platform/android/configuration.gradle
613
+ cd platform/android && $( MBGL_ANDROID_GRADLE ) -Pmapbox.abis=all assemble $( BUILDTYPE )
617
614
618
- .PHONY : run-android-ui-test-aws
619
- run-android-ui-test-aws :
620
- cd platform/android && ./gradlew devicefarmUpload
615
+ # Uploads the compiled Android SDK to Maven
616
+ .PHONY : run-android-upload-archives
617
+ run-android-upload-archives : platform/android/configuration.gradle
618
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=all :MapboxGLAndroidSDK:uploadArchives
621
619
620
+ # Runs Android UI tests on all connected devices using Spoon
622
621
.PHONY : run-android-ui-test-spoon
623
- run-android-ui-test-spoon :
624
- cd platform/android && ./gradlew spoon
625
-
626
- .PHONY : apackage
627
- apackage :
628
- cd platform/android && ./gradlew --parallel --max-workers=$(JOBS ) assemble$(BUILDTYPE )
622
+ run-android-ui-test-spoon : platform/android/configuration.gradle
623
+ cd platform/android && $(MBGL_ANDROID_GRADLE ) -Pmapbox.abis=" $( MBGL_ANDROID_ACTIVE_ARCHS) " spoon
629
624
630
625
.PHONY : test-code-android
631
626
test-code-android :
632
627
node platform/android/scripts/generate-test-code.js
633
628
634
- .PHONY : android-ndk-stack
635
- android-ndk-stack :
636
- adb logcat | ndk-stack -sym build/android-arm-v7-9/Debug
637
-
638
629
.PHONY : android-checkstyle
639
- android-checkstyle :
640
- cd platform/android && ./gradlew checkstyle
630
+ android-checkstyle : platform/android/configuration.gradle
631
+ cd platform/android && $( MBGL_ANDROID_GRADLE ) -Pmapbox.abis=none checkstyle
641
632
642
633
.PHONY : android-javadoc
643
- android-javadoc :
644
- cd platform/android && ./gradlew :MapboxGLAndroidSDK:javadocrelease
634
+ android-javadoc : platform/android/configuration.gradle
635
+ cd platform/android && $( MBGL_ANDROID_GRADLE ) -Pmapbox.abis=none :MapboxGLAndroidSDK:javadocrelease
645
636
646
637
ifeq ($(HOST_PLATFORM ) , macos)
647
638
.PHONY : aproj
648
- aproj :
639
+ aproj : platform/android/configuration.gradle
649
640
open -b com.google.android.studio platform/android
650
641
endif
651
642
643
+ .PHONY : android-configuration
644
+ android-configuration : platform/android/configuration.gradle
645
+ cat platform/android/configuration.gradle
646
+
652
647
# ### Miscellaneous targets #####################################################
653
648
654
649
.PHONY : style-code
@@ -663,12 +658,12 @@ codestyle:
663
658
.PHONY : clean
664
659
clean :
665
660
-rm -rf ./build \
661
+ ./platform/android/configuration.gradle \
666
662
./platform/android/MapboxGLAndroidSDK/build \
663
+ ./platform/android/MapboxGLAndroidSDK/.externalNativeBuild \
667
664
./platform/android/MapboxGLAndroidSDKTestApp/build \
668
665
./platform/android/MapboxGLAndroidSDKWearTestApp/build \
669
666
./platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen \
670
- ./platform/android/MapboxGLAndroidSDK/src/main/jniLibs \
671
- ./platform/android/MapboxGLAndroidSDKTestApp/src/main/jniLibs \
672
667
./platform/android/MapboxGLAndroidSDK/src/main/assets
673
668
674
669
.PHONY : distclean
0 commit comments