stdlib-js: build as multiplatform
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
|||||||
|
|
||||||
description = 'Kotlin Standard Library for JS'
|
description = 'Kotlin Standard Library for JS'
|
||||||
|
|
||||||
apply plugin: 'kotlin2js'
|
apply plugin: 'kotlin-platform-js'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
|
|
||||||
configureDist(project)
|
configureDist(project)
|
||||||
@@ -13,12 +13,11 @@ configurePublishing(project)
|
|||||||
|
|
||||||
def builtinsSrcDir = "${buildDir}/builtin-sources"
|
def builtinsSrcDir = "${buildDir}/builtin-sources"
|
||||||
def builtinsSrcDir2 = "${buildDir}/builtin-sources-for-builtins"
|
def builtinsSrcDir2 = "${buildDir}/builtin-sources-for-builtins"
|
||||||
def commonSrcDir = "${buildDir}/common-sources"
|
def commonSrcDir = "${projectDir}/../common/src/build/common-sources"
|
||||||
def commonTestSrcDir = "${buildDir}/common-test-sources"
|
|
||||||
def builtinsDir = "${rootDir}/core/builtins"
|
def builtinsDir = "${rootDir}/core/builtins"
|
||||||
def experimentalSrcDir = "${rootDir}/libraries/stdlib/experimental"
|
def experimentalSrcDir = "${rootDir}/libraries/stdlib/experimental"
|
||||||
def experimentalJsModuleName = 'kotlin-experimental'
|
def experimentalJsModuleName = 'kotlin-experimental'
|
||||||
def jsSrcGeneratedDir = "${rootDir}/js/js.libraries/src/core/generated" // to be removed soon
|
|
||||||
def jsSrcDir = "src"
|
def jsSrcDir = "src"
|
||||||
def jsTestSrcDir = "test"
|
def jsTestSrcDir = "test"
|
||||||
def jsSrcJsDir = "${jsSrcDir}/js"
|
def jsSrcJsDir = "${jsSrcDir}/js"
|
||||||
@@ -44,7 +43,6 @@ sourceSets {
|
|||||||
kotlin {
|
kotlin {
|
||||||
srcDir builtinsSrcDir
|
srcDir builtinsSrcDir
|
||||||
srcDir jsSrcDir
|
srcDir jsSrcDir
|
||||||
srcDir jsSrcGeneratedDir
|
|
||||||
srcDir commonSrcDir
|
srcDir commonSrcDir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,7 +56,6 @@ sourceSets {
|
|||||||
|
|
||||||
test {
|
test {
|
||||||
kotlin {
|
kotlin {
|
||||||
srcDir commonTestSrcDir
|
|
||||||
srcDir jsTestSrcDir
|
srcDir jsTestSrcDir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,13 +65,11 @@ configurations {
|
|||||||
merger
|
merger
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
|
expectedBy project(":kotlin-stdlib-common")
|
||||||
testCompile project(':kotlin-test:kotlin-test-js')
|
testCompile project(':kotlin-test:kotlin-test-js')
|
||||||
merger project(":tools:kotlin-stdlib-js-merger")
|
merger project(":tools:kotlin-stdlib-js-merger")
|
||||||
}
|
}
|
||||||
|
|
||||||
createPreprocessorTask(project, "Main", "${projectDir}/../src/kotlin", commonSrcDir)
|
|
||||||
createPreprocessorTask(project, "Test", "${projectDir}/../test", commonTestSrcDir)
|
|
||||||
|
|
||||||
task prepareComparableSource(type: Copy) {
|
task prepareComparableSource(type: Copy) {
|
||||||
doFirst {
|
doFirst {
|
||||||
delete builtinsSrcDir2
|
delete builtinsSrcDir2
|
||||||
@@ -135,13 +130,13 @@ compileBuiltinsKotlin2Js {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileKotlin2Js {
|
compileKotlin2Js {
|
||||||
dependsOn preprocessSourcesMain, prepareBuiltinsSources
|
dependsOn(":kotlin-stdlib-common:preprocessSourcesMain")
|
||||||
|
dependsOn prepareBuiltinsSources
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
outputFile = "${buildDir}/classes/main/kotlin.js"
|
outputFile = "${buildDir}/classes/main/kotlin.js"
|
||||||
sourceMap = true
|
sourceMap = true
|
||||||
sourceMapPrefix = "./"
|
sourceMapPrefix = "./"
|
||||||
freeCompilerArgs += ["-source-map-base-dirs", [builtinsSrcDir, jsSrcDir, commonSrcDir].collect { file(it).absoluteFile }.
|
freeCompilerArgs += ["-source-map-base-dirs", [builtinsSrcDir, jsSrcDir, commonSrcDir].collect { file(it).absoluteFile }.join(File.pathSeparator)]
|
||||||
join(File.pathSeparator)]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +153,7 @@ compileExperimentalKotlin2Js {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileTestKotlin2Js {
|
compileTestKotlin2Js {
|
||||||
dependsOn preprocessSourcesTest
|
dependsOn(":kotlin-stdlib-common:preprocessSourcesTest")
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
moduleKind = "umd"
|
moduleKind = "umd"
|
||||||
}
|
}
|
||||||
@@ -218,7 +213,7 @@ task compileJs(type: JavaExec) {
|
|||||||
if (prefixToRemove != null) sourcePath.substring(prefixToRemove.length()) else sourcePath
|
if (prefixToRemove != null) sourcePath.substring(prefixToRemove.length()) else sourcePath
|
||||||
}
|
}
|
||||||
|
|
||||||
def sourceMapSourcesBaseDirs = [jsSrcDir, jsSrcJsDir, jsSrcGeneratedDir, builtinsSrcDir, commonSrcDir, projectDir, experimentalSrcDir]
|
def sourceMapSourcesBaseDirs = [jsSrcDir, jsSrcJsDir, builtinsSrcDir, commonSrcDir, projectDir, experimentalSrcDir]
|
||||||
|
|
||||||
sourceMap.sourcesContent = sourceMap.sources.collect { sourceName ->
|
sourceMap.sourcesContent = sourceMap.sources.collect { sourceName ->
|
||||||
def text = sourceMapSourcesBaseDirs.collect { file("$it/$sourceName") }.find { it.exists() }?.text
|
def text = sourceMapSourcesBaseDirs.collect { file("$it/$sourceName") }.find { it.exists() }?.text
|
||||||
@@ -245,7 +240,7 @@ task mergedJar(type: Jar, dependsOn: classes) {
|
|||||||
classifier = null
|
classifier = null
|
||||||
manifestAttributes(manifest, project, 'Main')
|
manifestAttributes(manifest, project, 'Main')
|
||||||
|
|
||||||
// TODO: Use standard implementation title after js stdlib detector becomes more flexible
|
// TODO: Use standard implementation title after js stdlib detector becomes more flexible (KT-17655)
|
||||||
Properties properties = new Properties()
|
Properties properties = new Properties()
|
||||||
new File("${rootDir}/resources/kotlinManifest.properties").withInputStream {
|
new File("${rootDir}/resources/kotlinManifest.properties").withInputStream {
|
||||||
properties.load(it)
|
properties.load(it)
|
||||||
|
|||||||
Reference in New Issue
Block a user