| 
									
										
										
										
											2019-09-02 17:31:51 -07:00
										 |  |  | apply plugin: 'com.android.library' | 
					
						
							| 
									
										
										
										
											2020-03-05 19:00:28 +01:00
										 |  |  | apply plugin: 'kotlin-android' | 
					
						
							| 
									
										
										
										
											2019-09-02 17:31:51 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | dependencies { | 
					
						
							| 
									
										
										
										
											2020-01-27 10:45:25 -08:00
										 |  |  |     implementation libraries.supportCoreUtils | 
					
						
							| 
									
										
										
										
											2020-02-25 11:18:36 -05:00
										 |  |  |     implementation libraries.kotlinStdLib | 
					
						
							| 
									
										
										
										
											2019-10-18 09:59:04 -07:00
										 |  |  |     implementation libraries.v4Support | 
					
						
							| 
									
										
										
										
											2019-09-02 17:31:51 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def pathToRootDir = "../../../../" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | android { | 
					
						
							|  |  |  |     compileSdkVersion versions.compileSdk | 
					
						
							|  |  |  |     buildToolsVersion versions.buildTools | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     defaultConfig { | 
					
						
							|  |  |  |         minSdkVersion versions.minSdk | 
					
						
							|  |  |  |         targetSdkVersion versions.targetSdk | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-28 16:32:45 -07:00
										 |  |  |     compileOptions { | 
					
						
							|  |  |  |         sourceCompatibility versions.javaVersion | 
					
						
							|  |  |  |         targetCompatibility versions.javaVersion | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-02 17:31:51 -07:00
										 |  |  |     lintOptions { | 
					
						
							|  |  |  |         abortOnError false | 
					
						
							|  |  |  |         disable 'MissingTranslation', 'UnusedResources' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     packagingOptions { | 
					
						
							|  |  |  |         exclude 'META-INF/LICENSE' | 
					
						
							|  |  |  |         exclude 'META-INF/NOTICE' | 
					
						
							| 
									
										
										
										
											2020-04-23 00:21:39 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // Should be uncommented for development purpose within Android Studio
 | 
					
						
							|  |  |  |         // doNotStrip '**/*.so'
 | 
					
						
							| 
									
										
										
										
											2019-09-02 17:31:51 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     sourceSets { | 
					
						
							|  |  |  |         main { | 
					
						
							|  |  |  |             manifest.srcFile 'AndroidManifest.xml' | 
					
						
							|  |  |  |             java.srcDirs = ['src'] | 
					
						
							|  |  |  |             res.srcDirs = ['res'] | 
					
						
							|  |  |  |             aidl.srcDirs = ['aidl'] | 
					
						
							|  |  |  |             assets.srcDirs = ['assets'] | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         debug.jniLibs.srcDirs = ['libs/debug'] | 
					
						
							|  |  |  |         release.jniLibs.srcDirs = ['libs/release'] | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     libraryVariants.all { variant -> | 
					
						
							|  |  |  |         variant.outputs.all { output -> | 
					
						
							|  |  |  |             output.outputFileName = "godot-lib.${variant.name}.aar" | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         def buildType = variant.buildType.name.capitalize() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 12:34:44 +01:00
										 |  |  |         def releaseTarget = buildType.toLowerCase() | 
					
						
							| 
									
										
										
										
											2019-09-22 22:23:59 -07:00
										 |  |  |         if (releaseTarget == null || releaseTarget == "") { | 
					
						
							|  |  |  |             throw new GradleException("Invalid build type: " + buildType) | 
					
						
							| 
									
										
										
										
											2019-09-02 17:31:51 -07:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-22 22:23:59 -07:00
										 |  |  |         if (!supportedAbis.contains(defaultAbi)) { | 
					
						
							|  |  |  |             throw new GradleException("Invalid default abi: " + defaultAbi) | 
					
						
							| 
									
										
										
										
											2019-09-02 17:31:51 -07:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-14 14:36:53 -08:00
										 |  |  |         // Find scons' executable path
 | 
					
						
							|  |  |  |         File sconsExecutableFile = null | 
					
						
							|  |  |  |         def sconsName = "scons" | 
					
						
							|  |  |  |         def sconsExts = (org.gradle.internal.os.OperatingSystem.current().isWindows() | 
					
						
							| 
									
										
										
										
											2021-01-30 20:13:01 +08:00
										 |  |  |             ? [".bat", ".cmd", ".ps1", ".exe"] | 
					
						
							| 
									
										
										
										
											2020-11-14 14:36:53 -08:00
										 |  |  |             : [""]) | 
					
						
							|  |  |  |         logger.lifecycle("Looking for $sconsName executable path") | 
					
						
							|  |  |  |         for (ext in sconsExts) { | 
					
						
							|  |  |  |             String sconsNameExt = sconsName + ext | 
					
						
							|  |  |  |             logger.lifecycle("Checking $sconsNameExt") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             sconsExecutableFile = org.gradle.internal.os.OperatingSystem.current().findInPath(sconsNameExt) | 
					
						
							|  |  |  |             if (sconsExecutableFile != null) { | 
					
						
							|  |  |  |                 // We're done!
 | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // Check all the options in path
 | 
					
						
							|  |  |  |             List<File> allOptions = org.gradle.internal.os.OperatingSystem.current().findAllInPath(sconsNameExt) | 
					
						
							|  |  |  |             if (!allOptions.isEmpty()) { | 
					
						
							|  |  |  |                 // Pick the first option and we're done!
 | 
					
						
							|  |  |  |                 sconsExecutableFile = allOptions.get(0) | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (sconsExecutableFile == null) { | 
					
						
							|  |  |  |             throw new GradleException("Unable to find executable path for the '$sconsName' command.") | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             logger.lifecycle("Found executable path for $sconsName: ${sconsExecutableFile.absolutePath}") | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-22 22:23:59 -07:00
										 |  |  |         // Creating gradle task to generate the native libraries for the default abi.
 | 
					
						
							|  |  |  |         def taskName = getSconsTaskName(buildType) | 
					
						
							|  |  |  |         tasks.create(name: taskName, type: Exec) { | 
					
						
							| 
									
										
										
										
											2020-11-14 14:36:53 -08:00
										 |  |  |             executable sconsExecutableFile.absolutePath | 
					
						
							| 
									
										
										
										
											2019-09-22 22:23:59 -07:00
										 |  |  |             args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${defaultAbi}", "-j" + Runtime.runtime.availableProcessors() | 
					
						
							| 
									
										
										
										
											2019-09-02 17:31:51 -07:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // Schedule the tasks so the generated libs are present before the aar file is packaged.
 | 
					
						
							|  |  |  |         tasks["merge${buildType}JniLibFolders"].dependsOn taskName | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |