diff --git a/skiko/build.gradle.kts b/skiko/build.gradle.kts index fa5b49136..beb46eb03 100644 --- a/skiko/build.gradle.kts +++ b/skiko/build.gradle.kts @@ -610,6 +610,8 @@ project.tasks.withType().config tasks.findByName("publishSkikoWasmRuntimePublicationToComposeRepoRepository") ?.dependsOn("publishWasmJsPublicationToComposeRepoRepository") +tasks.findByName("publishSkikoWasmRuntimePublicationToMavenLocal") + ?.dependsOn("publishWasmJsPublicationToMavenLocal") tasks.withType().configureEach { diff --git a/skiko/buildSrc/src/main/kotlin/properties.kt b/skiko/buildSrc/src/main/kotlin/properties.kt index b9830b813..3cb2ec7cc 100644 --- a/skiko/buildSrc/src/main/kotlin/properties.kt +++ b/skiko/buildSrc/src/main/kotlin/properties.kt @@ -126,7 +126,8 @@ class SkikoProperties(private val myProject: Project) { val deployVersion: String get() { val main = if (isRelease) planeDeployVersion else "$planeDeployVersion-SNAPSHOT" - val metadata = if (buildType == SkiaBuildType.DEBUG) "+debug" else "" + var metadata = if (buildType == SkiaBuildType.DEBUG) "+debug" else "" + metadata += if (isWasmBuildWithProfiling) "+profiling" else "" return main + metadata } @@ -136,6 +137,9 @@ class SkikoProperties(private val myProject: Project) { val buildType: SkiaBuildType get() = if (myProject.findProperty("skiko.debug") == "true") SkiaBuildType.DEBUG else SkiaBuildType.RELEASE + val isWasmBuildWithProfiling: Boolean + get() = myProject.findProperty("skiko.wasm.withProfiling") == "true" + val targetArch: Arch get() = myProject.findProperty("skiko.arch")?.toString()?.let(Arch::byName) ?: hostArch diff --git a/skiko/buildSrc/src/main/kotlin/tasks/configuration/CommonTasksConfiguration.kt b/skiko/buildSrc/src/main/kotlin/tasks/configuration/CommonTasksConfiguration.kt index 63f570df6..ee1ca75e7 100644 --- a/skiko/buildSrc/src/main/kotlin/tasks/configuration/CommonTasksConfiguration.kt +++ b/skiko/buildSrc/src/main/kotlin/tasks/configuration/CommonTasksConfiguration.kt @@ -96,9 +96,10 @@ fun skiaPreprocessorFlags(os: OS, buildType: SkiaBuildType): Array { "-DSK_BUILD_FOR_LINUX", "-D_GLIBCXX_USE_CXX11_ABI=0" ) - OS.Wasm -> listOf( - "-DSKIKO_WASM" - ) + OS.Wasm -> mutableListOf().apply { + add("-DSKIKO_WASM") + // add("-sSUPPORT_LONGJMP=wasm") // TODO(o.karpovich): enable when skia is built with this flag (CMP-6628) + } OS.Android -> listOf( "-DSK_BUILD_FOR_ANDROID" ) diff --git a/skiko/buildSrc/src/main/kotlin/tasks/configuration/WasmTasksConfiguration.kt b/skiko/buildSrc/src/main/kotlin/tasks/configuration/WasmTasksConfiguration.kt index 9457f16db..041d4b331 100644 --- a/skiko/buildSrc/src/main/kotlin/tasks/configuration/WasmTasksConfiguration.kt +++ b/skiko/buildSrc/src/main/kotlin/tasks/configuration/WasmTasksConfiguration.kt @@ -56,12 +56,13 @@ fun SkikoProjectContext.createWasmLinkTasks(): LinkWasmTasks = with(this.project includeHeadersNonRecursive(skiaHeadersDirs(skiaWasmDir.get())) flags.set( - listOf( - *skiaPreprocessorFlags(OS.Wasm, buildType), - *buildType.clangFlags, - "-fno-rtti", - "-fno-exceptions", - ) + mutableListOf().apply { + addAll(skiaPreprocessorFlags(OS.Wasm, buildType)) + addAll(buildType.clangFlags) + add("-fno-rtti") + add("-fno-exceptions") + if (skiko.isWasmBuildWithProfiling) add("--profiling") + } ) } @@ -103,7 +104,7 @@ fun SkikoProjectContext.createWasmLinkTasks(): LinkWasmTasks = with(this.project ) @OptIn(kotlin.ExperimentalStdlibApi::class) - flags.set(buildList { + flags.set(mutableListOf().apply { addAll( listOf( "-l", "GL", @@ -117,6 +118,7 @@ fun SkikoProjectContext.createWasmLinkTasks(): LinkWasmTasks = with(this.project "-O2" ) ) + // addAll(listOf("-s", "SUPPORT_LONGJMP=wasm")) // TODO(o.karpovich): enable when skia is built with this flag (CMP-6628) if (outputES6) { addAll( listOf( @@ -128,6 +130,8 @@ fun SkikoProjectContext.createWasmLinkTasks(): LinkWasmTasks = with(this.project ) ) } + + if (skiko.isWasmBuildWithProfiling) add("--profiling") }) doLast { @@ -136,11 +140,16 @@ fun SkikoProjectContext.createWasmLinkTasks(): LinkWasmTasks = with(this.project val jsFiles = outDir.asFile.get().walk() .filter { it.isFile && (it.name.endsWith(".js") || it.name.endsWith(".mjs")) } + val isEnvironmentNodeCheckRegex = Regex( + // spaces are different in release and debug builds + """if\s*\(ENVIRONMENT_IS_NODE\)\s*\{""" + ) + for (jsFile in jsFiles) { val originalContent = jsFile.readText() val newContent = originalContent.replace("_org_jetbrains", "org_jetbrains") .replace("skikomjs.wasm", "skiko.wasm") - .replace("if(ENVIRONMENT_IS_NODE){", "if (false) {") // to make webpack erase this part + .replace(isEnvironmentNodeCheckRegex, "if (false) {") // to make webpack erase this part jsFile.writeText(newContent) if (outputES6) {