-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
169 lines (143 loc) · 4.17 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
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.6
version = '0.2'
description = 'some interesting description'
String libDir = "$projectDir/lib"
String genLibDir = "$projectDir/lib-gen"
String specDir = "$projectDir/specs"
String genDir = "$projectDir/src-gen"
String parserGenDir = "$genDir/de/hopp/generator/frontend"
String flexSpec = "$specDir/bdl.flex"
String cupSpec = "$specDir/bdl.cup"
String bdlSpec = "$specDir/bdl.katja"
String mhsSpec = "$specDir/mhs.katja"
String modelSpec = "$specDir/cpp.katja"
String flexLib = "$libDir/JFlex.jar"
String cupLib = "$libDir/java-cup-11a.jar"
String katja = "$libDir/katja.jar"
String katjaCommon = "$genLibDir/katja.common.jar"
String bdl = "$genLibDir/BDL.jar"
String mhs = "$genLibDir/MHS.jar"
String model = "$genLibDir/CPP.jar"
String cupParserFile = "BDLFileParser"
String symbolFile = "BDLFileSymbols"
String flexScanner = "$parserGenDir/BDLFileScanner.java"
String cupParser = "$parserGenDir/${cupParserFile}.java"
String symTab = "$parserGenDir/${symbolFile}.java"
repositories {
mavenCentral()
}
dependencies {
compile group: 'de.jflex', name: 'jflex', version: '1.4.3'
compile group: 'commons-io', name: 'commons-io', version: '2.4'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.1'
// compile group: 'net.sf.squirrel-sql.thirdparty-non-maven', name: 'java-cup', version: '0.11a'
compile files("$cupLib")
compile files("$katjaCommon", "$bdl", "$mhs", "$model")
testCompile group: 'junit', name: 'junit', version: '4.+'
}
sourceSets {
main {
java {
srcDirs "src-gen"
}
resources {
srcDirs 'src/main/resources'
}
}
}
eclipse {
classpath {
defaultOutputDir = file('build-eclipse')
}
}
// removes src-gen folder
task removeGen << {
delete "$genDir"
delete "$genLibDir"
}
// builds the ast model of bdl files and katja common
task buildBDL {
inputs.files("$katja", "$bdlSpec")
outputs.files("$bdl", "$katjaCommon")
doLast {
ant.java(jar:"$katja",fork:true) {
arg(value: "-b")
arg(value: "java")
arg(value: "-d")
arg(value: "$genLibDir")
arg(value: "-o")
arg(value: "-j")
arg(value: "$bdlSpec")
}
}
}
// builds the ast model of mhs files
task buildMHS {
inputs.files("$katja", "$mhsSpec")
outputs.files("$mhs")
doLast {
ant.java(jar:"$katja",fork:true) {
arg(value: "-b")
arg(value: "java")
arg(value: "-d")
arg(value: "$genLibDir")
arg(value: "-o")
arg(value: "$mhsSpec")
}
}
}
// builds the c/c++ model used by the generator
task buildCPP {
inputs.files("$katja", "$modelSpec")
outputs.files("$model")
doLast {
ant.java(jar:"$katja",fork:true) {
arg(value: "-b")
arg(value: "java")
arg(value: "-d")
arg(value: "$genLibDir")
arg(value: "-o")
arg(value: "$modelSpec")
}
}
}
task runKatja
task runJFlex {
inputs.files("$flexSpec", "$flexLib")
outputs.file("$flexScanner")
doLast {
ant.taskdef name: 'jflex', classname: 'JFlex.anttask.JFlexTask', classpath: flexLib
ant.jflex(file: flexSpec, outdir: parserGenDir)
}
}
task runCup {
inputs.files("$cupSpec", "$cupLib")
outputs.files("$cupParser", "$symTab")
doLast {
ant.taskdef name: 'jcup', classname: 'java_cup.anttask.CUPTask', classpath: cupLib
ant.jcup(srcfile: cupSpec, destdir: genDir, parser: cupParserFile, symbols: symbolFile)
// srcfile, destdir, interface = true/false, package
}
}
task generateResources
clean.dependsOn removeGen
//runKatja.dependsOn buildAST
runKatja.dependsOn buildBDL
runKatja.dependsOn buildMHS
runKatja.dependsOn buildCPP
generateResources.dependsOn runKatja
generateResources.dependsOn runJFlex
generateResources.dependsOn runCup
compileJava.dependsOn generateResources
jar {
// add main class to manifest
manifest {
attributes("Main-Class": "de.hopp.generator.Main")
}
// the following line is responsible for packaging all compile dependencies as well
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
// also add the deploy folder
//from "deploy"
}