This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
130 lines (103 loc) · 3.86 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import static org.apache.tools.ant.taskdefs.condition.Os.*
plugins {
// cpp
id 'cpp'
// Publish library to maven
id 'maven-publish'
// Add basic gradle conventions like archiving
id 'base'
// Google test suite for native build
id 'google-test-test-suite'
// GradleRIO
id 'edu.wpi.first.GradleRIO' version '2022.2.1'
// Doxygen
id 'org.ysb33r.doxygen' version '0.7.0'
}
allprojects {
plugins.withType(edu.wpi.first.toolchain.roborio.RoboRioToolchainPlugin).whenPluginAdded {
if (project.hasProperty('no-roborio'))
toolchainsPlugin.getByName('roboRio').optional = true
}
plugins.withType(NativeComponentPlugin).whenPluginAdded {
project.model {
binaries {
all {
if (it instanceof NativeBinarySpec) {
if (project.hasProperty('no-desktop') && targetPlatform.name == edu.wpi.first.toolchain.NativePlatforms.desktop) {
it.buildable = false
}
if (project.hasProperty('no-roborio') && targetPlatform.name == edu.wpi.first.toolchain.NativePlatforms.roborio) {
it.buildable = false
}
}
// Toolchain defines (cpp version)
if (toolChain in [Gcc, Clang]) {
println "Using Gcc"
cppCompiler.args "-std=${cpp_version}"
} else if (toolChain in VisualCpp) {
cppCompiler.args "/std:${cpp_version}"
}
}
}
}
}
}
subprojects {
project.buildDir = rootProject.buildDir
plugins.withType(CppPlugin).whenPluginAdded {
project.apply plugin: 'visual-studio'
}
ext.binaryPublishers = [:]
ext.binaryArtifacts = { scope, name ->
if (binaryPublishers[name] == null)
binaryPublishers[name] = []
binaryPublishers[name] << [scope: scope]
}
project.model {
binaries {
withType(NativeBinarySpec) {
// Create classified binary zip task i.e -> maven_test-2021.3.1-cpp-linuxathena.zip
def bin = it
if (it.buildable && (it instanceof SharedLibraryBinary || it instanceof StaticLibraryBinary)) {
def sharedlib = bin instanceof SharedLibraryBinary
def staticlib = bin instanceof StaticLibraryBinary
def taskSuffix = "${component.name}${targetPlatform.name}${buildType.name}"
def source = (sharedlib ? bin.sharedLibraryFile : bin.staticLibraryFile)
def type = (sharedlib ? "" : "static")
def ziptask = task "zip${taskSuffix}${type}"(type: Zip) {
def allsrc = [source]
if (sharedlib && bin.targetPlatform.operatingSystem.isWindows()) {
allsrc << bin.sharedLibraryLinkFile
} else if (staticlib && bin.targetPlatform.operatingSystem.isWindows()) {
allsrc << bin.staticLibraryFile
}
destinationDirectory = outputFolder
ext.platformArc = targetPlatform.name
platformArc = platformArc.replace("${OS_NAME}", "")
from(allsrc as Set<File>) {
into("${OS_NAME}/${platformArc}/" + (sharedlib ? "shared" : "static"))
}
from(licenseFile) {
into("${OS_NAME}/${platformArc}/" + (sharedlib ? "shared" : "static"))
}
baseName = component.name
classifier = targetPlatform.name + (buildType.name == 'debug' ? "${type}debug" : "${type}")
dependsOn(build)
dependsOn bin.tasks.withType(AbstractLinkTask)
}
// Binary Publisher classifier
if (binaryPublishers[bin.component.name] != null) {
binaryPublishers[bin.component.name].each { entry ->
entry.scope.artifact(ziptask) {
classifier targetPlatform.name + (buildType.name == 'debug' ? "${type}debug" : "${type}")
}
}
}
}
}
}
}
}
wrapper {
gradleVersion = '7.3.3' // new but... with model?
}