blob: b95f9bfdd71320609f2ef9b98c452455f6f8c1f7 [file] [log] [blame]
Leonid Startsev9f6d3b42019-10-09 18:07:41 +03001/*
2 * Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
5
6project.ext.deployMode = property('native.deploy') == 'true'
7project.ext.singleTargetMode = project.ext.ideaActive || !project.ext.deployMode
8
9project.ext.nativeMainSets = []
10project.ext.nativeTestSets = []
11
12kotlin {
13 targets.metaClass.addTarget = { preset ->
14 def target = delegate.fromPreset(preset, preset.name)
15 project.ext.nativeMainSets.add(target.compilations['main'].kotlinSourceSets.first())
16 project.ext.nativeTestSets.add(target.compilations['test'].kotlinSourceSets.first())
17 }
18
19 targets {
Vsevolod Tolstopyatovca54a562019-12-24 16:33:56 +030020 return
Leonid Startsev9f6d3b42019-10-09 18:07:41 +030021 if (project.ext.singleTargetMode) {
22 fromPreset(project.ext.ideaPreset, 'native')
23 } else {
24 // Linux
25 addTarget(presets.linuxX64)
26 addTarget(presets.linuxArm32Hfp)
Ugljesa Jovanovicdc3f4672019-12-27 22:33:48 +010027 addTarget(presets.linuxArm64)
Leonid Startsev9f6d3b42019-10-09 18:07:41 +030028
29 // Mac & iOS
30 addTarget(presets.macosX64)
31
32 addTarget(presets.iosArm64)
33 addTarget(presets.iosArm32)
34 addTarget(presets.iosX64)
35
Leonid Startsev54c9c512019-10-18 15:51:59 +030036 addTarget(presets.watchosX86)
37 addTarget(presets.watchosArm32)
38 addTarget(presets.watchosArm64)
39
40 addTarget(presets.tvosArm64)
41 addTarget(presets.tvosX64)
Leonid Startsev9f6d3b42019-10-09 18:07:41 +030042
43 // Windows
44 addTarget(presets.mingwX64)
45 addTarget(presets.mingwX86)
Leonid Startsevad5cbdc2019-12-12 13:00:54 +030046
47 // WASM
48 addTarget(presets.wasm32)
Leonid Startsev9f6d3b42019-10-09 18:07:41 +030049 }
50 }
51
52 sourceSets {
53 nativeMain { dependsOn commonMain }
54 // Empty source set is required in order to have native tests task
55 nativeTest {}
56
57 if (!project.ext.singleTargetMode) {
58 configure(project.ext.nativeMainSets) {
59 dependsOn nativeMain
60 }
61
62 configure(project.ext.nativeTestSets) {
63 dependsOn nativeTest
64 }
65 }
66 }
67}