diff --git a/Rakefile b/Rakefile index 8e8cf8edd2292..47b5865995d85 100644 --- a/Rakefile +++ b/Rakefile @@ -33,21 +33,22 @@ ide_version = "1.0.7-SNAPSHOT" # First off, create a new CrazyFun object. crazy_fun = CrazyFun.new -# Secondly, we add the handlers, which are responsible for turning a build +# Secondly, we add the handlers, which are responsible for turning a build # rule into a (series of) rake tasks. For example if we're looking at a file # in subdirectory "subdir" contains the line: # # java_library(:name => "example", :srcs => ["foo.java"]) # # we would generate a rake target of "//subdir:example" which would generate -# a Java JAR at "build/subdir/example.jar". -# +# a Java JAR at "build/subdir/example.jar". +# # If crazy fun doesn't know how to handle a particular output type ("java_library" # in the example above) then it will throw an exception, stopping the build JavaMappings.new.add_all(crazy_fun) JavascriptMappings.new.add_all(crazy_fun) MozillaMappings.new.add_all(crazy_fun) RakeMappings.new.add_all(crazy_fun) +RubyMappings.new.add_all(crazy_fun) # Not every platform supports building every binary needed, so we sometimes # need to fall back to prebuilt binaries. The prebuilt binaries are stored in @@ -59,7 +60,7 @@ end # Finally, find every file named "build.desc" in the project, and generate # rake tasks from them. These tasks are normal rake tasks, and can be invoked -# from rake. +# from rake. crazy_fun.create_tasks(Dir["**/build.desc"]) # Notice that because we're using rake, anything you can do in a normal rake @@ -161,7 +162,7 @@ dll(:name => "firefox_dll", :src => [ "common/src/cpp/webdriver-interactions/**/*", "jobbie/src/cpp/webdriver-firefox/**/*" ], :solution => "WebDriver.sln", :out => "Win32/Release/webdriver-firefox.dll", - :deps => [ + :deps => [ "//firefox:native_events_xpt", ], :prebuilt => "firefox/prebuilt") @@ -191,12 +192,12 @@ dll(:name => "libwebdriver_firefox_so", :prebuilt => "firefox/prebuilt", :out => "linux/Release/libwebdriver-firefox.so") -# There is no official 64 bit gecko SDK. Fall back to trying to use the one on -# system, but be ready for this to fail. I have a Ubuntu machine, so that's +# There is no official 64 bit gecko SDK. Fall back to trying to use the one on +# system, but be ready for this to fail. I have a Ubuntu machine, so that's # what I'm basing this on. I understand that's a Bad Idea gecko_devels = FileList.new("/usr/lib/xulrunner-devel-1.9.*/sdk") -local_gecko = gecko_devels.empty? ? "" : gecko_devels.to_a[0] + "/" +local_gecko = gecko_devels.empty? ? "" : gecko_devels.to_a[0] + "/" dll(:name => "libwebdriver_firefox_so64", :src => FileList.new('common/src/cpp/webdriver-interactions/*_linux.cpp') + FileList.new('firefox/src/cpp/webdriver-firefox/native_events.cpp'), @@ -436,7 +437,7 @@ end desc 'Install prerequisites for the build. You may need to run this as root or Administrator' task :setup do sh "gem install Antwrap yard" - + if python? sh "easy_install virtualenv" end diff --git a/firefox/build.desc b/firefox/build.desc index 2d68e2e37d395..79965c5b77d23 100644 --- a/firefox/build.desc +++ b/firefox/build.desc @@ -16,6 +16,18 @@ java_test(name = "test", "//remote/client:test" ]) +ruby_test( + srcs = [ + "common/test/rb/spec/**/*_spec.rb", + "firefox/test/rb/spec/**/*_spec.rb" + ], + include = [ + "firefox/src/rb/lib", + "remote/client/src/rb/lib" + ], + driver_name = "firefox" +) + mozilla_xpt(name = "native_events_xpt", srcs = [ "src/cpp/webdriver-firefox/nsINativeEvents.idl" ]) @@ -37,23 +49,23 @@ mozilla_xpi(name = "webdriver", ":command_processor_xpt", ":response_handler_xpt" ], - resources = [ + resources = [ { ":firefox_dll" : "platform/WINNT_x86-msvc/components/webdriver-firefox.dll" }, { ":libwebdriver_firefox_so" : "platform/Linux_x86-gcc3/components/libwebdriver-firefox.so" }, { ":libwebdriver_firefox_so64" : "platform/Linux_x86_64-gcc3/components/libwebdriver-firefox.so" } ], chrome = "src/extension/chrome.manifest", install = "src/extension/install.rdf") - + # Temporary rules while we migrate rake_task(name = "firefox_dll", task_name = "firefox_dll", out = "build/Win32/Release/webdriver-firefox.dll") - + rake_task(name = "libwebdriver_firefox_so", task_name = "libwebdriver_firefox_so", out = "build/linux/Release/libwebdriver-firefox.so") - + rake_task(name = "libwebdriver_firefox_so64", task_name = "libwebdriver_firefox_so64", out = "build/linux64/Release/libwebdriver-firefox.so") @@ -61,7 +73,7 @@ rake_task(name = "libwebdriver_firefox_so64", rake_task(name = "libnoblur_so_64", task_name = "libnoblur_so_64", out = "build/linux64/Release/x_ignore_nofocus.so") - + rake_task(name = "libnoblur_so", task_name = "libnoblur_so", out = "build/linux/Release/x_ignore_nofocus.so") diff --git a/go b/go index ea82a519a1399..3b128551c3d46 100755 --- a/go +++ b/go @@ -1,3 +1,3 @@ #!/bin/bash -java -jar third_party/jruby/jruby-complete-1.5.0.RC2.jar -r third_party/jruby/antwrap.jar -S rake $* +java -Djruby.launch.inproc=false -jar third_party/jruby/jruby-complete-1.5.0.RC2.jar -r third_party/jruby/antwrap.jar -S rake $* diff --git a/go.bat b/go.bat index eba0e121def7c..86bf24f2a6a7a 100755 --- a/go.bat +++ b/go.bat @@ -1,2 +1,2 @@ @echo off -java -jar third_party\jruby\jruby-complete-1.5.0.RC2.jar -r third_party\jruby\antwrap.jar -S rake %* +java -Djruby.launch.inproc=false -jar third_party\jruby\jruby-complete-1.5.0.RC2.jar -r third_party\jruby\antwrap.jar -S rake %* diff --git a/rake-tasks/ruby.rb b/rake-tasks/ruby.rb index 0a16dd23d80ea..86b3bdae44763 100644 --- a/rake-tasks/ruby.rb +++ b/rake-tasks/ruby.rb @@ -1,3 +1,113 @@ +class RubyMappings + + def add_all(fun) + fun.add_mapping "ruby_test", CheckArgs.new + fun.add_mapping "ruby_test", AddDefaults.new + fun.add_mapping "ruby_test", JRubyTest.new # this probably needs //common:test as a dependency + fun.add_mapping "ruby_test", MRITest.new + + # TODO: fun.add_mapping("rubygem", RubyGem.new) + # TODO: fun.add_mapping("rubydocs", RubyDocs.new) + end + + class RubyTasks < Tasks + def task_name(dir, name) + super dir, "ruby:#{name}" + end + end + + class CheckArgs + def handle(fun, dir, args) + raise "no :srcs specified for #{dir}" unless args.has_key? :srcs + raise "no :driver_name specified for #{dir}" unless args.has_key? :driver_name + end + end + + class AddDefaults + def handle(fun, dir, args) + args[:include] = [".", "common/src/rb/lib", "common/test/rb/lib"] + Array(args[:include]) + args[:command] = args[:command] || "spec" + args[:require] = Array(args[:require]) + + # move? + args[:srcs] = args[:srcs].map { |str| Dir[str] }.flatten + end + end + + class JRubyTest < RubyTasks + def handle(fun, dir, args) + require = ["third_party/jruby/json-jruby.jar"] + Array(args[:require]) + + desc "Run ruby tests for #{dir} (jruby)" + task task_name(dir, "test:jruby") do + ENV['WD_SPEC_DRIVER'] = args[:driver_name] # TODO: get rid of ENV + + jruby :include => args[:include], + :require => require, + :command => args[:command], + :files => args[:srcs] + end + end + end + + class MRITest < RubyTasks + def handle(fun, dir, args) + desc "Run ruby tests for #{dir} (mri)" + task task_name(dir, "test:mri") do + ENV['WD_SPEC_DRIVER'] = args[:driver_name] # TODO: get rid of this + + ruby :include => args[:include], + :require => args[:require], + :command => args[:command], + :files => args[:srcs] + end + end + end + +end # RubyMappings + +class RubyRunner + def self.run(impl, opts) + cmd = [] + + case impl.to_sym + when :jruby + cmd << "java" + cmd << "-Djava.awt.headless=true" if opts[:headless] + cmd << "-jar" << "third_party/jruby/jruby-complete-1.5.0.RC2.jar" + else + cmd << impl.to_s + end + + if opts.has_key? :include + cmd << "-I" + cmd << Array(opts[:include]).join(File::PATH_SEPARATOR) + end + + Array(opts[:require]).each do |f| + cmd << "-r#{f}" + end + + cmd << "-S" << opts[:command] if opts.has_key? :command + cmd += Array(opts[:files]) if opts.has_key? :files + + sh(*cmd) + end +end + +def jruby(opts) + RubyRunner.run :jruby, opts +end + + +def ruby(opts) + # if we're running on jruby, -Djruby.launch.inproc=false needs to be set for this to work. + # otherwise sh("ruby", ...) will reuse the current JVM + RubyRunner.run :ruby, opts +end + + + task :test_remote_rb => [:test_common, :remote_server] do ENV['WD_SPEC_DRIVER'] = 'remote' jruby :include => [".", "common/src/rb/lib", "remote/client/src/rb/lib", "common/test/rb/lib"], @@ -23,14 +133,6 @@ :files => Dir['common/test/rb/spec/**/*spec.rb'] end -task :test_firefox_rb => :test_common do - ENV['WD_SPEC_DRIVER'] = 'firefox' - jruby :include => [".", "common/src/rb/lib", "firefox/src/rb/lib", "remote/client/src/rb/lib", "common/test/rb/lib"], - :require => ["third_party/jruby/json-jruby.jar"], - :command => '-S spec', - :files => Dir['{common,firefox}/test/rb/spec/**/*spec.rb'] -end - # # remote #