@@ -958,8 +958,29 @@ public void CasingOnJavaLangObject ()
958
958
}
959
959
}
960
960
961
+ static object [ ] GenerateJavaStubsAndAssemblyData ( ) => new object [ ] {
962
+ new object [ ] {
963
+ true , // isRelease
964
+ true , // useNativeRuntimeLinkingMode
965
+ } ,
966
+
967
+ new object [ ] {
968
+ true , // isRelease
969
+ false , // useNativeRuntimeLinkingMode
970
+ } ,
971
+
972
+ new object [ ] {
973
+ false , // isRelease
974
+ false , // useNativeRuntimeLinkingMode
975
+ } ,
976
+
977
+ // Configuration for debug build and native runtime linking is not used, since
978
+ // runtime linking happens only in release builds
979
+ } ;
980
+
961
981
[ Test ]
962
- public void GenerateJavaStubsAndAssembly ( [ Values ( true , false ) ] bool isRelease )
982
+ [ TestCaseSource ( nameof ( GenerateJavaStubsAndAssemblyData ) ) ]
983
+ public void GenerateJavaStubsAndAssembly ( bool isRelease , bool useNativeRuntimeLinkingMode )
963
984
{
964
985
var targets = new [ ] {
965
986
"_GenerateJavaStubs" ,
@@ -968,6 +989,7 @@ public void GenerateJavaStubsAndAssembly ([Values (true, false)] bool isRelease)
968
989
var proj = new XamarinAndroidApplicationProject {
969
990
IsRelease = isRelease ,
970
991
} ;
992
+ proj . SetProperty ( "_AndroidEnableNativeRuntimeLinking" , useNativeRuntimeLinkingMode . ToString ( ) ) ;
971
993
proj . SetAndroidSupportedAbis ( "armeabi-v7a" ) ;
972
994
proj . OtherBuildItems . Add ( new AndroidItem . AndroidEnvironment ( "Foo.txt" ) {
973
995
TextContent = ( ) => "Foo=Bar" ,
@@ -978,7 +1000,7 @@ public void GenerateJavaStubsAndAssembly ([Values (true, false)] bool isRelease)
978
1000
foreach ( var target in targets ) {
979
1001
Assert . IsFalse ( b . Output . IsTargetSkipped ( target ) , $ "`{ target } ` should *not* be skipped!") ;
980
1002
}
981
- AssertAssemblyFilesInFileWrites ( proj , b ) ;
1003
+ AssertAssemblyFilesInFileWrites ( proj , b , useNativeRuntimeLinkingMode ) ;
982
1004
983
1005
// Change C# file and AndroidEvironment file
984
1006
proj . MainActivity += Environment . NewLine + "// comment" ;
@@ -988,30 +1010,40 @@ public void GenerateJavaStubsAndAssembly ([Values (true, false)] bool isRelease)
988
1010
foreach ( var target in targets ) {
989
1011
Assert . IsFalse ( b . Output . IsTargetSkipped ( target ) , $ "`{ target } ` should *not* be skipped!") ;
990
1012
}
991
- AssertAssemblyFilesInFileWrites ( proj , b ) ;
1013
+ AssertAssemblyFilesInFileWrites ( proj , b , useNativeRuntimeLinkingMode ) ;
992
1014
993
1015
// No changes
994
1016
Assert . IsTrue ( b . Build ( proj ) , "third build should have succeeded." ) ;
995
1017
foreach ( var target in targets ) {
996
1018
Assert . IsTrue ( b . Output . IsTargetSkipped ( target ) , $ "`{ target } ` should be skipped!") ;
997
1019
}
998
- AssertAssemblyFilesInFileWrites ( proj , b ) ;
1020
+ AssertAssemblyFilesInFileWrites ( proj , b , useNativeRuntimeLinkingMode ) ;
999
1021
}
1000
1022
}
1001
1023
1002
- readonly string [ ] ExpectedAssemblyFiles = new [ ] {
1003
- Path . Combine ( "android" , "environment.armeabi-v7a.o" ) ,
1004
- Path . Combine ( "android" , "environment.armeabi-v7a.ll" ) ,
1005
- Path . Combine ( "android" , "typemaps.armeabi-v7a.o" ) ,
1006
- Path . Combine ( "android" , "typemaps.armeabi-v7a.ll" ) ,
1007
- Path . Combine ( "app_shared_libraries" , "armeabi-v7a" , "libxamarin-app.so" )
1008
- } ;
1024
+ List < string > GetExpectedAssemblyFiles ( bool useNativeRuntimeLinkingMode )
1025
+ {
1026
+ var ret = new List < string > {
1027
+ Path . Combine ( "android" , "environment.armeabi-v7a.o" ) ,
1028
+ Path . Combine ( "android" , "environment.armeabi-v7a.ll" ) ,
1029
+ Path . Combine ( "android" , "typemaps.armeabi-v7a.o" ) ,
1030
+ Path . Combine ( "android" , "typemaps.armeabi-v7a.ll" )
1031
+ } ;
1032
+
1033
+ if ( useNativeRuntimeLinkingMode ) {
1034
+ ret . Add ( Path . Combine ( "app_shared_libraries" , "armeabi-v7a" , "libmonodroid-unified.so" ) ) ;
1035
+ } else {
1036
+ ret . Add ( Path . Combine ( "app_shared_libraries" , "armeabi-v7a" , "libxamarin-app.so" ) ) ;
1037
+ }
1038
+
1039
+ return ret ;
1040
+ }
1009
1041
1010
- void AssertAssemblyFilesInFileWrites ( XamarinAndroidApplicationProject proj , ProjectBuilder b )
1042
+ void AssertAssemblyFilesInFileWrites ( XamarinAndroidApplicationProject proj , ProjectBuilder b , bool useNativeRuntimeLinkingMode )
1011
1043
{
1012
1044
var intermediate = Path . Combine ( Root , b . ProjectDirectory , proj . IntermediateOutputPath ) ;
1013
1045
var lines = File . ReadAllLines ( Path . Combine ( intermediate , $ "{ proj . ProjectName } .csproj.FileListAbsolute.txt") ) ;
1014
- foreach ( var file in ExpectedAssemblyFiles ) {
1046
+ foreach ( var file in GetExpectedAssemblyFiles ( useNativeRuntimeLinkingMode ) ) {
1015
1047
var path = Path . Combine ( intermediate , file ) ;
1016
1048
CollectionAssert . Contains ( lines , path , $ "{ file } is not in FileWrites!") ;
1017
1049
FileAssert . Exists ( path ) ;
0 commit comments