Skip to content

Commit 29393a7

Browse files
committed
SimonStewart: Initial import from the original source
r3753
1 parent 2dd29df commit 29393a7

File tree

80 files changed

+5767
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5767
-0
lines changed

Rakefile

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Build file for WebDriver. I wonder if this could be run with JRuby?
2+
3+
require 'rake'
4+
require 'rake/testtask'
5+
require 'rake/rdoctask'
6+
7+
task :default => [:test]
8+
9+
task :build => [:common, :htmlunit]
10+
11+
task :clean do
12+
rm_rf 'common/build'
13+
rm_rf 'htmlunit/build'
14+
rm_rf 'jobbie/build'
15+
end
16+
17+
task :test => [:test_htmlunit] do
18+
end
19+
20+
%w(common htmlunit jobbie).each do |driver|
21+
source = FileList["#{driver}/src/java/**/*.java"]
22+
libs = ["#{driver}/lib/runtime/*.jar", "#{driver}/lib/buildtime/*.jar", "common/build/webdriver-common.jar"]
23+
deps = Array.new
24+
deps = %w(common/build/webdriver-common.jar) unless driver == "common"
25+
deps |= source
26+
file "#{driver}/build/webdriver-#{driver}.jar" => deps do
27+
javac :jar => "#{driver}/build/webdriver-#{driver}.jar",
28+
:sources => source,
29+
:classpath => libs
30+
end
31+
tsk = task "#{driver}" => ["#{driver}/build/webdriver-#{driver}.jar"]
32+
tsk.enhance(%w(common/build/webdriver-common.jar)) unless driver == "common"
33+
34+
libs << "#{driver}/build/webdriver-#{driver}.jar"
35+
libs << "common/lib/buildtime/*.jar"
36+
test_source = FileList["#{driver}/test/java/**/*.java"]
37+
deps << "#{driver}/build/webdriver-#{driver}.jar"
38+
if (driver != "common") then
39+
deps << "common/build/webdriver-common-test.jar"
40+
libs << "common/build/webdriver-common-test.jar"
41+
end
42+
file "#{driver}/build/webdriver-#{driver}-test.jar" => deps do
43+
javac :jar => "#{driver}/build/webdriver-#{driver}-test.jar",
44+
:sources => test_source,
45+
:classpath => libs
46+
end
47+
tsk = task "test_#{driver}" => ["#{driver}/build/webdriver-#{driver}-test.jar"] do
48+
libs << "#{driver}/build/webdriver-#{driver}-test.jar"
49+
junit :in => driver, :classpath => libs, :native_path => ["#{driver}/build", "#{driver}/lib/runtime"]
50+
end
51+
end
52+
53+
# C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:C:\WINDOWS\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\Microsoft.mshtml.dll /reference:obj\Debug\Interop.SHDocVw.dll /debug+ /debug:full /optimize- /out:obj\Debug\WebDriver.dll /target:library IeWrapper.cs NavigableDocument.cs NoSuchElementException.cs Properties\AssemblyInfo.cs UnsupportedOperationException.cs WebDriver.cs WrappedWebElement.cs
54+
# C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll" /reference:C:\WINDOWS\assembly\GAC\nunit.framework\2.2.0.0__96d09a1eb7f44a77\nunit.framework.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:C:\work\webdriver-qs\build\jobbie\WebDriver.dll /reference:obj\Debug\Interop.SHDocVw.dll /debug+ /debug:full /optimize- /out:obj\Debug\Test.dll /target:library IeWrapperJavascriptTest.cs IeWrapperTest.cs Properties\AssemblyInfo.cs XPathTest.cs
55+
56+
file 'jobbie/build/webdriver-jobbie.dll' => FileList['jobbie/src/csharp/**/*.cs'] do
57+
csc :out => 'jobbie/build/webdriver-jobbie.dll', :sources => FileList['jobbie/src/csharp/**/*.cs'],
58+
:references => ['C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll', 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll', 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll', 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll', 'C:\WINDOWS\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\Microsoft.mshtml.dll', 'jobbie\lib\buildtime\Interop.SHDocVw.dll']
59+
end
60+
61+
def windows?
62+
return RUBY_PLATFORM =~ /win32/i
63+
end
64+
65+
if windows? then
66+
Rake::Task[:build].enhance([:jobbie])
67+
Rake::Task[:test].enhance([:test_jobbie])
68+
Rake::Task[:test_jobbie].enhance([:jobbie])
69+
Rake::Task[:jobbie].enhance %w(jobbie/build/webdriver-jobbie.dll) do
70+
sh 'regasm jobbie/build/webdriver-jobbie.dll', :verbose => false
71+
sh 'regasm /regfile:jobbie/build/webdriver.reg jobbie/build/webdriver-jobbie.dll', :verbose => false
72+
end
73+
end
74+
75+
def javac(args)
76+
# mandatory args
77+
out = (args[:jar] or raise 'javac: please specify the :jar parameter')
78+
source_patterns = (args[:sources] or raise 'javac: please specify the :sources parameter')
79+
sources = FileList.new(source_patterns)
80+
raise("No source files found at #{sources.join(', ')}") if sources.empty?
81+
82+
puts "Building: #{out}"
83+
84+
# optional args
85+
unless args[:exclude].nil?
86+
args[:exclude].each { |pattern| sources.exclude(pattern) }
87+
end
88+
debug = (args[:debug] or true)
89+
temp_classpath = (args[:classpath]) || []
90+
91+
classpath = FileList.new
92+
temp_classpath.each do |item|
93+
classpath.add item
94+
end
95+
96+
target_dir = "#{out}.classes"
97+
mkdir_p target_dir, :verbose => false
98+
99+
compile_string = "javac "
100+
compile_string += "-source 1.4 -target 1.4 "
101+
compile_string += "-g " if debug
102+
compile_string += "-d #{target_dir} "
103+
104+
compile_string += "-cp " + classpath.join(File::PATH_SEPARATOR) + " " if classpath.length > 1
105+
106+
sources.each do |source|
107+
compile_string += " #{source}"
108+
end
109+
110+
sh compile_string, :verbose => false
111+
112+
jar_string = "jar cf #{out} -C #{target_dir} ."
113+
sh jar_string, :verbose => false
114+
115+
rm_rf target_dir, :verbose => false
116+
end
117+
118+
def junit(args)
119+
using = args[:in]
120+
121+
source_dir = "#{using}/test/java"
122+
source_glob = source_dir + File::SEPARATOR + '**' + File::SEPARATOR + '*.java'
123+
124+
temp_classpath = (args[:classpath]) || []
125+
classpath = FileList.new
126+
temp_classpath.each do |item|
127+
classpath.add item
128+
end
129+
130+
tests = FileList.new(source_dir + File::SEPARATOR + '**' + File::SEPARATOR + '*Test.java')
131+
tests.exclude '**/Abstract*'
132+
133+
test_string = 'java '
134+
test_string += '-cp ' + classpath.join(File::PATH_SEPARATOR) + ' ' if classpath.length > 1
135+
test_string += '-Djava.library.path=' + args[:native_path].join(File::PATH_SEPARATOR) + ' ' unless args[:native_path].nil?
136+
test_string += 'junit.textui.TestRunner'
137+
tests.each do |test|
138+
name = test.sub("#{source_dir}/", '').gsub('/', '.')
139+
test_string += " #{name[0, name.size - 5]}"
140+
end
141+
142+
result = sh test_string, :verbose => false
143+
end
144+
145+
def csc(args)
146+
# mandatory args
147+
out = (args[:out] or raise 'csc: please specify the :out parameter')
148+
source_patterns = (args[:sources] or raise 'csc: please specify the :sources parameter')
149+
sources = FileList.new(source_patterns)
150+
raise "No source files found at #{sources.join(', ')}" if sources.empty?
151+
152+
# optional args
153+
unless args[:exclude].nil?
154+
args[:exclude].each { |pattern| sources.exclude(pattern) }
155+
end
156+
target = (args[:target] or 'library')
157+
debug = (args[:debug] or true)
158+
resources = args[:resources] ? FileList.new(args[:resources]) : []
159+
references = args[:references] ? FileList.new(args[:references]) : []
160+
extra_args = args[:extra_args]
161+
162+
module_name = File.basename(out).sub(/\.dll$|\.exe$/, '')
163+
164+
argfile = 'csc '
165+
argfile += "/out:#{out.gsub('/', '\\')} "
166+
argfile += "/target:#{target.gsub('/', '\\')} "
167+
argfile += '/nologo '
168+
argfile += "/debug#{debug ? '+' : '-'} "
169+
argfile += "/lib:build "
170+
resources.each do |res|
171+
res_path = res.gsub('/', '\\')
172+
res_name = "#{module_name}.EmbeddedResources.#{File.basename(res_path)}"
173+
argfile += "/resource:#{res_path},#{res_name},public "
174+
end
175+
references.each { |ref| argfile += "/reference:#{ref.gsub('/', '\\')} " }
176+
sources.each { |src| argfile += "#{src.gsub('/', '\\')} " }
177+
argfile += extra_args unless extra_args.nil?
178+
179+
puts "Compiling #{out}" if verbose
180+
sh "#{argfile}", :verbose => false
181+
end

0 commit comments

Comments
 (0)