Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support K2. #1212

Merged
merged 25 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ reports
jacoco.exec
.externalNativeBuild
.cxx
.kotlin

# iOS
*.pbxuser
Expand Down
11 changes: 11 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ allprojects {
plugins.withId("org.jetbrains.kotlin.multiplatform") {
configure<KotlinMultiplatformExtension> {
jvmToolchain(11)

targets.configureEach {
compilations.configureEach {
compilerOptions.configure {
freeCompilerArgs.addAll(
// https://youtrack.jetbrains.com/issue/KT-61573
"-Xexpect-actual-classes",
)
}
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ androidx-compose = "1.5.4"
androidx-compose-compiler = "1.5.7"
compileSdk = "34"
http4k = "4.48.0.0"
kotlin = "1.9.21"
kotlin = "2.0.0-Beta2"
kotlinx-coroutines = "1.7.3"
kotlinx-serialization = "1.6.2"
ksp = "1.9.21-1.0.16"
ksp = "2.0.0-Beta2-1.0.16"
okHttp = "4.12.0"
okio = "3.7.0"
minSdk = "18"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.compiler.VfsBasedProjectEnvironment
import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.ModuleCompilerEnvironment
import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.ModuleCompilerInput
import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.compileModuleToAnalyzedFir
import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoots
Expand Down Expand Up @@ -136,10 +135,7 @@ internal class KotlinFirLoader(

return compileModuleToAnalyzedFir(
input = input,
environment = ModuleCompilerEnvironment(
projectEnvironment = projectEnvironment,
diagnosticsReporter = reporter,
),
projectEnvironment = projectEnvironment,
previousStepsSymbolProviders = emptyList(),
incrementalExcludesScope = null,
diagnosticsReporter = reporter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ApplySourceMapToBytecodeTest {
)

@Before
@Suppress("INVISIBLE_MEMBER") // Access :zipline internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals.
fun setUp() {
// Configure QuickJS to support module loading.
app.cash.zipline.internal.initModuleLoader(quickJs)
Expand Down Expand Up @@ -222,7 +222,7 @@ class ApplySourceMapToBytecodeTest {
assertThat(quickJs.evaluate("doubleToDisplayString('1000.0')")).isEqualTo("1000.0")
}

@Suppress("INVISIBLE_MEMBER") // Access :zipline internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals.
private fun loadJsModule(id: String, bytecode: ByteArray) {
app.cash.zipline.internal.loadJsModule(quickJs, id, bytecode)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GenerateKeyPair(
.default(Ed25519)
.help("Signing algorithm to use.")

@Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals.
override fun run() {
val keyPair = app.cash.zipline.loader.internal.generateKeyPair(algorithm)
out.println(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class DownloadTest {
assertTrue(fileSystem.exists(tmpDirPath / testFixtures.alphaSha256Hex))
}

@Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals.
private fun getApplicationManifestFileName(applicationName: String) =
app.cash.zipline.loader.internal.getApplicationManifestFileName(applicationName)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ internal class ZiplineCompiler(

private fun getJsFiles(files: List<File>) = files.filter { it.path.endsWith(".js") }

@Suppress("INVISIBLE_MEMBER") // Access :zipline internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals.
private val manifestFileName = app.cash.zipline.loader.internal.MANIFEST_FILE_NAME

@Suppress("INVISIBLE_MEMBER") // Access :zipline internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals.
private fun collectDependencies(quickJs: QuickJs, bytecode: ByteArray): List<String> {
app.cash.zipline.internal.collectModuleDependencies(quickJs)
quickJs.execute(bytecode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class ZiplinePlugin : KotlinCompilerPluginSupportPlugin {
}
}

@Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals.
private fun generateKeyPair(algorithm: SignatureAlgorithmId) {
val logger = LoggerFactory.getLogger(ZiplinePlugin::class.java)
val keyPair = app.cash.zipline.loader.internal.generateKeyPair(algorithm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package app.cash.zipline.gradle

import java.io.File
import org.gradle.api.internal.provider.DefaultProvider
import org.gradle.api.provider.Provider
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode
import org.jetbrains.kotlin.gradle.targets.js.ir.JsIrBinary
Expand Down Expand Up @@ -49,7 +48,7 @@ internal fun JsIrBinary.asJsProductionTask(): JsProductionTask {
override val targetName get() = target.name
override val toolName = null
override val mode get() = [email protected]
override val outputFile get() = linkTask.map { it.outputFileProperty.get() }
override val outputFile get() = linkTask.map { it.destinationDirectory.get().asFile }
}
}

Expand All @@ -64,6 +63,6 @@ internal fun KotlinWebpack.asJsProductionTask(): JsProductionTask {
name.endsWith("ProductionWebpack") -> KotlinJsBinaryMode.PRODUCTION
else -> error("unexpected KotlinWebpack task name: $name")
}
override val outputFile get() = DefaultProvider { [email protected] }
override val outputFile get() = mainOutputFile.map { it.asFile }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ZiplineCompilerTest {
private val quickJs = QuickJs.create()

@Before
@Suppress("INVISIBLE_MEMBER") // Access :zipline internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals.
fun setUp() {
// Configure QuickJS to support module loading.
app.cash.zipline.internal.initModuleLoader(quickJs)
Expand Down Expand Up @@ -224,7 +224,7 @@ class ZiplineCompilerTest {
return result
}

@Suppress("INVISIBLE_MEMBER") // Access :zipline internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals.
private fun loadJsModule(quickJs: QuickJs, id: String, bytecode: ByteArray) {
return app.cash.zipline.internal.loadJsModule(quickJs, id, bytecode)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class ZiplineGradleDownloaderTest {
)
}

@Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals.
private fun getApplicationManifestFileName(applicationName: String) =
app.cash.zipline.loader.internal.getApplicationManifestFileName(applicationName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ class ZiplineGradlePluginTest {
val SUCCESS_OUTCOMES = listOf(TaskOutcome.SUCCESS, TaskOutcome.UP_TO_DATE)
val versionProperty = "-PziplineVersion=${System.getProperty("ziplineVersion")}"

@Suppress("INVISIBLE_MEMBER") // Access :zipline internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals.
private val manifestFileName = app.cash.zipline.loader.internal.MANIFEST_FILE_NAME
}
}
11 changes: 11 additions & 0 deletions zipline-kotlin-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm")
Expand Down Expand Up @@ -33,3 +34,13 @@ configure<MavenPublishBaseExtension> {
)
)
}

tasks {
withType<KotlinCompile>().configureEach {
compilerOptions {
freeCompilerArgs.addAll(
"-opt-in=org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI"
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
@OptIn(ExperimentalCompilerApi::class)
@AutoService(CompilerPluginRegistrar::class)
class ZiplineCompilerPluginRegistrar : CompilerPluginRegistrar() {
override val supportsK2 get() = false
override val supportsK2 get() = true

override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
val messageCollector = configuration.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ManifestVerifier private constructor(
* @throws IllegalStateException if no trusted signature is found, or if a signature doesn't
* verify.
*/
@Suppress("INVISIBLE_MEMBER") // Access :zipline internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals.
fun verify(manifestBytes: ByteString, manifest: ZiplineManifest): String? {
if (!doSignatureChecks) return null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class ZiplineLoader internal constructor(
* After identifying a manifest to load this fetches all the code, loads it into a JS runtime,
* and runs both the user's initializer and the manifest's specified main function.
*/
@Suppress("INVISIBLE_MEMBER") // Access :zipline internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals.
internal suspend fun loadFromManifest(
applicationName: String,
eventListener: EventListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ProductionFetcherReceiverTest {
assertEquals(testFixtures.alphaByteString, ziplineFileFromCache)
}

@Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals.
private fun getLog() = app.cash.zipline.internal.getLog(zipline.quickJs)

private suspend fun ZiplineLoader.loadOrFail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class ZiplineLoaderTest {
}
}

@Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals.
private fun Zipline.getLog(): String? = app.cash.zipline.internal.getLog(quickJs)

private suspend fun ZiplineLoader.loadOrFail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ internal interface ProfilerClock {
val nanoTime: Long
}

internal expect object DefaultProfilerClock : ProfilerClock
internal expect object DefaultProfilerClock : ProfilerClock {
override val nanoTime: Long
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
package app.cash.zipline.profiler

internal actual object DefaultProfilerClock : ProfilerClock {
override val nanoTime: Long get() = System.nanoTime()
actual override val nanoTime: Long get() = System.nanoTime()
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
package app.cash.zipline.profiler

internal actual object DefaultProfilerClock : ProfilerClock {
override val nanoTime: Long get() = kotlin.system.getTimeNanos()
actual override val nanoTime: Long get() = kotlin.system.getTimeNanos()
}
15 changes: 9 additions & 6 deletions zipline-testing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
import org.jetbrains.kotlin.gradle.plugin.PLUGIN_CLASSPATH_CONFIGURATION_NAME
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile

Expand Down Expand Up @@ -69,19 +68,23 @@ kotlin {

tasks {
// https://kotlinlang.org/docs/whatsnew19.html#library-linkage-in-kotlin-native
withType<KotlinNativeCompile>().all {
kotlinOptions {
freeCompilerArgs += listOf("-Xpartial-linkage-loglevel=ERROR")
withType<KotlinNativeCompile>().configureEach {
compilerOptions {
freeCompilerArgs.addAll("-Xpartial-linkage-loglevel=ERROR")
}
}

// https://youtrack.jetbrains.com/issue/KT-56025
// https://youtrack.jetbrains.com/issue/KT-57203
named("jsBrowserProductionWebpack").configure {
findByName("jsBrowserProductionWebpack")?.apply {
dependsOn(named("jsProductionLibraryCompileSync"))
dependsOn(named("jsDevelopmentLibraryCompileSync"))
}
named("jsBrowserProductionLibraryPrepare").configure {
findByName("jsBrowserProductionLibraryPrepare")?.apply {
dependsOn(named("jsProductionExecutableCompileSync"))
dependsOn(named("jsDevelopmentLibraryCompileSync"))
}
findByName("jsBrowserProductionLibraryDistribution")?.apply {
dependsOn(named("jsProductionExecutableCompileSync"))
dependsOn(named("jsDevelopmentLibraryCompileSync"))
}
Expand Down
Loading
Loading