Leonid Startsev | 9f6d3b4 | 2019-10-09 18:07:41 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| 3 | */ |
| 4 | |
| 5 | |
| 6 | project.ext.deployMode = property('native.deploy') == 'true' |
| 7 | project.ext.singleTargetMode = project.ext.ideaActive || !project.ext.deployMode |
| 8 | |
| 9 | project.ext.nativeMainSets = [] |
| 10 | project.ext.nativeTestSets = [] |
| 11 | |
| 12 | kotlin { |
| 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 Tolstopyatov | ca54a56 | 2019-12-24 16:33:56 +0300 | [diff] [blame] | 20 | return |
Leonid Startsev | 9f6d3b4 | 2019-10-09 18:07:41 +0300 | [diff] [blame] | 21 | if (project.ext.singleTargetMode) { |
| 22 | fromPreset(project.ext.ideaPreset, 'native') |
| 23 | } else { |
| 24 | // Linux |
| 25 | addTarget(presets.linuxX64) |
| 26 | addTarget(presets.linuxArm32Hfp) |
Ugljesa Jovanovic | dc3f467 | 2019-12-27 22:33:48 +0100 | [diff] [blame^] | 27 | addTarget(presets.linuxArm64) |
Leonid Startsev | 9f6d3b4 | 2019-10-09 18:07:41 +0300 | [diff] [blame] | 28 | |
| 29 | // Mac & iOS |
| 30 | addTarget(presets.macosX64) |
| 31 | |
| 32 | addTarget(presets.iosArm64) |
| 33 | addTarget(presets.iosArm32) |
| 34 | addTarget(presets.iosX64) |
| 35 | |
Leonid Startsev | 54c9c51 | 2019-10-18 15:51:59 +0300 | [diff] [blame] | 36 | addTarget(presets.watchosX86) |
| 37 | addTarget(presets.watchosArm32) |
| 38 | addTarget(presets.watchosArm64) |
| 39 | |
| 40 | addTarget(presets.tvosArm64) |
| 41 | addTarget(presets.tvosX64) |
Leonid Startsev | 9f6d3b4 | 2019-10-09 18:07:41 +0300 | [diff] [blame] | 42 | |
| 43 | // Windows |
| 44 | addTarget(presets.mingwX64) |
| 45 | addTarget(presets.mingwX86) |
Leonid Startsev | ad5cbdc | 2019-12-12 13:00:54 +0300 | [diff] [blame] | 46 | |
| 47 | // WASM |
| 48 | addTarget(presets.wasm32) |
Leonid Startsev | 9f6d3b4 | 2019-10-09 18:07:41 +0300 | [diff] [blame] | 49 | } |
| 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 | } |