-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
32 lines (25 loc) · 869 Bytes
/
Rakefile
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
# Usage: rake com.example.MonkeyShines
# Source goes under ./src
# Classes end up under ./target
require 'rake/clean'
libs = FileList["lib/*"]
libs << "target"
JavaClassPaths = libs.join(":")
# regex should weed out anything containing "/", i.e. paths
rule(/^[^\/]+\.\w/ => lambda {|tn| "src/#{tn.gsub(".", "/")}.class"} ) do |t|
# system(command)
end
rule ".class" => [".java", "target"] do |t|
puts command = "javac -classpath #{JavaClassPaths} #{t.source} -d target"
system(command)
target_path = t.name.sub("src/", "target/").sub(/\.class$/, "")
puts command = "javap -c -v #{target_path} > #{target_path}.bc"
system(command)
puts command = "xxd #{target_path}.class > #{target_path}.hex"
end
desc "make directories, or whatever"
task :setup => ["src", "lib"]
directory "target"
directory "src"
directory "lib"
CLEAN.include("target")