forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask-gen.rb
61 lines (50 loc) · 1.25 KB
/
task-gen.rb
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
# Utility methods for generating tasks
module Rake
class Task
attr_accessor :deps
attr_accessor :out
end
end
class BaseGenerator
def create_deps_(out, args)
# We depend on our sources
file out => FileList[args[:srcs]] unless args[:srcs].nil?
add_deps_(out, args[:srcs])
add_deps_(out, args[:deps])
add_deps_(out, args[:resources])
task args[:name].to_sym => out unless args[:name] == out
t = Rake::Task[args[:name].to_sym]
t.deps = args[:deps]
t.out = out
end
def add_deps_(task_name, srcs)
if srcs.nil?
return
end
srcs.each do |src|
# Is the src a file or a symbol? If it's a symbol, we're good to go
if src.is_a? Symbol
file task_name.to_sym => [src]
elsif src.is_a? Hash
add_deps_(task_name, src.keys)
else
# Fine. Assume we're dealing with a string, and create a FileList
file task_name.to_sym => FileList[src]
end
end
end
end
# TODO(simon): Delete this. It's not working out dependencies correctly
$targets = {}
def build_deps_(srcs)
deps = []
return deps unless srcs
Array(srcs).each do |src|
if ($targets[src]) then
deps += $targets[src][:deps]
else
deps += FileList[src]
end
end
deps
end