-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
118 lines (92 loc) · 3.16 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
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
#! ruby
# Copyright (c) 2007 Aemon Cannon, aemoncannon -at- gmail -dot- com
#
# This file is part of flyparse-mode
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require 'fileutils'
require 'date'
# Just like File.expand_path, but for windows systems it
# capitalizes the drive name and ensures backslashes are used
def normalize_path(path, *dirs)
path = File.expand_path(path, *dirs)
if PLATFORM =~ /mswin/
path.gsub!('/', '\\').gsub!(/^[a-zA-Z]+:/) { |s| s.upcase }
else
path
end
end
JAVA_CLASSPATH_DELIM = PLATFORM =~ /mswin/ ? ";" : ":"
JAVA_CLASSPATH = ["bin", "lib/antlr-2.7.7.jar", "lib/antlr-3.1.jar", "lib/antlr-runtime-3.1.jar", "lib/stringtemplate-3.2.jar"]
ENV["CLASSPATH"] = (ENV["CLASSPATH"].to_s +
JAVA_CLASSPATH_DELIM +
JAVA_CLASSPATH.collect{|ea| normalize_path(ea) }.join(JAVA_CLASSPATH_DELIM))
ARCHIVE_NAME = "flyparse_#{Date.today}.zip"
RAKE = PLATFORM =~ /mswin/ ? "rake.bat" : "rake"
LANGUAGES = ["as3", "css", "javascript"]
JAR_TARGET = "flyparse-parsers.jar"
JAVAC_OPTIONS = [] # -g (for debugging)
COMMON_TARGET = "bin/.common"
FLYPARSE_CORE_SOURCE = FileList["src/**/*.java"]
file COMMON_TARGET => FLYPARSE_CORE_SOURCE do
sh "javac #{JAVAC_OPTIONS.join(" ")} #{FLYPARSE_CORE_SOURCE.join(" ")} -d bin"
touch COMMON_TARGET
end
task :all_languages => [] do
LANGUAGES.each{|l|
Dir.chdir(l.to_s){
sh "#{RAKE}"
}
}
end
file JAR_TARGET => [:build] do
Dir.chdir("bin"){
sh "jar cf ../lib/#{JAR_TARGET} emacs"
}
end
task :make_archive => [:make_jar] do
FileUtils.rm_f Dir.glob('./*.zip')
archive_files = ["COPYING", "README", "flyparse-mode.el",
"lib/flyparse-parsers.jar",
"as3/as3-flyparse-extensions.el",
"css/css-flyparse-extensions.el",
"javascript/javascript-flyparse-extensions.el"]
sh "7z a -r -tZip -x!*.svn #{ARCHIVE_NAME} #{archive_files.join(" ")}"
if $?.success? and File.exist? ARCHIVE_NAME
puts "Created deployment archive successfully."
else
puts "Failed to create deployment archive."
end
end
task :test => [] do
LANGUAGES.each{|l|
Dir.chdir(l){
sh "#{RAKE} test"
}
}
end
task :deploy => [:build, :make_archive] do
end
task :build => [:clean, COMMON_TARGET, :all_languages] do
end
task :default => [JAR_TARGET]
task :clean => [] do
rm_f COMMON_TARGET
FileUtils.rm_rf Dir.glob('bin/*')
LANGUAGES.each{|l|
Dir.chdir(l){
sh "#{RAKE} clean"
}
}
end