-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* kotlin侧添加webpack * python call js * 添加benchmark * python call http * 编辑打包脚本 * Update python-package.yml * 编辑打包脚本 * 编辑import策略 * 部分模型改为value class * Build DokkaGfm documents * 默认打包时编译JS * 重新去除静态库桥接方式 * 更新README * 重新添加docker镜像打包脚本 * fix --------- Co-authored-by: huangwenlong06 <huangwenlong06@meituan.com> Co-authored-by: ssttkkl <ssttkkl@users.noreply.github.com>
- Loading branch information
1 parent
fcfa6ee
commit 9f78ddd
Showing
29 changed files
with
3,188 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
build-logic/convention/src/main/kotlin/mahjongutils/buildlogic/KmpExeConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package mahjongutils.buildlogic | ||
|
||
import org.gradle.api.GradleException | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.ExtraPropertiesExtension | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.extra | ||
import org.gradle.kotlin.dsl.get | ||
import org.gradle.kotlin.dsl.getValue | ||
import org.gradle.kotlin.dsl.getting | ||
import org.gradle.kotlin.dsl.invoke | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile | ||
|
||
|
||
class KmpExeConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
with(pluginManager) { | ||
apply(KmpLibConventionPlugin::class.java) | ||
} | ||
configure<KotlinMultiplatformExtension> { | ||
jvm { | ||
mainRun { | ||
mainClass.set("MainKt") | ||
} | ||
} | ||
|
||
if (enableNative) { | ||
targets.withType<KotlinNativeTarget>().configureEach { | ||
binaries.executable() | ||
} | ||
} | ||
if (enableJs) { | ||
js(IR) { | ||
browser { | ||
binaries.executable() | ||
} | ||
nodejs { | ||
binaries.executable() | ||
} | ||
useCommonJs() | ||
} | ||
} | ||
if (enableWasm) { | ||
wasmJs { | ||
browser { | ||
binaries.executable() | ||
} | ||
nodejs { | ||
binaries.executable() | ||
} | ||
useCommonJs() | ||
compilations["main"].packageJson { | ||
name = "mahjong-utils-benchmark-wasm" | ||
customField( | ||
"author", mapOf( | ||
"name" to "ssttkkl", | ||
"email" to "huang.wen.long@hotmail.com" | ||
) | ||
) | ||
customField( | ||
"license", "MIT" | ||
) | ||
} | ||
} | ||
wasmWasi { | ||
nodejs { | ||
binaries.executable() | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (enableNative) { | ||
afterEvaluate { | ||
val hostOs = System.getProperty("os.name") | ||
val isMingwX64 = hostOs.startsWith("Windows") | ||
val isAarch64 = System.getProperty("os.arch") == "aarch64" | ||
val currentOsTargetName = when { | ||
hostOs == "Mac OS X" -> { | ||
if (isAarch64) { | ||
"macosArm64" | ||
} else { | ||
"macosX64" | ||
} | ||
} | ||
|
||
hostOs == "Linux" -> { | ||
if (isAarch64) { | ||
"linuxArm64" | ||
} else { | ||
"linuxX64" | ||
} | ||
} | ||
|
||
isMingwX64 -> "mingwX64" | ||
else -> throw GradleException("Host OS is not supported in Kotlin/Native.") | ||
} | ||
tasks.create("runDebugExecutableCurrentOs").apply { | ||
group = "run" | ||
dependsOn("runDebugExecutable" + currentOsTargetName.capitalize()) | ||
} | ||
tasks.create("runReleaseExecutableCurrentOs").apply { | ||
group = "run" | ||
dependsOn("runReleaseExecutable" + currentOsTargetName.capitalize()) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.