From 669f729b74dab09efd34b3f32abf52e5f5892936 Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Thu, 27 Oct 2022 15:07:35 +0300 Subject: [PATCH 01/11] Edited .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 4cf1c4c4f84..f428fd80ffa 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,7 @@ build_settings.yml # Autogenerated folder with yarn.lock file kotlin-js-store + +# intermediate build files on Windows +python-package/kotlin-bridge/*.def +python-package/kotlin-bridge/lets_plot_kotlin_bridge.o From 98d3206205554b0696a24afa8016652305fd2a93 Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Thu, 27 Oct 2022 15:29:57 +0300 Subject: [PATCH 02/11] Fixed build on Windows --- python-package/setup.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/python-package/setup.py b/python-package/setup.py index 58374572948..d2daff26d03 100644 --- a/python-package/setup.py +++ b/python-package/setup.py @@ -55,18 +55,26 @@ def run(self): with open(os.path.join(root_dir, 'README.md'), encoding='utf-8') as f: long_description = f.read() -if this_system == 'Windows': - import distutils.cygwinccompiler - - distutils.cygwinccompiler.get_msvcr = lambda: [] if this_system == 'Darwin': stdcpp_lib = 'c++' # fix for "ImportError: dlopen(...) Symbol not found: _NSGenericException" on macOS extra_link = ['-framework', 'Foundation'] -else: + +elif this_system == 'Windows': stdcpp_lib = 'stdc++' - extra_link = [] + # fix python package build with Kotlin v1.7.20 (and later) on Windows. + extra_link = ['-lbcrypt'] + # fix for "cannot find -lmsvcr140: No such file or directory" compiler error on Windows. + import distutils.cygwinccompiler + distutils.cygwinccompiler.get_msvcr = lambda: [] + +elif this_system == 'Linux': + stdcpp_lib = 'stdc++' + +else: + raise ValueError("Unsupported platform.") + setup(name='lets-plot', license="MIT", From c5473d5be36f8003f7c9e56c4505dc24ea4e88e7 Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Thu, 27 Oct 2022 16:02:37 +0300 Subject: [PATCH 03/11] Added extra_link parameter for Linux --- python-package/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python-package/setup.py b/python-package/setup.py index d2daff26d03..5a874e3f6b2 100644 --- a/python-package/setup.py +++ b/python-package/setup.py @@ -71,6 +71,7 @@ def run(self): elif this_system == 'Linux': stdcpp_lib = 'stdc++' + extra_link = [] else: raise ValueError("Unsupported platform.") From 4b886c90e063152b42185426ee2f44f7d4404361 Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Thu, 27 Oct 2022 20:23:03 +0300 Subject: [PATCH 04/11] Disabled DCE --- js-package/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js-package/build.gradle b/js-package/build.gradle index c8a4d7f2ac6..0b891467924 100644 --- a/js-package/build.gradle +++ b/js-package/build.gradle @@ -31,6 +31,9 @@ kotlin { target { browser { dceTask { + // DCE disabled to prevent 'Exception in thread "main" java.lang.StackOverflowError' error. + dceOptions.devMode = true + keep.addAll( "lets-plot-js-package.buildPlotFromRawSpecs", "lets-plot-js-package.buildPlotFromProcessedSpecs", From 572619f0960f42582c2d2a645c6c69b2eedeaaeb Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Fri, 28 Oct 2022 20:25:35 +0300 Subject: [PATCH 05/11] Added linuxArm64 target. Refactored Gradle scripts. Removed IgnoreJS. --- .gitignore | 3 ++ base-portable/build.gradle | 19 ---------- .../datalore/base/logging/PortableLogging.kt | 14 ++++++++ build.gradle | 35 +++++++++++++++++++ plot-base-portable/build.gradle | 19 ---------- plot-builder-portable/build.gradle | 22 +++--------- plot-common-portable/build.gradle | 19 ---------- plot-config-portable/build.gradle | 19 ---------- .../kotlin/plot/PlotSvgHelperTest.kt | 3 -- python-package-build/build.gradle | 4 ++- test-common/build.gradle | 19 ---------- .../datalore/base/annotation/IgnoreTarget.kt | 9 ----- .../datalore/base/annotation/IgnoreTarget.kt | 8 ----- .../kotlin/base/annotation/IgnoreTarget.kt | 9 ----- .../datalore/base/annotation/IgnoreJs.kt | 9 ----- .../datalore/base/annotation/IgnoreJs.kt | 9 ----- .../datalore/base/annotation/IgnoreTarget.kt | 9 ----- .../datalore/vis/canvas/CssStyleUtilTest.kt | 16 ++++----- vis-svg-portable/build.gradle | 19 ---------- 19 files changed, 67 insertions(+), 197 deletions(-) create mode 100644 base-portable/src/linuxArm64Main/kotlin/jetbrains/datalore/base/logging/PortableLogging.kt delete mode 100644 test-common/src/commonMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt delete mode 100644 test-common/src/jsMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt delete mode 100644 test-common/src/jvmMain/kotlin/base/annotation/IgnoreTarget.kt delete mode 100644 test-common/src/macosArm64Main/kotlin/jetbrains/datalore/base/annotation/IgnoreJs.kt delete mode 100644 test-common/src/macosX64Main/kotlin/jetbrains/datalore/base/annotation/IgnoreJs.kt delete mode 100644 test-common/src/nativeMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt diff --git a/.gitignore b/.gitignore index f428fd80ffa..f255b385971 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ kotlin-js-store # intermediate build files on Windows python-package/kotlin-bridge/*.def python-package/kotlin-bridge/lets_plot_kotlin_bridge.o + +# VSCode service directiry +.vscode diff --git a/base-portable/build.gradle b/base-portable/build.gradle index bc3c7e0ed91..c747434f222 100644 --- a/base-portable/build.gradle +++ b/base-portable/build.gradle @@ -3,8 +3,6 @@ * Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ -import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.gradle.plugin.idea-ext" @@ -17,23 +15,6 @@ kotlin { browser() } - if (project.buildSettings.build_python_extension) { - def currentOs = DefaultNativePlatform.getCurrentOperatingSystem() - - if (currentOs.isMacOsX()) { - def currentArch = DefaultNativePlatform.getCurrentArchitecture() - if (currentArch.displayName.contains("arm-v8")) { - macosArm64() - } else { - macosX64() - } - } else if (currentOs.isLinux()) { - linuxX64() - } else if (currentOs.isWindows()) { - mingwX64() - } - } - sourceSets { commonMain { dependencies { diff --git a/base-portable/src/linuxArm64Main/kotlin/jetbrains/datalore/base/logging/PortableLogging.kt b/base-portable/src/linuxArm64Main/kotlin/jetbrains/datalore/base/logging/PortableLogging.kt new file mode 100644 index 00000000000..a1508e9c463 --- /dev/null +++ b/base-portable/src/linuxArm64Main/kotlin/jetbrains/datalore/base/logging/PortableLogging.kt @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2020. JetBrains s.r.o. + * Use of this source code is governed by the MIT license that can be found in the LICENSE file. + */ + +package jetbrains.datalore.base.logging + +import kotlin.reflect.KClass + +actual object PortableLogging { + actual fun logger(cl: KClass<*>): Logger { + return PrintlnLogger(cl.simpleName ?: "") + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index c538de808c8..cf5139e7806 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,8 @@ plugins { id "io.codearte.nexus-staging" } +import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform + project.ext.letsPlotTaskGroup = 'lets-plot' def include_sources_letsPlotJvmCommon = [ @@ -177,7 +179,40 @@ task publishKotlinApiDependenciesToMavenRepository { group project.letsPlotTaskGroup } + subprojects { + // Configure Kotlin Native build. + if (name in [ + 'base-portable', + 'plot-base-portable', + 'plot-builder-portable', + 'plot-common-portable', + 'plot-config-portable', + 'test-common', + 'vis-svg-portable', + ]) { + apply plugin: "org.jetbrains.kotlin.multiplatform" + + def currentOs = DefaultNativePlatform.getCurrentOperatingSystem() + def currentOsArch = DefaultNativePlatform.getCurrentArchitecture() + + kotlin{ + if (project.buildSettings.build_python_extension) { + if (currentOs.macOsX & currentOsArch.amd64) { + macosX64() + } else if (currentOs.macOsX & currentOsArch.arm) { + macosArm64() + } else if (currentOs.linux & currentOsArch.amd64) { + linuxX64() + } else if (currentOs.linux & currentOsArch.arm) { + linuxArm64() + } else if (currentOs.isWindows()) { + mingwX64() + } + } + } + } + // Configure publishing for projects which "Lets-Plot Kotlin API" depends on. if (name in [ 'plot-base-portable', diff --git a/plot-base-portable/build.gradle b/plot-base-portable/build.gradle index 54ee1ec3c54..019b19daa64 100644 --- a/plot-base-portable/build.gradle +++ b/plot-base-portable/build.gradle @@ -3,8 +3,6 @@ * Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ -import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.gradle.plugin.idea-ext" @@ -16,23 +14,6 @@ kotlin { browser() } - if (project.buildSettings.build_python_extension) { - def currentOs = DefaultNativePlatform.getCurrentOperatingSystem() - - if (currentOs.isMacOsX()) { - def currentArch = DefaultNativePlatform.getCurrentArchitecture() - if (currentArch.displayName.contains("arm-v8")) { - macosArm64() - } else { - macosX64() - } - } else if (currentOs.isLinux()) { - linuxX64() - } else if (currentOs.isWindows()) { - mingwX64() - } - } - sourceSets { commonMain { dependencies { diff --git a/plot-builder-portable/build.gradle b/plot-builder-portable/build.gradle index 14841179dd2..029ad60a1df 100644 --- a/plot-builder-portable/build.gradle +++ b/plot-builder-portable/build.gradle @@ -1,4 +1,7 @@ -import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform +/* + * Copyright (c) 2019. JetBrains s.r.o. + * Use of this source code is governed by the MIT license that can be found in the LICENSE file. + */ plugins { id "org.jetbrains.kotlin.multiplatform" @@ -11,23 +14,6 @@ kotlin { browser() } - if (project.buildSettings.build_python_extension) { - def currentOs = DefaultNativePlatform.getCurrentOperatingSystem() - - if (currentOs.isMacOsX()) { - def currentArch = DefaultNativePlatform.getCurrentArchitecture() - if (currentArch.displayName.contains("arm-v8")) { - macosArm64() - } else { - macosX64() - } - } else if (currentOs.isLinux()) { - linuxX64() - } else if (currentOs.isWindows()) { - mingwX64() - } - } - sourceSets { commonMain { dependencies { diff --git a/plot-common-portable/build.gradle b/plot-common-portable/build.gradle index 377758bed13..d330e2f90f2 100644 --- a/plot-common-portable/build.gradle +++ b/plot-common-portable/build.gradle @@ -3,8 +3,6 @@ * Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ -import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.gradle.plugin.idea-ext" @@ -16,23 +14,6 @@ kotlin { browser() } - if (project.buildSettings.build_python_extension) { - def currentOs = DefaultNativePlatform.getCurrentOperatingSystem() - - if (currentOs.isMacOsX()) { - def currentArch = DefaultNativePlatform.getCurrentArchitecture() - if (currentArch.displayName.contains("arm-v8")) { - macosArm64() - } else { - macosX64() - } - } else if (currentOs.isLinux()) { - linuxX64() - } else if (currentOs.isWindows()) { - mingwX64() - } - } - sourceSets { commonMain { dependencies { diff --git a/plot-config-portable/build.gradle b/plot-config-portable/build.gradle index d939f0b9149..77b97639c47 100644 --- a/plot-config-portable/build.gradle +++ b/plot-config-portable/build.gradle @@ -3,8 +3,6 @@ * Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ -import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.gradle.plugin.idea-ext" @@ -16,23 +14,6 @@ kotlin { browser() } - if (project.buildSettings.build_python_extension) { - def currentOs = DefaultNativePlatform.getCurrentOperatingSystem() - - if (currentOs.isMacOsX()) { - def currentArch = DefaultNativePlatform.getCurrentArchitecture() - if (currentArch.displayName.contains("arm-v8")) { - macosArm64() - } else { - macosX64() - } - } else if (currentOs.isLinux()) { - linuxX64() - } else if (currentOs.isWindows()) { - mingwX64() - } - } - sourceSets { commonMain { dependencies { diff --git a/plot-config-portable/src/commonTest/kotlin/plot/PlotSvgHelperTest.kt b/plot-config-portable/src/commonTest/kotlin/plot/PlotSvgHelperTest.kt index d7f6f7952cf..acfcbb111d7 100644 --- a/plot-config-portable/src/commonTest/kotlin/plot/PlotSvgHelperTest.kt +++ b/plot-config-portable/src/commonTest/kotlin/plot/PlotSvgHelperTest.kt @@ -5,7 +5,6 @@ package jetbrains.datalore.plot -import jetbrains.datalore.base.annotation.IgnoreJs import jetbrains.datalore.base.geometry.DoubleVector import jetbrains.datalore.plot.testing.EXPECTED_BUNCH_SVG import jetbrains.datalore.plot.testing.EXPECTED_SINGLE_PLOT_SVG @@ -14,14 +13,12 @@ import kotlin.test.assertEquals internal class PlotSvgHelperTest { @Test - @IgnoreJs fun svgSizeFromSinglePlotSvg() { val sizeFromSvg = PlotSvgHelper.fetchPlotSizeFromSvg(EXPECTED_SINGLE_PLOT_SVG) assertEquals(DoubleVector(400.0, 300.0), sizeFromSvg) } @Test - @IgnoreJs fun svgSizeFromGGBunchSvg() { val sizeFromSvg = PlotSvgHelper.fetchPlotSizeFromSvg(EXPECTED_BUNCH_SVG) assertEquals(DoubleVector(300.0, 150.0), sizeFromSvg) diff --git a/python-package-build/build.gradle b/python-package-build/build.gradle index ef6889d6d9e..bfcb5410baa 100644 --- a/python-package-build/build.gradle +++ b/python-package-build/build.gradle @@ -14,6 +14,8 @@ plugins { // ---------------------------------------- def currentOs = DefaultNativePlatform.getCurrentOperatingSystem() +def currentOsArch = DefaultNativePlatform.getCurrentArchitecture() + //def task_group = 'lets plot' def tools_dir = "${rootDir}/tools" def python_package_dir = "${rootDir}/python-package" @@ -59,7 +61,7 @@ if (project.buildSettings.enable_python_package) { description = 'Builds lets-plot wheel distribution with Manylinux platform for publication(python)' workingDir tools_dir - commandLine "./run_manylinux_docker.sh", "${rootDir}" + commandLine "./run_manylinux_docker.sh", "${rootDir}", "${currentOsArch}" } diff --git a/test-common/build.gradle b/test-common/build.gradle index 96acdc6ab70..46cb412daf9 100644 --- a/test-common/build.gradle +++ b/test-common/build.gradle @@ -3,8 +3,6 @@ * Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ -import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.gradle.plugin.idea-ext" @@ -16,23 +14,6 @@ kotlin { browser() } - if (project.buildSettings.build_python_extension) { - def currentOs = DefaultNativePlatform.getCurrentOperatingSystem() - - if (currentOs.isMacOsX()) { - def currentArch = DefaultNativePlatform.getCurrentArchitecture() - if (currentArch.displayName.contains("arm-v8")) { - macosArm64("native") - } else { - macosX64("native") - } - } else if (currentOs.isLinux()) { - linuxX64("native") - } else if (currentOs.isWindows()) { - mingwX64("native") - } - } - sourceSets { commonMain { dependencies { diff --git a/test-common/src/commonMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt b/test-common/src/commonMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt deleted file mode 100644 index cf059916010..00000000000 --- a/test-common/src/commonMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2020. JetBrains s.r.o. - * Use of this source code is governed by the MIT license that can be found in the LICENSE file. - */ - -package jetbrains.datalore.base.annotation - -@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) -expect annotation class IgnoreJs() \ No newline at end of file diff --git a/test-common/src/jsMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt b/test-common/src/jsMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt deleted file mode 100644 index aa408b7fdb0..00000000000 --- a/test-common/src/jsMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2020. JetBrains s.r.o. - * Use of this source code is governed by the MIT license that can be found in the LICENSE file. - */ - -package jetbrains.datalore.base.annotation - -actual typealias IgnoreJs = kotlin.test.Ignore \ No newline at end of file diff --git a/test-common/src/jvmMain/kotlin/base/annotation/IgnoreTarget.kt b/test-common/src/jvmMain/kotlin/base/annotation/IgnoreTarget.kt deleted file mode 100644 index 9e9e8585e06..00000000000 --- a/test-common/src/jvmMain/kotlin/base/annotation/IgnoreTarget.kt +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2020. JetBrains s.r.o. - * Use of this source code is governed by the MIT license that can be found in the LICENSE file. - */ - -package jetbrains.datalore.base.annotation - -@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) -actual annotation class IgnoreJs \ No newline at end of file diff --git a/test-common/src/macosArm64Main/kotlin/jetbrains/datalore/base/annotation/IgnoreJs.kt b/test-common/src/macosArm64Main/kotlin/jetbrains/datalore/base/annotation/IgnoreJs.kt deleted file mode 100644 index cbeecced935..00000000000 --- a/test-common/src/macosArm64Main/kotlin/jetbrains/datalore/base/annotation/IgnoreJs.kt +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2022. JetBrains s.r.o. - * Use of this source code is governed by the MIT license that can be found in the LICENSE file. - */ - -package jetbrains.datalore.base.annotation - -@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) -actual annotation class IgnoreJs actual constructor() \ No newline at end of file diff --git a/test-common/src/macosX64Main/kotlin/jetbrains/datalore/base/annotation/IgnoreJs.kt b/test-common/src/macosX64Main/kotlin/jetbrains/datalore/base/annotation/IgnoreJs.kt deleted file mode 100644 index cbeecced935..00000000000 --- a/test-common/src/macosX64Main/kotlin/jetbrains/datalore/base/annotation/IgnoreJs.kt +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2022. JetBrains s.r.o. - * Use of this source code is governed by the MIT license that can be found in the LICENSE file. - */ - -package jetbrains.datalore.base.annotation - -@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) -actual annotation class IgnoreJs actual constructor() \ No newline at end of file diff --git a/test-common/src/nativeMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt b/test-common/src/nativeMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt deleted file mode 100644 index 9e9e8585e06..00000000000 --- a/test-common/src/nativeMain/kotlin/jetbrains/datalore/base/annotation/IgnoreTarget.kt +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2020. JetBrains s.r.o. - * Use of this source code is governed by the MIT license that can be found in the LICENSE file. - */ - -package jetbrains.datalore.base.annotation - -@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) -actual annotation class IgnoreJs \ No newline at end of file diff --git a/vis-canvas/src/commonTest/kotlin/jetbrains/datalore/vis/canvas/CssStyleUtilTest.kt b/vis-canvas/src/commonTest/kotlin/jetbrains/datalore/vis/canvas/CssStyleUtilTest.kt index 849e1274d97..8e8f5839d26 100644 --- a/vis-canvas/src/commonTest/kotlin/jetbrains/datalore/vis/canvas/CssStyleUtilTest.kt +++ b/vis-canvas/src/commonTest/kotlin/jetbrains/datalore/vis/canvas/CssStyleUtilTest.kt @@ -5,13 +5,12 @@ package jetbrains.datalore.vis.canvas -import jetbrains.datalore.base.annotation.IgnoreJs import jetbrains.datalore.vis.canvas.CssStyleUtil.extractStyleFont import jetbrains.datalore.vis.canvas.CssStyleUtil.scaleFont import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNull - +import kotlin.test.assertTrue class CssStyleUtilTest { @@ -28,18 +27,19 @@ class CssStyleUtilTest { } @Test - @IgnoreJs fun scaleSimpleFont() { + val commonExpected = "24.0px arial" + val jsExpected = "24px arial" val actual = scaleFont("12px arial", TEST_SCALE) - assertEquals("24.0px arial", actual) + assertTrue((commonExpected == actual) || (jsExpected == actual)) } @Test - @IgnoreJs fun scaleFontWithSlash() { - assertEquals("24.0px/20.0px sans-serif", scaleFont("12px/10px sans-serif", - TEST_SCALE - )) + val commonExpected = "24.0px/20.0px sans-serif" + val jsExpected = "24px/20px sans-serif" + val actual = scaleFont("12px/10px sans-serif", TEST_SCALE) + assertTrue((commonExpected == actual) || (jsExpected == actual)) } @Test diff --git a/vis-svg-portable/build.gradle b/vis-svg-portable/build.gradle index f3b0688901e..e97d5f2eab9 100644 --- a/vis-svg-portable/build.gradle +++ b/vis-svg-portable/build.gradle @@ -3,8 +3,6 @@ * Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ -import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.gradle.plugin.idea-ext" @@ -16,23 +14,6 @@ kotlin { browser() } - if (project.buildSettings.build_python_extension) { - def currentOs = DefaultNativePlatform.getCurrentOperatingSystem() - - if (currentOs.isMacOsX()) { - def currentArch = DefaultNativePlatform.getCurrentArchitecture() - if (currentArch.displayName.contains("arm-v8")) { - macosArm64() - } else { - macosX64() - } - } else if (currentOs.isLinux()) { - linuxX64() - } else if (currentOs.isWindows()) { - mingwX64() - } - } - sourceSets { commonMain { dependencies { From f199d604299534880e833adb20b7d81f77149e8a Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Fri, 28 Oct 2022 21:05:36 +0300 Subject: [PATCH 06/11] Switching native target depending on dev/release build version --- build.gradle | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index cf5139e7806..e04657401ed 100644 --- a/build.gradle +++ b/build.gradle @@ -198,15 +198,26 @@ subprojects { kotlin{ if (project.buildSettings.build_python_extension) { - if (currentOs.macOsX & currentOsArch.amd64) { - macosX64() - } else if (currentOs.macOsX & currentOsArch.arm) { - macosArm64() - } else if (currentOs.linux & currentOsArch.amd64) { - linuxX64() - } else if (currentOs.linux & currentOsArch.arm) { - linuxArm64() - } else if (currentOs.isWindows()) { + if (version.contains("alpha")){ + if (currentOs.macOsX & currentOsArch.amd64) { + macosX64() + } else if (currentOs.macOsX & currentOsArch.arm) { + macosArm64() + } else if (currentOs.linux & currentOsArch.amd64) { + linuxX64() + } else if (currentOs.linux & currentOsArch.arm) { + linuxArm64() + } + } else { + if (currentOs.macOsX) { + macosArm64() + macosX64 + } else if (currentOs.linux) { + linuxArm64() + linuxX64() + } + } + if (currentOs.windows) { mingwX64() } } From ab7d633212560060f548c68e7abe568d525229c6 Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Fri, 28 Oct 2022 21:40:32 +0300 Subject: [PATCH 07/11] Fixed typo --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e04657401ed..9936782bf9d 100644 --- a/build.gradle +++ b/build.gradle @@ -211,7 +211,7 @@ subprojects { } else { if (currentOs.macOsX) { macosArm64() - macosX64 + macosX64() } else if (currentOs.linux) { linuxArm64() linuxX64() From 9de91130412999a2b426c09912e36a38c9283bff Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Fri, 28 Oct 2022 22:08:07 +0300 Subject: [PATCH 08/11] Added linuxArm64 target in python-extension --- python-extension/build.gradle | 62 ++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/python-extension/build.gradle b/python-extension/build.gradle index 0488b5a279e..0b342dd9f4f 100644 --- a/python-extension/build.gradle +++ b/python-extension/build.gradle @@ -1,45 +1,53 @@ -plugins { - id "org.jetbrains.kotlin.multiplatform" - id "org.jetbrains.gradle.plugin.idea-ext" -} - - /* * Copyright (c) 2019. JetBrains s.r.o. * Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.gradle.plugin.idea-ext" +} + import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform def currentOs = DefaultNativePlatform.getCurrentOperatingSystem() +def currentOsArch = DefaultNativePlatform.getCurrentArchitecture() kotlin { if (project.buildSettings.build_python_extension) { - def target - if (currentOs.isMacOsX()) { - def currentArch = DefaultNativePlatform.getCurrentArchitecture() - if (currentArch.displayName.contains("arm-v8")) { - target = macosArm64("native") - } else { - target = macosX64("native") + def targetList = [] + if (version.contains("alpha")){ + if (currentOs.macOsX & currentOsArch.amd64) { + targetList.add(macosX64("native")) + } else if (currentOs.macOsX & currentOsArch.arm) { + targetList.add(macosArm64("native")) + } else if (currentOs.linux & currentOsArch.amd64) { + targetList.add(linuxX64("native")) + } else if (currentOs.linux & currentOsArch.arm) { + targetList.add(linuxArm64("native")) } - } else if (currentOs.isLinux()) { - target = linuxX64("native") - } else if (currentOs.isWindows()) { - target = mingwX64("native") } else { - throw "Unsupported platform " + currentOs.displayName - } - - target.binaries { - staticLib { - baseName = "lets-plot-${project.name}" + if (currentOs.macOsX) { + targetList.add(macosArm64("native")) + targetList.add(macosX64("native")) + } else if (currentOs.linux) { + targetList.add(linuxArm64("native")) + targetList.add(linuxX64("native")) } } - - target.compilations.main.cinterops { - python { - compilerOpts "-I${project.buildSettings.python.include_path}" + if (currentOs.windows) { + mingwX64("native") + } + for (target in targetList) { + target.binaries { + staticLib { + baseName = "lets-plot-${project.name}" + } + } + target.compilations.main.cinterops { + python { + compilerOpts "-I${project.buildSettings.python.include_path}" + } } } } else { From 3bad1f8f732a5fbbd05f85d1da72dd86806d86ca Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Mon, 31 Oct 2022 18:36:18 +0300 Subject: [PATCH 09/11] Reverted target switching. Enabled DCE. --- build.gradle | 31 ++++++++------------- js-package/build.gradle | 3 --- python-extension/build.gradle | 51 +++++++++++++++-------------------- 3 files changed, 32 insertions(+), 53 deletions(-) diff --git a/build.gradle b/build.gradle index 9936782bf9d..21d73c36637 100644 --- a/build.gradle +++ b/build.gradle @@ -198,27 +198,18 @@ subprojects { kotlin{ if (project.buildSettings.build_python_extension) { - if (version.contains("alpha")){ - if (currentOs.macOsX & currentOsArch.amd64) { - macosX64() - } else if (currentOs.macOsX & currentOsArch.arm) { - macosArm64() - } else if (currentOs.linux & currentOsArch.amd64) { - linuxX64() - } else if (currentOs.linux & currentOsArch.arm) { - linuxArm64() - } - } else { - if (currentOs.macOsX) { - macosArm64() - macosX64() - } else if (currentOs.linux) { - linuxArm64() - linuxX64() - } - } - if (currentOs.windows) { + if (currentOs.macOsX & currentOsArch.amd64) { + macosX64() + } else if (currentOs.macOsX & currentOsArch.arm) { + macosArm64() + } else if (currentOs.linux & currentOsArch.amd64) { + linuxX64() + } else if (currentOs.linux & currentOsArch.arm) { + linuxArm64() + } else if (currentOs.windows) { mingwX64() + } else { + throw new Exception("Unsupported platform.") } } } diff --git a/js-package/build.gradle b/js-package/build.gradle index 0b891467924..c8a4d7f2ac6 100644 --- a/js-package/build.gradle +++ b/js-package/build.gradle @@ -31,9 +31,6 @@ kotlin { target { browser { dceTask { - // DCE disabled to prevent 'Exception in thread "main" java.lang.StackOverflowError' error. - dceOptions.devMode = true - keep.addAll( "lets-plot-js-package.buildPlotFromRawSpecs", "lets-plot-js-package.buildPlotFromProcessedSpecs", diff --git a/python-extension/build.gradle b/python-extension/build.gradle index 0b342dd9f4f..4476268384a 100644 --- a/python-extension/build.gradle +++ b/python-extension/build.gradle @@ -15,41 +15,32 @@ def currentOsArch = DefaultNativePlatform.getCurrentArchitecture() kotlin { if (project.buildSettings.build_python_extension) { - def targetList = [] - if (version.contains("alpha")){ - if (currentOs.macOsX & currentOsArch.amd64) { - targetList.add(macosX64("native")) - } else if (currentOs.macOsX & currentOsArch.arm) { - targetList.add(macosArm64("native")) - } else if (currentOs.linux & currentOsArch.amd64) { - targetList.add(linuxX64("native")) - } else if (currentOs.linux & currentOsArch.arm) { - targetList.add(linuxArm64("native")) - } + def target + if (currentOs.macOsX & currentOsArch.amd64) { + target = macosX64("native") + } else if (currentOs.macOsX & currentOsArch.arm) { + target = macosArm64("native") + } else if (currentOs.linux & currentOsArch.amd64) { + target = linuxX64("native") + } else if (currentOs.linux & currentOsArch.arm) { + target =linuxArm64("native") + } else if (currentOs.windows) { + target = mingwX64("native") } else { - if (currentOs.macOsX) { - targetList.add(macosArm64("native")) - targetList.add(macosX64("native")) - } else if (currentOs.linux) { - targetList.add(linuxArm64("native")) - targetList.add(linuxX64("native")) - } - } - if (currentOs.windows) { - mingwX64("native") + throw new Exception("Unsupported platform.") } - for (target in targetList) { - target.binaries { - staticLib { - baseName = "lets-plot-${project.name}" - } + + target.binaries { + staticLib { + baseName = "lets-plot-${project.name}" } - target.compilations.main.cinterops { - python { - compilerOpts "-I${project.buildSettings.python.include_path}" - } + } + target.compilations.main.cinterops { + python { + compilerOpts "-I${project.buildSettings.python.include_path}" } } + } else { jvm() // at least one target is required by MPP - dummy jvm target will work just fine } From 4a03287b0047507d83d1fa2a5ad7e0429755a97a Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Tue, 1 Nov 2022 13:43:27 +0300 Subject: [PATCH 10/11] Modified clean task --- python-package-build/build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python-package-build/build.gradle b/python-package-build/build.gradle index bfcb5410baa..b4ada18cb94 100644 --- a/python-package-build/build.gradle +++ b/python-package-build/build.gradle @@ -27,6 +27,10 @@ clean { delete python_package_dist_dir delete "${python_package_dir}/lets_plot/package_data" delete "${python_package_dir}/lets_plot.egg-info" + delete "${python_package_dir}/kotlin-bridge/kotlin_bridge.o" + delete fileTree("${python_package_dir}/kotlin-bridge/"){ + include "*.def" + } } if (project.buildSettings.enable_python_package) { From 3305fddc52dfc340e28d6bc21bffe4451fbba9b3 Mon Sep 17 00:00:00 2001 From: Valentin Dovidaytis Date: Wed, 2 Nov 2022 19:29:03 +0300 Subject: [PATCH 11/11] Switched to legacy memory manager --- gradle.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gradle.properties b/gradle.properties index 9a383f5eade..cace1b4cc0b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -39,3 +39,5 @@ org.gradle.jvmargs=-Xmx2g kotlin.js.compiler=both kotlin.mpp.stability.nowarn=true kotlin.jvm.target.validation.mode=error +# Switched to legacy memory manager to prevent runtime errors on Windows. +kotlin.native.binary.memoryModel=strict