155a760ee9
This reverts commit 740f851a
196 lines
5.3 KiB
Groovy
196 lines
5.3 KiB
Groovy
plugins {
|
|
id "com.moowork.node" version "1.2.0"
|
|
}
|
|
|
|
description = 'Kotlin Standard Library for JS IR'
|
|
|
|
apply plugin: 'kotlin-platform-js'
|
|
apply plugin: 'idea'
|
|
|
|
def originalBuiltinsDir = "${rootDir}/core/builtins"
|
|
def builtinsSrcDir = "${buildDir}/builtin-sources"
|
|
def nativeBuiltinsSrcDir = "${buildDir}/native-builtin-sources"
|
|
|
|
// Sync native built-ins to separate directory because we don't
|
|
// need them all -- some of them are implemented as proper code in 'js-ir/builtins'.
|
|
// Also, they don't compile on its own without error suppressing.
|
|
task prepareNativeBuiltinsSources(type: Sync) {
|
|
from("${originalBuiltinsDir}/native/kotlin") {
|
|
include "Annotation.kt"
|
|
include "Any.kt"
|
|
include "Array.kt"
|
|
include "Boolean.kt"
|
|
include "CharSequence.kt"
|
|
include "Collections.kt"
|
|
include "Comparable.kt"
|
|
include "Coroutines.kt"
|
|
include "Iterator.kt"
|
|
include "Nothing.kt"
|
|
include "Number.kt"
|
|
include "String.kt"
|
|
}
|
|
|
|
into nativeBuiltinsSrcDir
|
|
|
|
doLast {
|
|
(new File(nativeBuiltinsSrcDir)).list().each { path ->
|
|
def file = new File("${nativeBuiltinsSrcDir}/${path}")
|
|
def sourceCode = """\
|
|
@file:Suppress(
|
|
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
|
|
"MUST_BE_INITIALIZED_OR_BE_ABSTRACT",
|
|
"EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE",
|
|
"PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED",
|
|
"WRONG_MODIFIER_TARGET"
|
|
)
|
|
""".stripIndent() + file.getText()
|
|
file.setText(sourceCode)
|
|
}
|
|
}
|
|
}
|
|
|
|
task prepareBuiltinsSources(type: Sync) {
|
|
from("${originalBuiltinsDir}/src/kotlin/") {
|
|
exclude "ArrayIntrinsics.kt" // Used only for JVM
|
|
}
|
|
into builtinsSrcDir
|
|
}
|
|
|
|
def jsCommonDir = "${buildDir}/common-js-sources"
|
|
|
|
task prepareCommonJsSources(type: Sync) {
|
|
from("${projectDir}/../js/")
|
|
exclude 'src/generated/**' // is used for legacy backend
|
|
into jsCommonDir
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
kotlin {
|
|
srcDir "${projectDir}/builtins"
|
|
srcDir "${projectDir}/runtime"
|
|
srcDir "${projectDir}/src"
|
|
|
|
srcDir "${jsCommonDir}/src"
|
|
srcDir "${jsCommonDir}/runtime"
|
|
|
|
srcDir builtinsSrcDir
|
|
srcDir nativeBuiltinsSrcDir
|
|
}
|
|
}
|
|
test {
|
|
kotlin {
|
|
srcDir "${jsCommonDir}/test/"
|
|
}
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
commonSources
|
|
}
|
|
|
|
dependencies {
|
|
expectedBy project(":kotlin-stdlib-common")
|
|
commonSources project(path: ":kotlin-stdlib-common", configuration: "sources")
|
|
testCompile project(':kotlin-test:kotlin-test-js')
|
|
}
|
|
|
|
|
|
compileKotlin2Js {
|
|
dependsOn prepareNativeBuiltinsSources
|
|
dependsOn prepareBuiltinsSources
|
|
dependsOn prepareCommonJsSources
|
|
|
|
kotlinOptions {
|
|
outputFile = "${buildDir}/classes/main/kotlin.js"
|
|
moduleKind = "umd"
|
|
main = "noCall"
|
|
verbose = true
|
|
freeCompilerArgs += [
|
|
"-Xir-produce-klib-dir",
|
|
"-Xir-only",
|
|
"-Xallow-kotlin-package",
|
|
"-Xallow-result-return-type",
|
|
"-Xuse-experimental=kotlin.Experimental",
|
|
"-Xuse-experimental=kotlin.ExperimentalMultiplatform",
|
|
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
|
|
"-Xinline-classes",
|
|
]
|
|
}
|
|
}
|
|
|
|
def testOutputFile = "${buildDir}/classes/kotlin/test/kotlin-stdlib-js-ir_test.js"
|
|
def kotlinTestTestOutputFile = "${project(':kotlin-test:kotlin-test-js').buildDir}/classes/kotlin/test/kotlin-test-js-ir_test.js"
|
|
|
|
compileTestKotlin2Js {
|
|
kotlinOptions {
|
|
moduleKind = "umd"
|
|
verbose = true
|
|
outputFile = testOutputFile
|
|
freeCompilerArgs += [
|
|
"-Xir-produce-js",
|
|
"-verbose",
|
|
"-Xuse-experimental=kotlin.Experimental",
|
|
"-Xuse-experimental=kotlin.ExperimentalUnsignedTypes",
|
|
"-Xuse-experimental=kotlin.ExperimentalStdlibApi"
|
|
]
|
|
}
|
|
}
|
|
|
|
archivesBaseName = 'kotlin-stdlib-js-ir'
|
|
|
|
jar {
|
|
manifestAttributes(manifest, project, 'Main')
|
|
duplicatesStrategy = DuplicatesStrategy.FAIL
|
|
}
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
classifier = 'sources'
|
|
duplicatesStrategy = DuplicatesStrategy.FAIL
|
|
from (sourceSets.main.allSource)
|
|
}
|
|
|
|
artifacts {
|
|
archives sourcesJar
|
|
}
|
|
|
|
node {
|
|
download = true
|
|
version = '8.9.4' // The default 6.9.1 has buggy hyperbolic functions implementation
|
|
nodeModulesDir = buildDir
|
|
}
|
|
|
|
task installMocha(type: NpmTask) {
|
|
args = ['install', 'mocha']
|
|
}
|
|
|
|
task installTeamcityReporter(type: NpmTask) {
|
|
args = ['install', 'mocha-teamcity-reporter']
|
|
}
|
|
|
|
task runMocha(type: NodeTask) {
|
|
dependsOn compileTestKotlin2Js
|
|
dependsOn installMocha
|
|
dependsOn ':kotlin-test:kotlin-test-js:testClasses'
|
|
|
|
script = file("${buildDir}/node_modules/mocha/bin/mocha")
|
|
|
|
if (project.hasProperty("teamcity")) {
|
|
dependsOn installTeamcityReporter
|
|
args = ['--reporter', 'mocha-teamcity-reporter',
|
|
'--reporter-options', 'topLevelSuite=stdlib-js-ir']
|
|
}
|
|
else {
|
|
args = ['--reporter', 'min']
|
|
}
|
|
|
|
args += [testOutputFile, kotlinTestTestOutputFile]
|
|
|
|
execOverrides {
|
|
it.ignoreExitValue = rootProject.ignoreTestFailures
|
|
it.workingDir = buildDir
|
|
}
|
|
}
|
|
|
|
test.dependsOn runMocha
|