-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle
More file actions
182 lines (144 loc) · 4.94 KB
/
build.gradle
File metadata and controls
182 lines (144 loc) · 4.94 KB
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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'net.sf.proguard:proguard-gradle:5.2.1'
}
}
apply plugin:'scala'
apply plugin:'eclipse'
apply plugin:'application'
import org.apache.tools.ant.taskdefs.condition.Os
// application settings
applicationName = "svparse"
applicationDefaultJvmArgs = ["-Xmx6g"]
mainClassName = 'com.github.svstuff.systemverilog.Driver'
repositories{
mavenCentral()
mavenLocal()
}
dependencies{
compile 'org.scala-lang:scala-library:2.11.8'
compile 'org.scala-lang.modules:scala-xml_2.11:1.0.4'
compile 'com.typesafe.scala-logging:scala-logging_2.11:3.4.0'
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'org.slf4j:slf4j-simple:1.7.21'
compile 'org.apache.commons:commons-lang3:3.4'
compile files('lib/antlr-4.4-complete.jar')
}
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}
task antlr(type: Exec) {
workingDir = "${projectDir}"
executable = './regen.py'
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
executable = 'python'
args = ['regen.py']
}
inputs.files files('regen.py', 'SVParser.g4')
outputs.files files {
file("src/main/java/com/github/svstuff/systemverilog/generated").listFiles() +
file("src/main/scala/com/github/svstuff/systemverilog/generated").listFiles()
}
}
compileJava.dependsOn antlr
// Configure jar task
jar {
manifest {
attributes 'Main-Class': mainClassName
}
}
// Make fat jar~ 14MB
task fatJar(type: Jar) {
manifest {
attributes 'Main-Class': mainClassName
}
baseName = project.name + '-fat'
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
} {
exclude "META-INF/*.MF"
exclude "*.properties"
// text-files
exclude "**/*.txt"
// antlr example files
exclude "org/antlr/v4/tool/**/*.stg"
}
with jar
}
// Make slim jar by optimizing fat jar ~ 1.6MB
task slimJar(type: proguard.gradle.ProGuardTask) {
dependsOn fatJar
injars project.fatJar.archivePath.toString()
libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
outjars project.fatJar.archivePath.toString().replaceFirst(/-fat\.jar$/, '-slim.jar')
// Keep main class
keepclasseswithmembers "public class ${mainClassName} { \
public static void main(java.lang.String[]); \
}"
// General settings
dontobfuscate
// Workaround
// See: https://sourceforge.net/p/proguard/bugs/462/
optimizations '!code/allocation/variable'
// Options for libs
// antlr library omits this
dontwarn 'org.antlr.stringtemplate.StringTemplate'
// dynamically loaded constructors
keepclasseswithmembers 'class * { \
public <init>(org.antlr.v4.codegen.model.decl.StructDecl,java.lang.String); \
}'
keep 'class org.antlr.v4.codegen.model.decl.StructDecl'
// superflurous note about dynamically accessing 'clone', as clone is always kept
dontnote 'org.apache.commons.lang3.ObjectUtils'
// Options for SCALA
// See http://proguard.sourceforge.net/#manual/examples.html#scala
dontwarn 'scala.**'
keepclassmembers 'class * { \
** MODULE$; \
}'
keepclassmembernames 'class scala.concurrent.forkjoin.ForkJoinPool { \
long eventCount; \
int workerCounts; \
int runControl; \
scala.concurrent.forkjoin.ForkJoinPool$WaitQueueNode syncStack; \
scala.concurrent.forkjoin.ForkJoinPool$WaitQueueNode spareStack; \
}'
keepclassmembernames 'class scala.concurrent.forkjoin.ForkJoinWorkerThread { \
int base; \
int sp; \
int runState; \
}'
keepclassmembernames 'class scala.concurrent.forkjoin.ForkJoinTask { \
int status; \
}'
keepclassmembernames 'class scala.concurrent.forkjoin.LinkedTransferQueue { \
scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference head; \
scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference tail; \
scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference cleanMe; \
}'
}
task installSlimDist {
String libDir = "${buildDir}/install/${applicationName}-slim/lib"
String binDir = "${buildDir}/install/${applicationName}-slim/bin"
inputs.file slimJar
outputs.dir libDir
outputs.dir binDir
doLast {
copy {
from slimJar
into libDir
rename { "${applicationName}.jar" }
}
}
doLast {
file(binDir).mkdir()
File linRunner = file(new File(binDir, applicationName))
File winRunner = file(new File(binDir, "${applicationName}.bat"))
linRunner.text = "#!/bin/bash\njava ${applicationDefaultJvmArgs.join(' ')} -jar ${libDir}/${applicationName}.jar \$@"
linRunner.executable = true
winRunner.text = "java ${applicationDefaultJvmArgs.join(' ')} -jar ${libDir}/${applicationName}.jar %*"
}
}