Skip to content

Commit

Permalink
Refactor/remove unused Rake tasks files
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-hill authored and p0deje committed Oct 1, 2019
1 parent 7498da6 commit cb5a603
Show file tree
Hide file tree
Showing 36 changed files with 115 additions and 169 deletions.
64 changes: 43 additions & 21 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,43 @@
$LOAD_PATH.unshift File.expand_path(".")

require 'rake'
require 'rake-tasks/files'
require 'rake_tasks/files'
require 'net/telnet'
require 'stringio'
require 'fileutils'

include Rake::DSL if defined?(Rake::DSL)
include Rake::DSL

Rake.application.instance_variable_set "@name", "go"
orig_verbose = verbose
verbose(false)

# The CrazyFun build grammar. There's no magic here, just ruby
require 'rake-tasks/crazy_fun'
require 'rake-tasks/crazy_fun/mappings/export'
require 'rake-tasks/crazy_fun/mappings/folder'
require 'rake-tasks/crazy_fun/mappings/javascript'
require 'rake-tasks/crazy_fun/mappings/rake'
require 'rake-tasks/crazy_fun/mappings/rename'
require 'rake-tasks/crazy_fun/mappings/ruby'

# The original build rules
require 'rake-tasks/task-gen'
require 'rake-tasks/checks'
require 'rake-tasks/c'
require 'rake-tasks/ie_code_generator'
require 'rake-tasks/ci'
require 'rake_tasks/crazy_fun/main'
require 'rake_tasks/selenium_rake/detonating_handler'
require 'rake_tasks/selenium_rake/crazy_fun'

require 'rake_tasks/crazy_fun/mappings/export'
require 'rake_tasks/crazy_fun/mappings/folder'
require 'rake_tasks/crazy_fun/mappings/javascript'
require 'rake_tasks/crazy_fun/mappings/rake'
require 'rake_tasks/crazy_fun/mappings/rename'
require 'rake_tasks/crazy_fun/mappings/ruby'

# Location of all new methods
require 'rake_tasks/selenium_rake/c_tasks'
require 'rake_tasks/selenium_rake/checks'
require 'rake_tasks/selenium_rake/ie_code_generator'
require 'rake_tasks/selenium_rake/java_formatter'
require 'rake_tasks/selenium_rake/cpp_formatter'
require 'rake_tasks/selenium_rake/type_definitions_generator'

# Our modifications to the Rake library
require 'rake-tasks/rake/task'
require 'rake_tasks/rake/task'

$DEBUG = orig_verbose != Rake::FileUtilsExt::DEFAULT ? true : false
if (ENV['debug'] == 'true')
$DEBUG = true
end
$DEBUG = true if ENV['debug'] == 'true'

verbose($DEBUG)

def release_version
Expand Down Expand Up @@ -487,8 +490,27 @@ namespace :ci do
end
end

# Required for above ci:upload_to_sauce rake only
require 'uri'
require 'net/http'
require 'digest/md5'
require 'json'
require 'pathname'

def net_http
http_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
if http_proxy
http_proxy = "http://#{http_proxy}" unless http_proxy.start_with?('http://')
proxy_uri = URI.parse(http_proxy)

Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port)
else
Net::HTTP
end
end

at_exit do
if File.exist?(".git") && !Platform.windows?
if File.exist?(".git") && !SeleniumRake::Checks.windows?
system "sh", ".git-fixfiles"
end
end
1 change: 0 additions & 1 deletion rake-tasks/browsers.rb

This file was deleted.

6 changes: 0 additions & 6 deletions rake-tasks/c.rb

This file was deleted.

2 changes: 0 additions & 2 deletions rake-tasks/checks.rb

This file was deleted.

19 changes: 0 additions & 19 deletions rake-tasks/ci.rb

This file was deleted.

4 changes: 0 additions & 4 deletions rake-tasks/crazy_fun.rb

This file was deleted.

4 changes: 0 additions & 4 deletions rake-tasks/ie_code_generator.rb

This file was deleted.

18 changes: 0 additions & 18 deletions rake-tasks/task-gen.rb

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'rake-tasks/crazy_fun/build_grammar'
require 'rake_tasks/crazy_fun/build_grammar'

class OutputType
attr_accessor :name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
module Platform
extend self

def windows?
@windows ||= !!(/mswin|msys|mingw32/ =~ RbConfig::CONFIG['host_os'])
end

def mac?
(RbConfig::CONFIG['host_os'] =~ /darwin|mac os/) != nil
end

def linux?
(RbConfig::CONFIG['host_os'] =~ /linux/) != nil
end

def cygwin?
RUBY_PLATFORM.downcase.include?("cygwin")
end

def dir_separator
File::ALT_SEPARATOR || File::SEPARATOR
end

def env_separator
File::PATH_SEPARATOR
end

def jruby?
RUBY_PLATFORM =~ /java/
end

def path_for(path)
windows? ? path.gsub("/", Platform.dir_separator) : path
end
end

module FileCopyHack
def cp_r(src, dest, opts = {})
super
Expand All @@ -51,7 +15,6 @@ def cp_r(src, dest, opts = {})
end

class Tasks
include Platform
include FileCopyHack

def task_name(dir, name)
Expand Down Expand Up @@ -166,7 +129,7 @@ def copy_all(dir, srcs, dest)
end

def zip(src, dest)
out = Platform.path_for(File.expand_path(dest))
out = SeleniumRake::Checks.path_for(File.expand_path(dest))
Dir.chdir(src) {
# TODO(jari): something very weird going on here on windows
# the 2>&1 is needed for some reason
Expand All @@ -178,7 +141,7 @@ def zip(src, dest)
def to_filelist(dir, src)
str = dir + "/" + src
FileList[str].collect do |file|
Platform.path_for(file)
SeleniumRake::Checks.path_for(file)
end
end

Expand Down Expand Up @@ -225,7 +188,7 @@ def copy_array(dir, src, dest)
def copy_hash(dir, src, dest)
src.each do |key, value|
if key.is_a? Symbol
copy_symbol dir, key, Platform.path_for(File.join(dest, value))
copy_symbol dir, key, SeleniumRake::Checks.path_for(File.join(dest, value))
else
from, to = File.join(dir, key), File.join(dest, value)
cp_r from, to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'rake-tasks/crazy_fun/mappings/common'
require 'rake_tasks/crazy_fun/mappings/common'

class ExportMappings
def add_all(fun)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'rake-tasks/crazy_fun/mappings/common'
require 'rake_tasks/crazy_fun/mappings/common'

# Example:
# folder(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rake-tasks/crazy_fun/mappings/common'
require 'rake-tasks/checks.rb'
require 'rake_tasks/crazy_fun/mappings/common'
require 'rake_tasks/selenium_rake/checks'

class GccMappings
def add_all(fun)
Expand All @@ -24,8 +24,6 @@ def Gcc::out_name(dir, args)
end

class BaseGcc < Tasks
include Platform

def gcc(fun, dir, srcs, args, link_args, out, is_32_bit)
if !gcc?
copy_prebuilt(fun, out)
Expand Down Expand Up @@ -198,12 +196,10 @@ def handle(fun, dir, args)
end

class Build < BaseGcc
include Platform

def handle(fun, dir, args)
out = Gcc::out_name(dir, args)
gecko_sdk = MozBinary::gecko_sdk_path args
gecko_sdk += Platform.dir_separator
gecko_sdk += SeleniumRake::Checks.dir_separator
xpcom_lib = args[:xpcom_lib] || "xpcomglue_s_nomozalloc"

file out do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rake-tasks/crazy_fun/mappings/common'
require 'rake-tasks/crazy_fun/mappings/common'
require 'rake_tasks/crazy_fun/mappings/common'
require 'rake_tasks/crazy_fun/mappings/common'
require 'pathname'
require 'set'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rake'
require 'rake-tasks/browsers.rb'
require 'rake-tasks/buck.rb'
require 'rake-tasks/crazy_fun/mappings/common'
require 'rake_tasks/selenium_rake/checks'
require 'rake_tasks/buck.rb'
require 'rake_tasks/crazy_fun/mappings/common'

class PythonMappings
def add_all(fun)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'rake-tasks/crazy_fun/mappings/common'
require 'rake_tasks/crazy_fun/mappings/common'

class RakeMappings
def add_all(fun)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'rake-tasks/crazy_fun/mappings/common'
require 'rake_tasks/crazy_fun/mappings/common'

class RenameMappings
def add_all(fun)
Expand Down Expand Up @@ -44,7 +44,7 @@ def handle(fun, dir, args)
end
end

require 'rake-tasks/crazy_fun/mappings/common'
require 'rake_tasks/crazy_fun/mappings/common'

class RenameMappings
def add_all(fun)
Expand Down
File renamed without changes.
62 changes: 32 additions & 30 deletions rake-tasks/files.rb → rake_tasks/files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,6 @@ def find_file(file)
end
end

def copy_single_resource_(from, to)
dir = to.sub(/(.*)\/.*?$/, '\1')
mkdir_p dir.to_s

from = find_file(from)
if from.is_a? FileList
from.each do |f|
cp_r f, to.to_s, remove_destination: true
end
else
cp_r from, to.to_s, remove_destination: true
end
end

def copy_resource_(from, to)
return if from.nil?

if from.is_a? Hash
from.each do |key, value|
copy_single_resource_ key, "#{to}/#{value}"
end
elsif from.is_a? Array
from.each do |res|
copy_resource_ res, to
end
else
copy_single_resource_ from, to
end
end

def copy_prebuilt(prebuilt, out)
dir = out.split('/')[0..-2].join('/')

Expand Down Expand Up @@ -94,3 +64,35 @@ def copy_to_prebuilt(src, prebuilt)
end
end
end

private

def copy_resource_(from, to)
return if from.nil?

if from.is_a? Hash
from.each do |key, value|
copy_single_resource_ key, "#{to}/#{value}"
end
elsif from.is_a? Array
from.each do |res|
copy_resource_ res, to
end
else
copy_single_resource_ from, to
end
end

def copy_single_resource_(from, to)
dir = to.sub(/(.*)\/.*?$/, '\1')
mkdir_p dir.to_s

from = find_file(from)
if from.is_a? FileList
from.each do |f|
cp_r f, to.to_s, remove_destination: true
end
else
cp_r from, to.to_s, remove_destination: true
end
end
Loading

0 comments on commit cb5a603

Please sign in to comment.