blob: 9ff893ccd73f397cb595bb700963addacaee3d61 [file] [log] [blame]
Leonid Startsev9f6d3b42019-10-09 18:07:41 +03001/*
Leonid Startsevf7abe612020-02-18 17:16:03 +03002 * Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Leonid Startsev9f6d3b42019-10-09 18:07:41 +03003 */
4
Vsevolod Tolstopyatov608cbad2020-09-14 15:38:02 +03005project.ext.ideaActive = System.getProperty('idea.active') == 'true'
Leonid Startsev9f6d3b42019-10-09 18:07:41 +03006project.ext.deployMode = property('native.deploy') == 'true'
7project.ext.singleTargetMode = project.ext.ideaActive || !project.ext.deployMode
8
9project.ext.nativeMainSets = []
10project.ext.nativeTestSets = []
11
12kotlin {
Vsevolod Tolstopyatov608cbad2020-09-14 15:38:02 +030013 targets {
14 def manager = project.ext.hostManager
15 def linuxEnabled = manager.isEnabled(presets.linuxX64.konanTarget)
16 def macosEnabled = manager.isEnabled(presets.macosX64.konanTarget)
17 def winEnabled = manager.isEnabled(presets.mingwX64.konanTarget)
18
19 project.ext.isLinuxHost = linuxEnabled
20 project.ext.isMacosHost = macosEnabled
21 project.ext.isWinHost = winEnabled
22
23 def ideaPreset = presets.linuxX64
24 if (macosEnabled) ideaPreset = presets.macosX64
25 if (winEnabled) ideaPreset = presets.mingwX64
26 project.ext.ideaPreset = ideaPreset
27 }
28
Leonid Startsev9f6d3b42019-10-09 18:07:41 +030029 targets.metaClass.addTarget = { preset ->
30 def target = delegate.fromPreset(preset, preset.name)
31 project.ext.nativeMainSets.add(target.compilations['main'].kotlinSourceSets.first())
32 project.ext.nativeTestSets.add(target.compilations['test'].kotlinSourceSets.first())
33 }
34
35 targets {
36 if (project.ext.singleTargetMode) {
37 fromPreset(project.ext.ideaPreset, 'native')
38 } else {
39 // Linux
40 addTarget(presets.linuxX64)
41 addTarget(presets.linuxArm32Hfp)
Ugljesa Jovanovicdc3f4672019-12-27 22:33:48 +010042 addTarget(presets.linuxArm64)
Leonid Startsev9f6d3b42019-10-09 18:07:41 +030043
44 // Mac & iOS
45 addTarget(presets.macosX64)
46
47 addTarget(presets.iosArm64)
48 addTarget(presets.iosArm32)
49 addTarget(presets.iosX64)
50
Leonid Startsev54c9c512019-10-18 15:51:59 +030051 addTarget(presets.watchosX86)
52 addTarget(presets.watchosArm32)
53 addTarget(presets.watchosArm64)
54
55 addTarget(presets.tvosArm64)
56 addTarget(presets.tvosX64)
Leonid Startsev9f6d3b42019-10-09 18:07:41 +030057
58 // Windows
59 addTarget(presets.mingwX64)
60 addTarget(presets.mingwX86)
Leonid Startsev9f6d3b42019-10-09 18:07:41 +030061 }
62 }
63
64 sourceSets {
65 nativeMain { dependsOn commonMain }
66 // Empty source set is required in order to have native tests task
Sergey Igushkinc5f1af62020-05-26 15:54:39 +030067 nativeTest { dependsOn commonTest }
Leonid Startsev9f6d3b42019-10-09 18:07:41 +030068
69 if (!project.ext.singleTargetMode) {
70 configure(project.ext.nativeMainSets) {
71 dependsOn nativeMain
72 }
73
74 configure(project.ext.nativeTestSets) {
75 dependsOn nativeTest
76 }
77 }
78 }
79}