forked from timtadh/jpdg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildfile
287 lines (251 loc) · 8.05 KB
/
Buildfile
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#!/usr/bin/env ruby
require 'rubygems'
require 'buildr'
require 'rake'
Java.load
require "antwrap"
if File::exists?('parsemis/Buildfile')
pwd = Dir.pwd
Dir.chdir File::join(pwd, 'parsemis')
load "./Buildfile"
puts project('parsemis').base_dir
Dir.chdir pwd
end
repositories.remote << 'http://mirrors.ibiblio.org/pub/mirrors/maven2/'
repositories.remote << 'http://repo1.maven.org/'
repositories.remote << 'https://oss.sonatype.org/content/repositories/releases/'
#repositories.remote << 'http://mvnrepository.com/'
Project.local_task :run
baksmali_url = 'https://bitbucket.org/JesusFreke/smali/downloads/baksmali-2.0.2.jar'
baksmali_2 = "baksmali:baksmali:jar:2.0.2"
download(artifact(baksmali_2)=>baksmali_url)
smali_url = 'https://bitbucket.org/JesusFreke/smali/downloads/smali-2.0.2.jar'
smali_2 = "smali:smali:jar:2.0.2"
download(artifact(smali_2)=>smali_url)
heros_libs = [
'com.google.guava:guava:jar:14.0.1',
'org.slf4j:slf4j-api:jar:1.7.5',
'org.slf4j:slf4j-simple:jar:1.7.5',
]
jasmin_libs = [
'libs/java-cup-11a.jar',
]
soot_libs = [
'libs/util-2.0.6-dev.jar',
'libs/dexlib2-2.0.6-dev.jar',
'soot/libs/polyglot.jar',
'soot/libs/AXMLPrinter2.jar',
'org.apache.commons:commons-lang3:jar:3.4',
'org.ow2.asm:asm-debug-all:jar:5.0.3',
'com.google.guava:guava:jar:18.0',
baksmali_2,
] + jasmin_libs
soot_test_libs = [
'org.hamcrest:hamcrest-all:jar:1.3',
'org.mockito:mockito-all:jar:1.10.8',
#'org.powermock:powermock-mockito-release-full:jar:1.6.1',
'org.powermock:powermock-module-junit4:jar:1.6.1',
'org.powermock:powermock-module-junit4-common:jar:1.6.1',
'org.powermock:powermock-api-mockito:jar:1.6.1',
'org.powermock:powermock-reflect:jar:1.6.1',
'org.powermock:powermock-core:jar:1.6.1',
'org.powermock:powermock-api-support:jar:1.6.1',
'org.javassist:javassist:jar:3.18.2-GA',
]
ant_lib = [
'org.apache.ant:ant:jar:1.7.0',
]
parsemis_libs = [
'antlr:antlr:jar:2.7.6',
'org.prefuse:prefuse:jar:beta-20071021',
]
jpdg_libs = [
#'org.javatuples:javatuples:jar:1.2',
#'com.cedarsoftware:json-io:jar:2.4.1',
'com.google.code.gson:gson:jar:2.2.4',
'org.apache.commons:commons-io:jar:1.3.2',
'commons-codec:commons-codec:jar:1.4',
'commons-lang:commons-lang:jar:2.6',
'commons-cli:commons-cli:jar:1.2',
]
jpdg_extra = [
'libs/dexlib2-2.0.6-dev.jar',
]
task :jas do
jas = ant("jas") do |ant|
ant.mkdir(dir:"jasmin/target")
ant.mkdir(dir:"jasmin/target/classes")
ant.javac(
destdir:"jasmin/target/classes",
optimize:"true",
source:"1.5",
target:"1.5",
) do |ant|
ant.src(path:"jasmin/lib/jas/src/jas")
end
end
ant("autogen_compile") do |ant|
ant.javac(
destdir:"jasmin/target/classes",
classpath:"jasmin/target/classes",
optimize:"true",
source:"1.5",
target:"1.5",
) do |ant|
ant.src(path:"jasmin/lib/jas/src/scm/autogen")
end
end
ant("autogen_run") do |ant|
ant.mkdir(dir:"jasmin/target/generated")
ant.mkdir(dir:"jasmin/target/generated/scm")
ant.java(
classname:"autogen",
classpath:"jasmin/target/classes",
dir:"jasmin/target/generated/scm",
fork:true,
)
end
ant("autogen_compile") do |ant|
ant.javac(
destdir:"jasmin/target/classes",
classpath:"jasmin/target/classes",
optimize:"true",
source:"1.5",
target:"1.5",
) do |ant|
ant.src(path:"jasmin/lib/jas/src/scm")
ant.src(path:"jasmin/target/generated/scm")
end
end
end
jpdg_layout = Layout.new
jpdg_layout[:source] = "source"
define 'jpdg', layout: jpdg_layout do |soot|
project.version = 'git-master'
run.using main: ['edu.cwru.jpdg.JPDG']
package(:jar).with(:manifest => {
'Main-Class'=>'edu.cwru.jpdg.JPDG'
}).merge(
[ 'libs/soot.jar' ] + jpdg_libs + jpdg_extra
)
compile.with [ 'libs/soot.jar' ] + jpdg_libs
test_libs = [
'org.hamcrest:hamcrest-all:jar:1.3',
]
test.with test_libs
test.using :java_args => ['-ea']
task :export_libs do |t|
for lib in jpdg_libs
artifact(lib).invoke
end
for lib in test_libs
artifact(lib).invoke
end
mkdir_p _("libs/ext")
lib_paths = Array.new(project.compile.dependencies).reject do |t|
## remove dependencies which are not downloaded artifacts
t.class != Buildr::Artifact
end .collect do |t|
t.to_s
end
cp lib_paths, _("libs/ext")
test_paths = Array.new(project.test.dependencies).reject do |t|
## remove dependencies which are not downloaded artifacts
t.class != Buildr::Artifact
end .collect do |t|
t.to_s
end
cp test_paths, _("libs/ext")
end
end
jasmin_layout = Layout.new
jasmin_layout[:source, :main, :java] = "src"
jasmin_layout[:target,] = "target"
jasmin_layout[:target, :main] = "target/main"
jasmin_layout[:target, :main, :classes] = "target/main/classes"
define 'jasmin', base_dir: "jasmin", layout: jasmin_layout do
project.version = 'git-master'
mkdir_p _('target/classes')
compile.enhance([:jas])
compile.with jasmin_libs + [_('target/classes')]
compile.options.target = '1.5'
compile.options.source = '1.5'
package(:jar)
end
def git_commit(dir)
commit = `git --git-dir='#{dir}' rev-parse HEAD`.strip()
puts "the commit = " + commit
return commit
end
jasmin_jar = File::join(project('jpdg').base_dir, 'libs', 'jasmin.jar')
task jasmin_jar do
if File::exists?('jasmin-version') and File::exists?(jasmin_jar)
f = File::open('jasmin-version')
built_commit = f.read().strip()
f.close()
else
build_commit = 'none'
end
git_dir = File::join(project('jpdg').base_dir, '.git', 'modules', 'jasmin')
cur_commit = git_commit(git_dir)
if built_commit != cur_commit
project('jasmin')::task('package').invoke
cp File::join(project('jasmin').base_dir, 'target', 'jasmin-git-master.jar'), jasmin_jar
f = File::open('jasmin-version', 'w')
f.write(cur_commit)
f.close()
end
end
#parsemis_layout = Layout.new
#parsemis_layout[:source, :main, :java] = "src"
##parsemis_layout[:target,] = "target"
##parsemis_layout[:target, :main] = "target/main"
##parsemis_layout[:target, :main, :classes] = "target/main/classes"
#define 'parsemis', base_dir: "parsemis", layout: parsemis_layout do
#project.version = 'git-master'
#mkdir_p _('target/classes')
#compile.with parsemis_libs
##compile.options.target = '1.5'
##compile.options.source = '1.5'
#package(:jar)
#end
heros_layout = Layout.new
heros_layout[:source, :main, :java] = "src"
heros_layout[:target,] = "target"
heros_layout[:target, :main] = "target/main"
heros_layout[:target, :main, :classes] = "target/main/classes"
define 'heros', base_dir: "heros", layout: heros_layout do
project.version = 'git-master'
package(:jar)
compile.with heros_libs
compile.using :lint => 'unchecked', :target => '1.5', :source => '1.5'
test.with 'org.hamcrest:hamcrest-all:jar:1.3'
test.using :java_args => ['-ea']
end
soot_layout = Layout.new
soot_layout[:source, :main, :java] = "src"
soot_layout[:source, :test, :java] = "tests"
define 'soot', base_dir: "soot", layout: soot_layout do |soot|
project.version = 'git-master'
package(:jar).with(:manifest => {
'Main-Class'=>'soot.Main'
}).merge(
soot_libs + heros_libs + jasmin_libs + [ 'libs/jasmin.jar', project('heros') ]
)
compile.with soot_libs + ant_lib + jasmin_libs + [ 'libs/jasmin.jar', project('heros') ]
compile.using :lint => 'none'
compile.from [
"soot/generated/singletons",
"soot/generated/options",
"soot/generated/sablecc",
"soot/generated/jastadd",
]
test.with soot_test_libs
test.using :java_args => ['-ea']
mkdir_p _("target/main/classes/soot/baf/toolkits/base/")
cp _("src/soot/baf/toolkits/base/peephole.dat"), _("target/main/classes/soot/baf/toolkits/base/")
mkdir_p _("target/main/classes/soot/jimple/parser/parser/")
cp _("generated/sablecc/soot/jimple/parser/parser/parser.dat"), _("target/main/classes/soot/jimple/parser/parser/parser.dat")
mkdir_p _("target/main/classes/soot/jimple/parser/lexer/")
cp _("generated/sablecc/soot/jimple/parser/lexer/lexer.dat"), _("target/main/classes/soot/jimple/parser/lexer/lexer.dat")
end