This repository has been archived by the owner on Aug 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Rakefile
83 lines (66 loc) · 2.1 KB
/
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
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
require "rubygems"
gem "hoe", "~> 2.3"
require "hoe"
gem "rake-compiler", "~> 0.6"
require "rake/extensiontask"
Hoe.plugin :debugging, :doofus, :git
Hoe.plugins.delete :rubyforge
Hoe.spec "johnson" do
developer "John Barnette", "[email protected]"
developer "Aaron Patterson", "[email protected]"
developer "Yehuda Katz", "[email protected]"
developer "Matthew Draper", "[email protected]"
self.extra_rdoc_files = FileList["*.rdoc"]
self.history_file = "CHANGELOG.rdoc"
self.readme_file = "README.rdoc"
self.test_globs = %w(test/**/*_test.rb)
self.spec_extras[:extensions] = %w(ext/spidermonkey/extconf.rb)
extra_dev_deps << ["rake-compiler", "~> 0.6"]
clean_globs << "ext/**/Makefile"
clean_globs << "ext/**/*.{o,so,bundle,a,log}"
clean_globs << "ext/spidermonkey/immutable_node.c"
clean_globs << "lib/johnson/**/*.{bundle,so}"
clean_globs << "tmp"
clean_globs << "vendor/spidermonkey/**/*.OBJ"
Rake::ExtensionTask.new "spidermonkey", spec do |ext|
ext.lib_dir = "lib/johnson/spidermonkey"
end
end
task :clean do
Dir.chdir "vendor/spidermonkey" do
sh "make clean -f Makefile.ref" unless Dir["**/libjs.a"].empty?
end
end
task :test => :compile
require "erb"
GENERATED_NODE = "ext/spidermonkey/immutable_node.c"
task :package => GENERATED_NODE
task :check_manifest => GENERATED_NODE
def jsops
ops = []
File.open("vendor/spidermonkey/jsopcode.tbl", "rb") { |f|
f.each_line do |line|
if line =~ /^OPDEF\((\w+),/
ops << $1
end
end
}
ops
end
def tokens
toks = []
File.open("vendor/spidermonkey/jsscan.h", "rb") { |f|
f.each_line do |line|
line.scan(/TOK_\w+/).each do |token|
next if token == "TOK_ERROR"
toks << token
end
end
}
toks.uniq
end
file GENERATED_NODE => "ext/spidermonkey/immutable_node.c.erb" do |t|
template = ERB.new(File.open(t.prerequisites.first, "rb") { |x| x.read })
File.open(GENERATED_NODE, "wb") { |f| f.write template.result(binding) }
end
file "ext/spidermonkey/extconf.rb" => GENERATED_NODE