first commit
This commit is contained in:
		
						commit
						1b1cd2e064
					
				
					 175 changed files with 7095 additions and 0 deletions
				
			
		
							
								
								
									
										23
									
								
								src-tauri/gen/android/buildSrc/build.gradle.kts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src-tauri/gen/android/buildSrc/build.gradle.kts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | |||
| plugins { | ||||
|     `kotlin-dsl` | ||||
| } | ||||
| 
 | ||||
| gradlePlugin { | ||||
|     plugins { | ||||
|         create("pluginsForCoolKids") { | ||||
|             id = "rust" | ||||
|             implementationClass = "RustPlugin" | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| repositories { | ||||
|     google() | ||||
|     mavenCentral() | ||||
| } | ||||
| 
 | ||||
| dependencies { | ||||
|     compileOnly(gradleApi()) | ||||
|     implementation("com.android.tools.build:gradle:8.0.0") | ||||
| } | ||||
| 
 | ||||
|  | @ -0,0 +1,52 @@ | |||
| import java.io.File | ||||
| import org.apache.tools.ant.taskdefs.condition.Os | ||||
| import org.gradle.api.DefaultTask | ||||
| import org.gradle.api.GradleException | ||||
| import org.gradle.api.logging.LogLevel | ||||
| import org.gradle.api.tasks.Input | ||||
| import org.gradle.api.tasks.TaskAction | ||||
| 
 | ||||
| open class BuildTask : DefaultTask() { | ||||
|     @Input | ||||
|     var rootDirRel: String? = null | ||||
|     @Input | ||||
|     var target: String? = null | ||||
|     @Input | ||||
|     var release: Boolean? = null | ||||
| 
 | ||||
|     @TaskAction | ||||
|     fun assemble() { | ||||
|         val executable = """/Users/aok/.cargo/bin/cargo-tauri"""; | ||||
|         try { | ||||
|             runTauriCli(executable) | ||||
|         } catch (e: Exception) { | ||||
|             if (Os.isFamily(Os.FAMILY_WINDOWS)) { | ||||
|                 runTauriCli("$executable.cmd") | ||||
|             } else { | ||||
|                 throw e; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     fun runTauriCli(executable: String) { | ||||
|         val rootDirRel = rootDirRel ?: throw GradleException("rootDirRel cannot be null") | ||||
|         val target = target ?: throw GradleException("target cannot be null") | ||||
|         val release = release ?: throw GradleException("release cannot be null") | ||||
|         val args = listOf("tauri", "android", "android-studio-script"); | ||||
| 
 | ||||
|         project.exec { | ||||
|             workingDir(File(project.projectDir, rootDirRel)) | ||||
|             executable(executable) | ||||
|             args(args) | ||||
|             if (project.logger.isEnabled(LogLevel.DEBUG)) { | ||||
|                 args("-vv") | ||||
|             } else if (project.logger.isEnabled(LogLevel.INFO)) { | ||||
|                 args("-v") | ||||
|             } | ||||
|             if (release) { | ||||
|                 args("--release") | ||||
|             } | ||||
|             args(listOf("--target", target)) | ||||
|         }.assertNormalExitValue() | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,85 @@ | |||
| import com.android.build.api.dsl.ApplicationExtension | ||||
| import org.gradle.api.DefaultTask | ||||
| import org.gradle.api.Plugin | ||||
| import org.gradle.api.Project | ||||
| import org.gradle.kotlin.dsl.configure | ||||
| import org.gradle.kotlin.dsl.get | ||||
| 
 | ||||
| const val TASK_GROUP = "rust" | ||||
| 
 | ||||
| open class Config { | ||||
|     lateinit var rootDirRel: String | ||||
| } | ||||
| 
 | ||||
| open class RustPlugin : Plugin<Project> { | ||||
|     private lateinit var config: Config | ||||
| 
 | ||||
|     override fun apply(project: Project) = with(project) { | ||||
|         config = extensions.create("rust", Config::class.java) | ||||
| 
 | ||||
|         val defaultAbiList = listOf("arm64-v8a", "armeabi-v7a", "x86", "x86_64"); | ||||
|         val abiList = (findProperty("abiList") as? String)?.split(',') ?: defaultAbiList | ||||
| 
 | ||||
|         val defaultArchList = listOf("arm64", "arm", "x86", "x86_64"); | ||||
|         val archList = (findProperty("archList") as? String)?.split(',') ?: defaultArchList | ||||
| 
 | ||||
|         val targetsList = (findProperty("targetList") as? String)?.split(',') ?: listOf("aarch64", "armv7", "i686", "x86_64") | ||||
| 
 | ||||
|         extensions.configure<ApplicationExtension> { | ||||
|             @Suppress("UnstableApiUsage") | ||||
|             flavorDimensions.add("abi") | ||||
|             productFlavors { | ||||
|                 create("universal") { | ||||
|                     dimension = "abi" | ||||
|                     ndk { | ||||
|                         abiFilters += abiList | ||||
|                     } | ||||
|                 } | ||||
|                 defaultArchList.forEachIndexed { index, arch -> | ||||
|                     create(arch) { | ||||
|                         dimension = "abi" | ||||
|                         ndk { | ||||
|                             abiFilters.add(defaultAbiList[index]) | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         afterEvaluate { | ||||
|             for (profile in listOf("debug", "release")) { | ||||
|                 val profileCapitalized = profile.replaceFirstChar { it.uppercase() } | ||||
|                 val buildTask = tasks.maybeCreate( | ||||
|                     "rustBuildUniversal$profileCapitalized", | ||||
|                     DefaultTask::class.java | ||||
|                 ).apply { | ||||
|                     group = TASK_GROUP | ||||
|                     description = "Build dynamic library in $profile mode for all targets" | ||||
|                 } | ||||
| 
 | ||||
|                 tasks["mergeUniversal${profileCapitalized}JniLibFolders"].dependsOn(buildTask) | ||||
| 
 | ||||
|                 for (targetPair in targetsList.withIndex()) { | ||||
|                     val targetName = targetPair.value | ||||
|                     val targetArch = archList[targetPair.index] | ||||
|                     val targetArchCapitalized = targetArch.replaceFirstChar { it.uppercase() } | ||||
|                     val targetBuildTask = project.tasks.maybeCreate( | ||||
|                         "rustBuild$targetArchCapitalized$profileCapitalized", | ||||
|                         BuildTask::class.java | ||||
|                     ).apply { | ||||
|                         group = TASK_GROUP | ||||
|                         description = "Build dynamic library in $profile mode for $targetArch" | ||||
|                         rootDirRel = config.rootDirRel | ||||
|                         target = targetName | ||||
|                         release = profile == "release" | ||||
|                     } | ||||
| 
 | ||||
|                     buildTask.dependsOn(targetBuildTask) | ||||
|                     tasks["merge$targetArchCapitalized${profileCapitalized}JniLibFolders"].dependsOn( | ||||
|                         targetBuildTask | ||||
|                     ) | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue