Skip to content

Commit

Permalink
Revert unified versioning.
Browse files Browse the repository at this point in the history
Revert "[build][version] generate KonanVersion using data from gradle.properties." 07ae314.
Revert "[gradle][test] disable version test" 86ec80a.
Revert "[build][version][doc] update" 94ba9d6.
  • Loading branch information
vvlevchenko committed Apr 20, 2018
1 parent 9e0c44a commit fe28b13
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 126 deletions.
7 changes: 6 additions & 1 deletion GRADLE_PLUGIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ The Kotlin/Native plugin depends on `org.jetbrains.kotlin:kotlin-gradle-plugin`.
plugins as buildscript dependencies, it's recommended to **declare them in the same `build.gradle`** to avoid issues with
plugin classpath.

The plugin downloads the compiler during its first run. You may specify a version of the compiler using `konan.version`
project property:

konan.version=0.3

If you already downloaded the compiler manually you may specify the path to its root directory using `konan.home`
project property (e.g. in `gradle.properties`).
project property (e.g. in `gradle.properties`). Note: the plugin ignores the `konan.version` property in this case.

konan.home=/home/user/kotlin-native-0.5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.config.addKotlinSourceRoots
import org.jetbrains.kotlin.config.kotlinSourceRoots
import org.jetbrains.kotlin.konan.KonanVersion
import org.jetbrains.kotlin.konan.file.File
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
import org.jetbrains.kotlin.psi.KtFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@
* limitations under the License.
*/

package org.jetbrains.kotlin.konan
package org.jetbrains.kotlin.backend.konan

/**
* https://en.wikipedia.org/wiki/Software_versioning
* scheme major.minor[.build[.revision]].
*/

enum class MetaVersion {
DEV,
EAP,
ALPHA,
BETA,
RC
}
}

class KonanVersion(val meta: MetaVersion?, val major: Int, val minor: Int, val maintenance: Int, val build:Int) {
companion object {
val CURRENT = KonanVersion(MetaVersion.EAP, 0, 6, 2, 0)
}
override fun toString() = if (meta != null) "$meta $major.$minor.$maintenance.$build" else "$major.$minor.$maintenance.$build"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import kotlinx.cinterop.allocArrayOf
import kotlinx.cinterop.memScoped
import llvm.*
import org.jetbrains.kotlin.backend.konan.Context
import org.jetbrains.kotlin.konan.KonanVersion
import org.jetbrains.kotlin.backend.konan.KonanVersion
import org.jetbrains.kotlin.backend.konan.irasdescriptors.FunctionDescriptor
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.ir.SourceManager.FileEntry
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ buildscript {
apply plugin: 'kotlin'

// We reuse the source code from the Project in buildSrc.
sourceSets.main.kotlin.srcDirs = ["$projectDir/../../shared/src/main/kotlin"]
sourceSets.main.kotlin.srcDirs = ["$projectDir/../../shared"]

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ remoteRoot=konan_tests
testDataVersion=1226829:id
kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_CompilerAllPlugins),number:1.2.50-dev-515,tag:kotlin-native,pinned:true/artifacts/content/maven
kotlinVersion=1.2.50-dev-515
konanVersion=0.7
konanVersion=0.6.2
org.gradle.jvmargs='-Dfile.encoding=UTF-8'

16 changes: 1 addition & 15 deletions shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.jetbrains.kotlin.VersionGenerator

buildscript {
ext.rootBuildDirectory = file('..')
ext.rootBuildDirectory = file('../')

apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
Expand All @@ -34,19 +33,6 @@ repositories {
}
}

task generateCompilerVersion(type: VersionGenerator){}

sourceSets {
main.kotlin {
srcDir 'src/main/kotlin'
srcDir generateCompilerVersion.versionSourceDirectory
}
}

compileKotlin{
dependsOn('generateCompilerVersion')
}

jar {
archiveName = "shared.jar"
}
Expand Down
35 changes: 0 additions & 35 deletions shared/buildSrc/build.gradle

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions tools/kotlin-native-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ test {
processResources {
// We add konanVersion as a task input to avoid considering this task up-to-date when
// konanVersion is actually changed and should be updated in the plugin jar.
inputs.property("konanVersion", konanVersion)
expand('konanVersion': konanVersion)
from(file("$rootBuildDirectory/utilities/env_blacklist"))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import org.gradle.language.nativeplatform.internal.Names
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
import org.jetbrains.kotlin.gradle.plugin.KonanPlugin.Companion.COMPILE_ALL_TASK_NAME
import org.jetbrains.kotlin.gradle.plugin.tasks.*
import org.jetbrains.kotlin.konan.KonanVersion
import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.kotlin.konan.target.KonanTarget
import org.jetbrains.kotlin.konan.target.customerDistribution
Expand Down Expand Up @@ -111,6 +110,9 @@ internal val Project.konanExtension: KonanExtension
internal val Project.konanCompilerDownloadTask
get() = tasks.getByName(KonanPlugin.KONAN_DOWNLOAD_TASK_NAME)

internal val Project.konanVersion
get() = getProperty(KonanPlugin.ProjectProperty.KONAN_VERSION, KonanPlugin.DEFAULT_KONAN_VERSION) as String

internal val Project.requestedTargets
get() = findProperty(KonanPlugin.ProjectProperty.KONAN_BUILD_TARGETS)?.let {
it.toString().trim().split("\\s+".toRegex())
Expand Down Expand Up @@ -139,7 +141,7 @@ private fun Project.getOrCreateTask(name: String): Task = with(tasks) {
}

internal fun Project.konanCompilerName(): String =
"kotlin-native-${project.simpleOsName}-${KonanVersion.CURRENT}"
"kotlin-native-${project.simpleOsName}-${this.konanVersion}"

internal fun Project.konanCompilerDownloadDir(): String =
DependencyProcessor.localKonanDir.resolve(project.konanCompilerName()).absolutePath
Expand Down Expand Up @@ -216,7 +218,7 @@ internal fun dumpProperties(task: Task) {
println("target : $target")
println("languageVersion : $languageVersion")
println("apiVersion : $apiVersion")
println("konanVersion : ${KonanVersion.CURRENT}")
println("konanVersion : $konanVersion")
println("konanHome : $konanHome")
println()
}
Expand All @@ -237,7 +239,7 @@ internal fun dumpProperties(task: Task) {
println("linkerOpts : $linkerOpts")
println("headers : ${headers.dump()}")
println("linkFiles : ${linkFiles.dump()}")
println("konanVersion : ${KonanVersion.CURRENT}")
println("konanVersion : $konanVersion")
println("konanHome : $konanHome")
println()
}
Expand Down Expand Up @@ -271,6 +273,7 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR

enum class ProjectProperty(val propertyName: String) {
KONAN_HOME ("konan.home"),
KONAN_VERSION ("konan.version"),
KONAN_BUILD_TARGETS ("konan.build.targets"),
KONAN_JVM_ARGS ("konan.jvmArgs"),
KONAN_USE_ENVIRONMENT_VARIABLES("konan.useEnvironmentVariables"),
Expand All @@ -291,6 +294,11 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
internal const val KONAN_MAIN_VARIANT = "konan_main_variant"

internal const val KONAN_EXTENSION_NAME = "konan"

internal val DEFAULT_KONAN_VERSION = Properties().apply {
load(KonanPlugin::class.java.getResourceAsStream("/META-INF/gradle-plugins/konan.properties") ?:
throw RuntimeException("Cannot find a properties file"))
}.getProperty("default-konan-version") ?: throw RuntimeException("Cannot read the default compiler version")
}

private fun Project.cleanKonan() = project.tasks.withType(KonanBuildingTask::class.java).forEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.gradle.api.Project
import org.gradle.tooling.provider.model.ToolingModelBuilder
import org.jetbrains.kotlin.gradle.plugin.model.KonanArtifact
import org.jetbrains.kotlin.gradle.plugin.model.KonanModel
import org.jetbrains.kotlin.konan.KonanVersion
import org.jetbrains.kotlin.konan.util.visibleName

object KonanToolingModelBuilder : ToolingModelBuilder {
Expand All @@ -30,11 +29,12 @@ object KonanToolingModelBuilder : ToolingModelBuilder {
val artifacts = project.konanArtifactsContainer.flatten()
.toList()
.map { KonanArtifactImpl("${it.artifact.name}-${it.konanTarget.visibleName}", it.artifact.canonicalPath) }
return KonanModelImpl(artifacts)
return KonanModelImpl(project.konanVersion, artifacts)
}
}

private class KonanModelImpl(
override val konanVersion: String,
override val artifacts: List<KonanArtifact>
) : KonanModel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import java.io.Serializable
* This model is shared with the client processes such as an IDE.
*/
interface KonanModel : Serializable {
val konanVersion: String
val artifacts: List<KonanArtifact>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ abstract class KonanBuildingTask: KonanArtifactWithLibrariesTask(), KonanBuildin
@Input
val extraOpts = mutableListOf<String>()

val konanVersion
@Input get() = project.konanVersion
val konanHome
@Input get() = project.konanHome

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import org.gradle.api.GradleScriptException
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.konan.KonanVersion
import org.jetbrains.kotlin.konan.MetaVersion
import org.jetbrains.kotlin.konan.util.DependencyProcessor
import org.jetbrains.kotlin.konan.util.DependencySource
import org.jetbrains.kotlin.konan.util.visibleName
Expand All @@ -45,15 +43,18 @@ open class KonanCompilerDownloadTask : DefaultTask() {
if (!project.hasProperty(KonanPlugin.ProjectProperty.DOWNLOAD_COMPILER)) {
val konanHome = project.getProperty(KonanPlugin.ProjectProperty.KONAN_HOME)
logger.info("Use a user-defined compiler path: $konanHome")
if (project.hasProperty(KonanPlugin.ProjectProperty.KONAN_VERSION)) {
val konanVersion = project.getProperty(KonanPlugin.ProjectProperty.KONAN_VERSION)
logger.warn("${KonanPlugin.ProjectProperty.KONAN_VERSION.propertyName} " +
"(=$konanVersion) property is ignored " +
"because a user-defined compiler path is specified: $konanHome")
}
} else {
try {
val downloadUrlDirectory = buildString {
append("$BASE_DOWNLOAD_URL/")
val version = KonanVersion.CURRENT
when (version.meta) {
MetaVersion.DEV -> append("dev/")
else -> append("releases/")
}
val version = project.konanVersion
append(if (version.contains("dev")) "dev/" else "releases/")
append("$version/")
append(project.simpleOsName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,20 @@ class IncrementalSpecification extends BaseKonanSpecification {
recompilationAndInteropProcessingHappened(*results)
}

def 'konan version change should cause recompilation and interop reprocessing'() {
when:
def project = KonanProject.createWithInterop(projectDirectory, ArtifactType.LIBRARY) { KonanProject it ->
it.propertiesFile.append("konan.version=0.3\n")
}
def results = buildTwice(project) { KonanProject it ->
def newText = it.propertiesFile.text.replace('konan.version=0.3', 'konan.version=0.4')
it.propertiesFile.write(newText)
}

then:
recompilationAndInteropProcessingHappened(*results)
}

def 'Common source change should cause recompilation'() {
when:
File commonSource
Expand Down

0 comments on commit fe28b13

Please sign in to comment.