-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
196 lines (166 loc) · 4.96 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import java.util.stream.Stream
import java.util.regex.Pattern
import java.nio.file.Paths
import java.nio.file.Files
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.13.0"
}
}
// Project-Type
apply plugin: "cpp"
// Test Suite
apply plugin: "google-test"
// IDEs
apply plugin: "visual-studio"
apply plugin: "com.diffplug.gradle.spotless"
allprojects {
model {
platforms {
x86 {
architecture "x86"
}
x64 {
architecture "x64"
}
}
buildTypes {
debug
release
}
}
}
model {
visualStudio {
solution {
solutionFile.location = ".vs/${name}.sln"
solutionFile.withContent { TextProvider content ->
content.asBuilder().insert(0, "# GENERATED FILE: DO NOT EDIT\n")
content.text = content.text.replaceAll("HideSolutionNode = FALSE", "HideSolutionNode = TRUE")
}
}
}
components {
cppstreams(NativeLibrarySpec) {
if(System.properties['sun.arch.data.model'] == "64") {
targetPlatform "x64"
} else {
targetPlatform "x86"
}
}
}
binaries {
all {
if (toolChain in Gcc) {
cppCompiler.args "-std=c++11", "-Wall", "-Wextra", "-fPIC"
}
if (toolChain in Clang) {
cppCompiler.args "-std=c++11", "-Weverything", "-Wno-reserved-id-macro", "-Wno-deprecated-dynamic-exception-spec", "-Wno-c++98-compat", "-Wno-sign-conversion"
}
if (toolChain in VisualCpp) {
cppCompiler.args "/W4", "/FS", "/EHsc"
}
if(buildType == buildTypes.debug) {
cppCompiler.define "__DEBUG__"
if (toolChain in Gcc) {
cppCompiler.args "-Og", "-g3"
}
if (toolChain in Clang) {
cppCompiler.args "-O0", "-g"
}
if (toolChain in VisualCpp) {
cppCompiler.args "/Od", "/Z7"
}
}
if(buildType == buildTypes.release) {
cppCompiler.define "__NDEBUG__"
if (toolChain in Gcc) {
cppCompiler.args "-Ofast", "-g0"
}
if (toolChain in Clang) {
cppCompiler.args "-Ofast", "-g0"
}
if (toolChain in VisualCpp) {
cppCompiler.args "/O2"
}
}
}
withType(GoogleTestTestSuiteBinarySpec) {
lib project: ":lib", library: "googleTest", linkage: "static"
cppCompiler.define "GOOGLE_TEST"
if (targetPlatform.operatingSystem.linux) {
cppCompiler.args "-pthread"
linker.args "-pthread"
}
}
}
}
spotless {
format "cpp", {
target "src/**/*.h", "src/**/*.cpp"
licenseHeaderFile "LICENSE-header.txt", "#"
}
}
task doc {
dependsOn "generateHTMLdoc"
dependsOn "generatePDFdoc"
}
task generateHTMLdoc(type: Zip, dependsOn: "runDoxygen") {
inputs.dir "build/doc/gen/html"
outputs.files "build/doc/${project.name}-doc.zip"
baseName = "${project.name}-doc"
version = ""
destinationDir = file("build/doc")
from "build/doc/gen/html"
}
task generatePDFdoc(type: Exec, dependsOn: "runDoxygen") {
onlyIf {
isCommandAvailable("pdflatex") && isCommandAvailable("make")
}
inputs.dir "build/doc/gen/latex"
outputs.files "build/doc/${project.name}-doc.pdf"
doFirst {
def log = file("build/tmp/generatePDFdoc/output.txt")
log.getParentFile().mkdirs()
standardOutput = new FileOutputStream(log)
errorOutput = standardOutput
}
doLast {
copy {
from "build/doc/gen/latex"
into "build/doc"
include "refman.pdf"
rename "refman.pdf", "${project.name}-doc.pdf"
}
}
workingDir "build/doc/gen/latex"
executable "make"
}
task runDoxygen(type: Exec) {
onlyIf {
isCommandAvailable("doxygen")
}
inputs.dir "src"
inputs.files "Doxyfile"
outputs.dirs "build/doc/gen"
doFirst {
def log = file("build/tmp/runDoxygen/output.txt")
log.getParentFile().mkdirs()
standardOutput = new FileOutputStream(log)
file("build/doc/gen").mkdirs()
}
executable "doxygen"
args "Doxyfile"
}
def isCommandAvailable(String exec) {
if(System.getProperty("os.name").toLowerCase().contains("windows"))
exec += ".exe"
return Stream.of(System.getenv("PATH").split(Pattern.quote(File.pathSeparator)))
.map({file -> Paths.get(file)})
.anyMatch({path -> Files.exists(path.resolve(exec))});
}