dev 1.0.145 → 1.0.146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/dev.rb +1 -1
- data/lib/dev/Commands.rb +257 -0
- data/lib/dev/Environment.rb +30 -1
- data/lib/dev/Hash.rb +2 -0
- data/lib/dev/Project.rb +22 -265
- data/lib/dev/Tasks.rb +16 -6
- data/lib/dev/cmd/Compile.rb +39 -0
- data/lib/dev/cmd/Info.rb +6 -0
- metadata +4 -1
data/lib/dev.rb
CHANGED
@@ -42,7 +42,7 @@ puts_debug "read " + __FILE__.foreground(:green)
|
|
42
42
|
#require "#{File.dirname(__FILE__)}/dev/Environment.rb"
|
43
43
|
#require "#{File.dirname(__FILE__)}/dev/Hash.rb"
|
44
44
|
#require "#{File.dirname(__FILE__)}/dev/SystemCall.rb"
|
45
|
-
["
|
45
|
+
["Environment","Hash","SystemCall","Database","BoostBuild","Project","Commands","Tasks"].each{ |f| require "#{File.dirname(__FILE__)}/dev/#{f}.rb" }
|
46
46
|
Dir["#{File.dirname(__FILE__)}/dev/**/*.rb"].each{ |f| require f }
|
47
47
|
|
48
48
|
DEV_ROOT=Dev::Environment.dev_root
|
data/lib/dev/Commands.rb
ADDED
@@ -0,0 +1,257 @@
|
|
1
|
+
require_relative 'cmd/Compile.rb'
|
2
|
+
module Dev
|
3
|
+
class Commands < Hash
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
refresh
|
7
|
+
end
|
8
|
+
|
9
|
+
def refresh
|
10
|
+
puts_debug "Dev::Command.refresh"
|
11
|
+
self.delete :setup if self.has_key? :setup
|
12
|
+
#self.delete :compile if self.has_key? :compile
|
13
|
+
["add","pull","setup","compile","test","features","commit","update"].each { |key|
|
14
|
+
if self.has_key?(key.to_sym)
|
15
|
+
puts_debug "CMD has key #{key}"
|
16
|
+
else
|
17
|
+
value=get_default_value(key.to_sym)
|
18
|
+
self[key.to_sym]=value if !value.nil?
|
19
|
+
puts_debug "CMD[#{(key.to_sym).to_s}]=#{value.to_s}" if !value.nil?
|
20
|
+
puts_debug "default value for #{key} was nil"
|
21
|
+
end
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_default_value(key)
|
26
|
+
return get_default_value_setup if key==:setup
|
27
|
+
return get_default_value_commit if key==:commit
|
28
|
+
return get_default_value_test if key==:test
|
29
|
+
return Dev::Cmd::Compile.get_auto_compile_directives if key==:compile
|
30
|
+
return get_default_value_update if key==:update
|
31
|
+
return get_default_value_pull if key==:pull
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_default_value_commit
|
36
|
+
array=Array.new
|
37
|
+
array << 'git commit -a -m "rake commit all"' if File.exists?(".git")
|
38
|
+
array << 'svn commit -m "rake commit all"' if File.exists?(".svn")
|
39
|
+
array=nil if array.empty?
|
40
|
+
return array
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_default_value_update
|
44
|
+
array=Array.new
|
45
|
+
array << 'svn update' if File.exists?(".svn")
|
46
|
+
array=nil if array.empty?
|
47
|
+
return array
|
48
|
+
end
|
49
|
+
def get_default_value_setup
|
50
|
+
array=Array.new
|
51
|
+
puts_debug "assigning default values for setup"
|
52
|
+
#array << "bundle install" if File.exists?("Gemfile")
|
53
|
+
array << "{ :cmd=> 'bundle install', :capture_output=> false}" if File.exists?("Gemfile") && "#{RUBY_VERSION}">="1.8.7"
|
54
|
+
|
55
|
+
# dep,svn directives
|
56
|
+
puts_debug "checking for :dep hash...."
|
57
|
+
dep_hash=DEV.get_value(:dep)
|
58
|
+
puts_debug "dep_hash is nil" if dep_hash.nil?
|
59
|
+
unless dep_hash.nil?
|
60
|
+
puts_debug "dep_hash is not nil"
|
61
|
+
puts_debug "dep_hash is empty" if dep_hash.empty?
|
62
|
+
dep_hash.each do |key,value|
|
63
|
+
puts_debug ":dep[#{key.to_s}]"
|
64
|
+
if value.kind_of?(Hash)
|
65
|
+
dep=Dev::Dep.new(value)
|
66
|
+
dep.setup_commands.each{|cmd| array << cmd}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
puts_debug "mkdir directives..."
|
72
|
+
if(!Dir.glob("*.csproj").nil? && Dir.glob("*.csproj").length > 0)
|
73
|
+
array << "<%Dir.mkdir 'bin' unless File.exist?('bin')%>"
|
74
|
+
array << "<%Dir.mkdir 'bin/Debug' unless File.exist?('bin/Debug')%>"
|
75
|
+
array << "<%Dir.mkdir 'bin/Release' unless File.exist?('bin/Release')%>"
|
76
|
+
end
|
77
|
+
array=nil if array.empty?
|
78
|
+
return array
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_default_value_pull
|
82
|
+
array=Array.new
|
83
|
+
# dep,svn directives
|
84
|
+
dep_hash=DEV.get_value("dep")
|
85
|
+
unless dep_hash.nil?
|
86
|
+
dep_hash.each do |key,value|
|
87
|
+
if value.kind_of?(Hash)
|
88
|
+
dep=Dev::Dep.new(value)
|
89
|
+
dep.pull_commands.each{|cmd| array << cmd}
|
90
|
+
#puts_debug "pull array: " + array.to_s
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
array=nil if array.empty?
|
95
|
+
return array
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_default_value_test
|
99
|
+
puts_debug "Dev::Commands.get_default_value_test"
|
100
|
+
array=Array.new
|
101
|
+
|
102
|
+
|
103
|
+
array << "rspec --pattern='**/*.spec'" if DEV[:file_count].has_key?(:spec) && DEV[:file_count][:spec] > 0
|
104
|
+
|
105
|
+
Dir.glob("*.gemspec").each { |gs|
|
106
|
+
array << "{cmd: 'gem install ./#{gs.gsub('.gemspec','')}-#{DEV[:version]}.gem', capture_output: true}"
|
107
|
+
#array << "{cmd: 'gem install ./#{gs.gsub('.gemspec','')}-#{DEV[:version]}.gem', capture_output: false}"
|
108
|
+
#array << "{:cmd=> 'gem install #{gs.gsub('.gemspec','')}-#{DEV[:version]}.gem', :capture_output=> false}"
|
109
|
+
#array << "gem install ./#{gs.gsub('.gemspec','')}-#{DEV[:version]}.gem"
|
110
|
+
} #if DEV[:type]=="gem"
|
111
|
+
|
112
|
+
#if self[:type]=="C#"
|
113
|
+
Dir.glob("*.{Test.csproj,Features.csproj}").each { |cs|
|
114
|
+
dll_name="bin/x86/Release/#{File.basename(cs,'.csproj')}.dll"
|
115
|
+
array << "\"<paths,nunit>\" /nologo #{dll_name} /xml:#{dll_name}.nunit-results.xml" if RUBY_PLATFORM.include?("w32")
|
116
|
+
array << "mono \"<paths,nunit>\" #{dll_name}" if !RUBY_PLATFORM.include?("w32")
|
117
|
+
}
|
118
|
+
#end
|
119
|
+
return array
|
120
|
+
end
|
121
|
+
|
122
|
+
def setup; execute_method "setup"; end
|
123
|
+
def compile; execute_method "compile"; end
|
124
|
+
def test; execute_method "test"; end
|
125
|
+
def update;execute_method("update");end
|
126
|
+
def replace; DEV.replace; end
|
127
|
+
|
128
|
+
def execute_method(name)
|
129
|
+
string_name=name.to_s
|
130
|
+
puts_debug "method_missing name=" + string_name
|
131
|
+
|
132
|
+
puts " no directives defined for #{string_name}" if self.get_value(string_name).nil? && string_name=="pull"
|
133
|
+
return if(self.get_value(string_name).nil?)
|
134
|
+
puts " no directives defined for #{string_name}" if self.get_value(string_name).length < 1
|
135
|
+
return if self.get_value(string_name).length < 1
|
136
|
+
|
137
|
+
value=self.get_value(string_name)
|
138
|
+
if value.kind_of?(Hash)
|
139
|
+
value.each { |name,value| Dev::Commands.execute_cmd(value); sleep(0.5) }
|
140
|
+
else
|
141
|
+
value.each { |c| Dev::Commands.execute_cmd(c); sleep(0.5) }
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.execute_cmd(c)
|
146
|
+
# expand the command here....
|
147
|
+
command=Dev::Environment.expand_command(c)
|
148
|
+
puts_debug "command: " + command.to_s + " (in Project.execute_cmd)"
|
149
|
+
if c.include?('<%') && c.include?('%>')
|
150
|
+
#puts "Command: " + c
|
151
|
+
eval(c.gsub("<%","").gsub("%>",""))
|
152
|
+
else
|
153
|
+
# is the command a hash?
|
154
|
+
hash=c if c.kind_of?(Hash)
|
155
|
+
# can the command be converted to a hash?
|
156
|
+
hash=Dev::Environment.s_to_hash(command) if hash.nil?
|
157
|
+
call=nil
|
158
|
+
if(hash.nil?)
|
159
|
+
call=Dev::SystemCall.new(command)
|
160
|
+
else
|
161
|
+
call=Dev::SystemCall.new(hash)
|
162
|
+
end
|
163
|
+
call.puts_summary
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def info
|
168
|
+
puts "DEV"
|
169
|
+
Hash.print_hash("",DEV)
|
170
|
+
puts " "
|
171
|
+
puts "CMD"
|
172
|
+
Hash.print_hash("",CMD)
|
173
|
+
puts " "
|
174
|
+
end
|
175
|
+
|
176
|
+
def add
|
177
|
+
unless self[:src_glob].nil?
|
178
|
+
scm = Dev::Scm.new
|
179
|
+
return if scm.scm_type == "none"
|
180
|
+
if self[:src_glob].kind_of?(Hash)
|
181
|
+
self[:src_glob].each do |name,value|
|
182
|
+
puts " adding files " + value.to_s
|
183
|
+
scm.add_file_glob(value)
|
184
|
+
end
|
185
|
+
else
|
186
|
+
puts " adding files " + self[:src_glob].to_s
|
187
|
+
scm.add_file_glob(self[:src_glob])
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def commit
|
193
|
+
scm = Dev::Scm.new
|
194
|
+
return if scm.scm_type == "none"
|
195
|
+
puts " no differences detected" unless has_diff
|
196
|
+
execute_method("commit") if has_diff
|
197
|
+
if File.exists?(".svn")
|
198
|
+
call=Dev::SystemCall.new('svn update')
|
199
|
+
call=Dev::SystemCall.new('svn info')
|
200
|
+
url = call.output.match(/URL: ([\d\w\.\:\/-]+)/)[1]
|
201
|
+
rev = call.output.match(/Last Changed Rev: ([\d]+)/)[1]
|
202
|
+
puts " #{url}@#{rev}"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def check
|
207
|
+
puts " default.taskstamp." + DEV.context + " exists." if File.exists?("default.taskstamp."+ DEV.context)
|
208
|
+
puts " default.taskstamp." + DEV.context + " does not exist" unless File.exists?("default.taskstamp." +DEV.context)
|
209
|
+
|
210
|
+
begin
|
211
|
+
hasdiff = has_diff
|
212
|
+
rescue
|
213
|
+
puts "has_diff threw an exception."
|
214
|
+
end
|
215
|
+
|
216
|
+
puts " no differences detected." unless hasdiff
|
217
|
+
puts " detected differences." if hasdiff
|
218
|
+
|
219
|
+
if File.exists?("default.taskstamp."+DEV.context) && !hasdiff
|
220
|
+
#puts " nothing to do"
|
221
|
+
update
|
222
|
+
exit
|
223
|
+
end
|
224
|
+
|
225
|
+
#if !has_diff and File.exists?("default.taskstamp."+context)
|
226
|
+
# puts " no differences detected."
|
227
|
+
# puts " default.taskstamp." + context + " exists."
|
228
|
+
# exit
|
229
|
+
#end
|
230
|
+
#puts " detected differences" if has_diff
|
231
|
+
#puts " default.taskstamp." + context + " does not exist" unless File.exists?("default.taskstamp." + context)
|
232
|
+
end
|
233
|
+
|
234
|
+
def has_diff
|
235
|
+
call=nil
|
236
|
+
|
237
|
+
if File.exists?(".git")
|
238
|
+
call=Dev::SystemCall.new('git status')
|
239
|
+
return true if call.output.include?("new file:")
|
240
|
+
return true if call.output.include?("deleted:")
|
241
|
+
return true if call.output.include?("modified:")
|
242
|
+
end
|
243
|
+
|
244
|
+
call=Dev::SystemCall.new('git diff --name-only') if File.exists?(".git")
|
245
|
+
call=Dev::SystemCall.new('svn diff') if File.exists?(".svn")
|
246
|
+
|
247
|
+
unless call.nil? || call.output.length==0
|
248
|
+
puts_debug call.output
|
249
|
+
return true # differences detected
|
250
|
+
else
|
251
|
+
return false # no differences
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end # class Tasks
|
255
|
+
end # module Dev
|
256
|
+
|
257
|
+
CMD=Dev::Commands.new()
|
data/lib/dev/Environment.rb
CHANGED
@@ -80,7 +80,36 @@ class Environment
|
|
80
80
|
return machine.strip
|
81
81
|
#return "unknown"
|
82
82
|
end
|
83
|
-
|
83
|
+
def self.expand_command(command); Dev::Environment.expand_project_variables(command); end
|
84
|
+
def self.expand_project_variables(str)
|
85
|
+
if str.kind_of?(Hash)
|
86
|
+
expandedHash = Hash.new
|
87
|
+
str.each do |name,value|
|
88
|
+
expandedHash[name]=expand_project_variables(value)
|
89
|
+
end
|
90
|
+
return expandedHash
|
91
|
+
end
|
92
|
+
|
93
|
+
if str.kind_of?(Array)
|
94
|
+
expandedArray= Array.new
|
95
|
+
str.each{|e|expandedArray << expand_project_variable(e) }
|
96
|
+
return expandedArray
|
97
|
+
end
|
98
|
+
|
99
|
+
if str.kind_of?(String)
|
100
|
+
result=Dev::Environment.expand_string_variables(str) # expands ruby variables, e.g. '#{name}' to 'widget'
|
101
|
+
if result.include?('<') && result.include?('>')
|
102
|
+
result.scan(/(<[\w,]+>)/).each { |pvar| # expand project variables, e.g. '<name>' to 'widget
|
103
|
+
key = pvar[0].gsub("<","").gsub(">","") # '<paths,nunit>' to 'C:/wherever/NUnit.exe'
|
104
|
+
value=DEV.get_value(key)
|
105
|
+
result = result.gsub(pvar[0],value)
|
106
|
+
}
|
107
|
+
end
|
108
|
+
return result
|
109
|
+
end
|
110
|
+
|
111
|
+
return str
|
112
|
+
end
|
84
113
|
end
|
85
114
|
|
86
115
|
end # module Dev
|
data/lib/dev/Hash.rb
CHANGED
data/lib/dev/Project.rb
CHANGED
@@ -48,6 +48,7 @@ class Project < Hash
|
|
48
48
|
update_default_values
|
49
49
|
db = Dev::Database.new
|
50
50
|
db.set_branch_uri(self[:fullname],self[:scm_uri])
|
51
|
+
|
51
52
|
end
|
52
53
|
def update_default_values
|
53
54
|
puts_debug "update_default_values"
|
@@ -61,13 +62,14 @@ class Project < Hash
|
|
61
62
|
puts_debug "assigning self[:dep] to Hash.new"
|
62
63
|
self[:dep]=Hash.new
|
63
64
|
end
|
64
|
-
|
65
|
-
["
|
65
|
+
|
66
|
+
["features" ].each do |k|
|
66
67
|
puts_debug "set_default_value(#{k})"
|
67
68
|
set_default_value(k)
|
68
69
|
end
|
70
|
+
#CMD.refresh
|
69
71
|
generate_auto_replace_directives
|
70
|
-
generate_tasks(self)
|
72
|
+
#generate_tasks(self)
|
71
73
|
end
|
72
74
|
|
73
75
|
def get_default_value_name
|
@@ -146,6 +148,12 @@ class Project < Hash
|
|
146
148
|
end
|
147
149
|
|
148
150
|
def array_method(name)
|
151
|
+
|
152
|
+
# prefer CMD.execute_method
|
153
|
+
puts "routing call to array_method(#{name}) to CMD.execute_method" if !CMD.get_value(name.to_s).nil?
|
154
|
+
return CMD.execute_method(name) if !CMD.get_value(name.to_s).nil?
|
155
|
+
|
156
|
+
puts "array_method(#{name}) executing on Dev::Project class, #{name} should be moved to CMD hash"
|
149
157
|
string_name=name.to_s
|
150
158
|
puts_debug "method_missing name=" + string_name
|
151
159
|
|
@@ -162,59 +170,9 @@ class Project < Hash
|
|
162
170
|
end
|
163
171
|
end
|
164
172
|
|
165
|
-
def execute_cmd(c)
|
166
|
-
# expand the command here....
|
167
|
-
command=expand_command(c)
|
168
|
-
puts_debug "command: " + command.to_s + " (in Project.execute_cmd)"
|
169
|
-
if c.include?('<%') && c.include?('%>')
|
170
|
-
#puts "Command: " + c
|
171
|
-
eval(c.gsub("<%","").gsub("%>",""))
|
172
|
-
else
|
173
|
-
# is the command a hash?
|
174
|
-
hash=c if c.kind_of?(Hash)
|
175
|
-
# can the command be converted to a hash?
|
176
|
-
hash=Dev::Environment.s_to_hash(command) if hash.nil?
|
177
|
-
call=nil
|
178
|
-
if(hash.nil?)
|
179
|
-
call=Dev::SystemCall.new(command)
|
180
|
-
else
|
181
|
-
call=Dev::SystemCall.new(hash)
|
182
|
-
end
|
183
|
-
call.puts_summary
|
184
|
-
end
|
185
|
-
end
|
173
|
+
def execute_cmd(c); Dev::Commands.execute_cmd(c); end
|
186
174
|
|
187
175
|
def method_missing( name, *args ); array_method(name); end
|
188
|
-
def expand_command(command); expand_project_variables(command); end
|
189
|
-
|
190
|
-
def expand_project_variables(str)
|
191
|
-
if str.kind_of?(Hash)
|
192
|
-
expandedHash = Hash.new
|
193
|
-
str.each do |name,value|
|
194
|
-
expandedHash[name]=expand_project_variables(value)
|
195
|
-
end
|
196
|
-
return expandedHash
|
197
|
-
end
|
198
|
-
|
199
|
-
if str.kind_of?(Array)
|
200
|
-
expandedArray= Array.new
|
201
|
-
str.each{|e|expandedArray << expand_project_variable(e) }
|
202
|
-
return expandedArray
|
203
|
-
end
|
204
|
-
|
205
|
-
if str.kind_of?(String)
|
206
|
-
result=Dev::Environment.expand_string_variables(str) # expands ruby variables, e.g. '#{name}' to 'widget'
|
207
|
-
if result.include?('<') && result.include?('>')
|
208
|
-
result.scan(/(<[\w,]+>)/).each { |pvar| # expand project variables, e.g. '<name>' to 'widget
|
209
|
-
key = pvar[0].gsub("<","").gsub(">","") # '<paths,nunit>' to 'C:/wherever/NUnit.exe'
|
210
|
-
result = result.gsub(pvar[0],get_value(key))
|
211
|
-
}
|
212
|
-
end
|
213
|
-
return result
|
214
|
-
end
|
215
|
-
|
216
|
-
return str
|
217
|
-
end
|
218
176
|
|
219
177
|
def loc_cmd
|
220
178
|
cmd="countloc --recurse ."
|
@@ -228,21 +186,7 @@ class Project < Hash
|
|
228
186
|
system(loc_cmd)
|
229
187
|
end
|
230
188
|
|
231
|
-
|
232
|
-
unless self[:src_glob].nil?
|
233
|
-
scm = Dev::Scm.new
|
234
|
-
return if scm.scm_type == "none"
|
235
|
-
if self[:src_glob].kind_of?(Hash)
|
236
|
-
self[:src_glob].each do |name,value|
|
237
|
-
puts " adding files " + value.to_s
|
238
|
-
scm.add_file_glob(value)
|
239
|
-
end
|
240
|
-
else
|
241
|
-
puts " adding files " + self[:src_glob].to_s
|
242
|
-
scm.add_file_glob(self[:src_glob])
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
189
|
+
|
246
190
|
|
247
191
|
def loc_total
|
248
192
|
# parse the output for TOTAL LOC
|
@@ -259,33 +203,7 @@ class Project < Hash
|
|
259
203
|
Dev::Environment.user + "." + Dev::Environment.machine
|
260
204
|
end
|
261
205
|
|
262
|
-
|
263
|
-
puts " default.taskstamp." + context + " exists." if File.exists?("default.taskstamp."+context)
|
264
|
-
puts " default.taskstamp." + context + " does not exist" unless File.exists?("default.taskstamp."+context)
|
265
|
-
|
266
|
-
begin
|
267
|
-
hasdiff = has_diff
|
268
|
-
rescue
|
269
|
-
puts "has_diff threw an exception."
|
270
|
-
end
|
271
|
-
|
272
|
-
puts " no differences detected." unless hasdiff
|
273
|
-
puts " detected differences." if hasdiff
|
274
|
-
|
275
|
-
if File.exists?("default.taskstamp."+context) && !hasdiff
|
276
|
-
#puts " nothing to do"
|
277
|
-
update
|
278
|
-
exit
|
279
|
-
end
|
280
|
-
|
281
|
-
#if !has_diff and File.exists?("default.taskstamp."+context)
|
282
|
-
# puts " no differences detected."
|
283
|
-
# puts " default.taskstamp." + context + " exists."
|
284
|
-
# exit
|
285
|
-
#end
|
286
|
-
#puts " detected differences" if has_diff
|
287
|
-
#puts " default.taskstamp." + context + " does not exist" unless File.exists?("default.taskstamp." + context)
|
288
|
-
end
|
206
|
+
|
289
207
|
|
290
208
|
def stamp_task(name)
|
291
209
|
File.open("#{name}.taskstamp." + context,"w") { |f| f.write(Time.now.to_s) }
|
@@ -355,44 +273,11 @@ class Project < Hash
|
|
355
273
|
def has_build_products
|
356
274
|
end
|
357
275
|
|
358
|
-
def has_diff
|
359
|
-
call=nil
|
360
276
|
|
361
|
-
if File.exists?(".git")
|
362
|
-
call=Dev::SystemCall.new('git status')
|
363
|
-
return true if call.output.include?("new file:")
|
364
|
-
return true if call.output.include?("deleted:")
|
365
|
-
return true if call.output.include?("modified:")
|
366
|
-
end
|
367
|
-
|
368
|
-
call=Dev::SystemCall.new('git diff --name-only') if File.exists?(".git")
|
369
|
-
call=Dev::SystemCall.new('svn diff') if File.exists?(".svn")
|
370
|
-
|
371
|
-
unless call.nil? || call.output.length==0
|
372
|
-
puts_debug call.output
|
373
|
-
return true # differences detected
|
374
|
-
else
|
375
|
-
return false # no differences
|
376
|
-
end
|
377
|
-
end
|
378
277
|
|
379
|
-
def update
|
380
|
-
array_method("update")
|
381
|
-
end
|
382
278
|
|
383
|
-
|
384
|
-
|
385
|
-
return if scm.scm_type == "none"
|
386
|
-
puts " no differences detected" unless has_diff
|
387
|
-
array_method("commit") if has_diff
|
388
|
-
if File.exists?(".svn")
|
389
|
-
call=Dev::SystemCall.new('svn update')
|
390
|
-
call=Dev::SystemCall.new('svn info')
|
391
|
-
url = call.output.match(/URL: ([\d\w\.\:\/-]+)/)[1]
|
392
|
-
rev = call.output.match(/Last Changed Rev: ([\d]+)/)[1]
|
393
|
-
puts " #{url}@#{rev}"
|
394
|
-
end
|
395
|
-
end
|
279
|
+
|
280
|
+
|
396
281
|
|
397
282
|
def rake_working_deps
|
398
283
|
unless dep_hash.nil?
|
@@ -427,15 +312,7 @@ class Project < Hash
|
|
427
312
|
Dev::Svn::update_revision_variables(filename)
|
428
313
|
end
|
429
314
|
|
430
|
-
|
431
|
-
#[ "file_count","loc" ].each do |k|
|
432
|
-
# puts_debug "set_default_value(#{k})"
|
433
|
-
# set_default_value(k)
|
434
|
-
# end
|
435
|
-
puts " "
|
436
|
-
Hash.print_hash("",self)
|
437
|
-
puts " "
|
438
|
-
end
|
315
|
+
|
439
316
|
|
440
317
|
def set_default_value(key)
|
441
318
|
set_value(key,get_default_value(key)) if get_value(key).nil? && !get_default_value(key).nil?
|
@@ -446,116 +323,7 @@ class Project < Hash
|
|
446
323
|
value=loc_total if key=="loc"
|
447
324
|
|
448
325
|
array=Array.new
|
449
|
-
if(key=="setup")
|
450
|
-
puts_debug "assigning default values for setup"
|
451
|
-
#array << "bundle install" if File.exists?("Gemfile")
|
452
|
-
array << "{ :cmd=> 'bundle install', :capture_output=> false}" if File.exists?("Gemfile") && "#{RUBY_VERSION}">="1.8.7"
|
453
|
-
|
454
|
-
# dep,svn directives
|
455
|
-
puts_debug "checking for :dep hash...."
|
456
|
-
dep_hash=self.get_value("dep")
|
457
|
-
puts_debug "dep_hash is nil" if dep_hash.nil?
|
458
|
-
unless dep_hash.nil?
|
459
|
-
puts_debug "dep_hash is not nil"
|
460
|
-
puts_debug "dep_hash is empty" if dep_hash.empty?
|
461
|
-
dep_hash.each do |key,value|
|
462
|
-
puts_debug ":dep[#{key}.to_s]"
|
463
|
-
if value.kind_of?(Hash)
|
464
|
-
dep=Dev::Dep.new(value)
|
465
|
-
dep.setup_commands.each{|cmd| array << cmd}
|
466
|
-
end
|
467
|
-
end
|
468
|
-
end
|
469
|
-
|
470
|
-
if(!Dir.glob("*.csproj").nil? && Dir.glob("*.csproj").length > 0)
|
471
|
-
array << "<%Dir.mkdir 'bin' unless File.exist?('bin')%>"
|
472
|
-
array << "<%Dir.mkdir 'bin/Debug' unless File.exist?('bin/Debug')%>"
|
473
|
-
array << "<%Dir.mkdir 'bin/Release' unless File.exist?('bin/Release')%>"
|
474
|
-
end
|
475
|
-
end
|
476
326
|
|
477
|
-
if(key=="pull")
|
478
|
-
# dep,svn directives
|
479
|
-
dep_hash=self.get_value("dep")
|
480
|
-
unless dep_hash.nil?
|
481
|
-
dep_hash.each do |key,value|
|
482
|
-
if value.kind_of?(Hash)
|
483
|
-
dep=Dev::Dep.new(value)
|
484
|
-
dep.pull_commands.each{|cmd| array << cmd}
|
485
|
-
#puts_debug "pull array: " + array.to_s
|
486
|
-
end
|
487
|
-
end
|
488
|
-
end
|
489
|
-
end
|
490
|
-
if(key=="compile")
|
491
|
-
Dir.glob("*.gemspec").each { |gs|
|
492
|
-
#array << "gem build #{gs}"
|
493
|
-
array << "{ :cmd=> 'gem build #{gs}', :capture_output=> false}"
|
494
|
-
} if self[:type]=="gem"
|
495
|
-
|
496
|
-
Dir.glob("*.csproj").each{|cs|
|
497
|
-
platforms = Dev::Project::extract_platforms(cs)
|
498
|
-
platforms = ["AnyCPU"] if platforms.nil?
|
499
|
-
|
500
|
-
puts_debug "for project " + cs + " platforms = " + platforms.to_s
|
501
|
-
platforms.each{ |platform|
|
502
|
-
if(platform=="AnyCPU")
|
503
|
-
if(!has_key?(:any_release_compile_flags))
|
504
|
-
self[:any_release_compile_flags]="/property:Configuration=Release /property:Platform=\"Any CPU\" /p:OutputPath=./bin/Release"
|
505
|
-
end
|
506
|
-
array<<"<paths,msbuild> #{cs} <any_release_compile_flags>" if RUBY_PLATFORM.include?("w32")
|
507
|
-
array<<"xbuild #{cs} <any_release_compile_flags>" if !RUBY_PLATFORM.include?("w32")
|
508
|
-
end
|
509
|
-
if(platform=="x86")
|
510
|
-
if(!has_key?(:x86_release_compile_flags))
|
511
|
-
self[:x86_release_compile_flags]="/property:Configuration=Release /property:Platform=\"x86\" /p:OutputPath=./bin/x86/Release"
|
512
|
-
end
|
513
|
-
array<<"<paths,msbuild> #{cs} <x86_release_compile_flags>" if RUBY_PLATFORM.include?("w32")
|
514
|
-
array<<"xbuild #{cs} <x86_release_compile_flags>" if !RUBY_PLATFORM.include?("w32")
|
515
|
-
end
|
516
|
-
if(platform=="x64")
|
517
|
-
if(!has_key?(:x64_release_compile_flags))
|
518
|
-
self[:x64_release_compile_flags]="/property:Configuration=Release /property:Platform=\"x64\" /p:OutputPath=./bin/x64/Release"
|
519
|
-
end
|
520
|
-
array<<"<paths,msbuild> #{cs} <x64_release_compile_flags>" if RUBY_PLATFORM.include?("w32")
|
521
|
-
#array<<"xbuild #{cs} <x64_release_compile_flags>" if !RUBY_PLATFORM.include?("w32")
|
522
|
-
end
|
523
|
-
}
|
524
|
-
}
|
525
|
-
|
526
|
-
if self[:type]=="c++"
|
527
|
-
if(!has_key?(:win32_release_compile_flags))
|
528
|
-
self[:win32_release_compile_flags]="/property:Configuration=Release /property:Platform=\"win32\""
|
529
|
-
end
|
530
|
-
Dir.glob("*.sln").each{|sln|
|
531
|
-
slntext=File.read(sln)
|
532
|
-
if(slntext.include?("Format Version 10.00"))
|
533
|
-
array<<"<paths,msbuild_vs9> #{sln} <win32_release_compile_flags>"
|
534
|
-
else
|
535
|
-
array<<"<paths,msbuild> #{sln} <win32_release_compile_flags>"
|
536
|
-
end
|
537
|
-
}
|
538
|
-
end
|
539
|
-
|
540
|
-
end
|
541
|
-
if(key=="test")
|
542
|
-
|
543
|
-
Dir.glob("*.gemspec").each { |gs|
|
544
|
-
#array << "{cmd: 'gem install ./#{gs.gsub('.gemspec','')}-#{self[:version]}.gem', capture_output: false}"
|
545
|
-
array << "{:cmd=> 'gem install #{gs.gsub('.gemspec','')}-#{self[:version]}.gem', :capture_output=> false}"
|
546
|
-
#array << "gem install ./#{gs.gsub('.gemspec','')}-#{self[:version]}.gem"
|
547
|
-
} if self[:type]=="gem"
|
548
|
-
|
549
|
-
if self[:type]=="C#"
|
550
|
-
Dir.glob("*.{Test.csproj,Features.csproj}").each { |cs|
|
551
|
-
dll_name="bin/x86/Release/#{File.basename(cs,'.csproj')}.dll"
|
552
|
-
array << "\"<paths,nunit>\" /nologo #{dll_name} /xml:#{dll_name}.nunit-results.xml" if RUBY_PLATFORM.include?("w32")
|
553
|
-
array << "mono \"<paths,nunit>\" #{dll_name}" if !RUBY_PLATFORM.include?("w32")
|
554
|
-
}
|
555
|
-
end
|
556
|
-
|
557
|
-
|
558
|
-
end
|
559
327
|
if(key=="features")
|
560
328
|
array << "cucumber features" if File.exists?("features") && Dir.glob("features/**/*.rb").length > 0
|
561
329
|
end
|
@@ -563,13 +331,7 @@ class Project < Hash
|
|
563
331
|
array << 'git diff' if File.exists?(".git")
|
564
332
|
array << "{ :cmd=> 'svn diff', :capture_output=> false}" if File.exists?(".svn")
|
565
333
|
end
|
566
|
-
|
567
|
-
array << 'git commit -a -m "rake commit all"' if File.exists?(".git")
|
568
|
-
array << 'svn commit -m "rake commit all"' if File.exists?(".svn")
|
569
|
-
end
|
570
|
-
if(key=="update")
|
571
|
-
array << 'svn update' if File.exists?(".svn")
|
572
|
-
end
|
334
|
+
|
573
335
|
|
574
336
|
value=array if array.length > 0
|
575
337
|
|
@@ -578,15 +340,10 @@ class Project < Hash
|
|
578
340
|
|
579
341
|
|
580
342
|
|
581
|
-
|
582
|
-
results = Array::new
|
583
|
-
text=File.read(filename)
|
584
|
-
text.scan(/(\w+)<\/Platform/).each{ | var_match | results << var_match[0].to_s if !results.include?(var_match[0].to_s)}
|
585
|
-
results
|
586
|
-
end
|
343
|
+
|
587
344
|
end
|
588
345
|
end # module Dev
|
589
346
|
|
590
|
-
|
591
|
-
|
592
|
-
DEV
|
347
|
+
DEV=Dev::Project.new(nil,true)
|
348
|
+
DEV.refresh
|
349
|
+
PROJECT=DEV
|
data/lib/dev/Tasks.rb
CHANGED
@@ -33,7 +33,7 @@ def generate_task_hash(project)
|
|
33
33
|
task_hash[:update]={ :desc=> 'updates changes from source code management' }
|
34
34
|
end
|
35
35
|
|
36
|
-
task_hash[:compile] = { :desc=> 'compile source code' } if project.has_key?(:compile)
|
36
|
+
task_hash[:compile] = { :desc=> 'compile source code' } if CMD.has_key?(:compile) || project.has_key?(:compile)
|
37
37
|
task_hash[:replace] = { :desc=> 'replace text' } if project.has_key?(:replace)
|
38
38
|
|
39
39
|
if project[:type]=="gem" || project[:type]=="ruby"
|
@@ -50,7 +50,8 @@ def generate_tasks(project)
|
|
50
50
|
name=k.to_s
|
51
51
|
desc=nil
|
52
52
|
desc=v[:desc] if v.has_key?(:desc)
|
53
|
-
ruby="task :#{name} do; task_start '#{name}'; PROJECT.#{name}; end"
|
53
|
+
#ruby="task :#{name} do; task_start '#{name}'; PROJECT.#{name}; end" if PROJECT.respond_to?(name)
|
54
|
+
ruby="task :#{name} do; task_start '#{name}'; CMD.#{name}; end"
|
54
55
|
ruby="desc '#{desc}'; " + ruby unless desc.nil?
|
55
56
|
if !task_exists?(name)
|
56
57
|
puts_debug "defining task " + name
|
@@ -63,7 +64,7 @@ def generate_tasks(project)
|
|
63
64
|
Rake.application.instance_variable_get('@tasks').delete('default')
|
64
65
|
task_list=""
|
65
66
|
["check","add","setup","replace","compile","post_compile","test","commit","update"].each {|t|
|
66
|
-
if(hash.has_key?(t.to_sym) || task_exists?(t) )
|
67
|
+
if(hash.has_key?(t.to_sym) || task_exists?(t) || CMD.has_key?(t.to_sym) )
|
67
68
|
task_list = "#{task_list}," if task_list.length > 0
|
68
69
|
task_list = "#{task_list} :#{t}"
|
69
70
|
default_code = "#{default_code} :#{t},"
|
@@ -81,6 +82,15 @@ def task_exists?(name)
|
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
|
-
|
85
|
-
|
86
|
-
|
85
|
+
module Dev
|
86
|
+
class Tasks < Hash
|
87
|
+
def refresh
|
88
|
+
DEV.refresh
|
89
|
+
CMD.refresh
|
90
|
+
generate_tasks(DEV)
|
91
|
+
end
|
92
|
+
end # class Tasks
|
93
|
+
end # module Dev
|
94
|
+
|
95
|
+
TASKS=Dev::Tasks.new
|
96
|
+
TASKS.refresh
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Dev
|
2
|
+
module Cmd
|
3
|
+
class Compile
|
4
|
+
def self.get_auto_compile_directives
|
5
|
+
array=Array.new
|
6
|
+
windows=RUBY_PLATFORM.include?("w32")
|
7
|
+
|
8
|
+
# jamfiles
|
9
|
+
|
10
|
+
# vcxproj
|
11
|
+
Dir.glob('**/*.vcxproj').each { |vcxproj| array << "<paths,msbuild> #{vcxproj} /property:Configuration=Release /property:Platform=Win32" } if windows
|
12
|
+
|
13
|
+
# csproj
|
14
|
+
csbuild="<paths,msbuild>"
|
15
|
+
csbuild="xbuild" if !RUBY_PLATFORM.include?("w32")
|
16
|
+
Dir.glob('**/*.csproj').each { |csproj|
|
17
|
+
platforms=Dev::Cmd::Compile.extract_platforms(csproj)
|
18
|
+
platforms.each { |platform|
|
19
|
+
skip=(!RUBY_PLATFORM.include?("w32") && platform=="x64")
|
20
|
+
array << "#{csbuild} #{csproj} /property:Configuration=Release /property:Platform=\"#{platform}\" /p:OutputPath=./bin/#{platform}/Release" if !skip
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
# gemspec
|
25
|
+
Dir.glob("*.gemspec").each { |gs| array << "{ :cmd=> 'gem build #{gs}', :capture_output=> false}" }
|
26
|
+
|
27
|
+
array=nil if array.empty?
|
28
|
+
return array
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.extract_platforms(filename)
|
32
|
+
results = Array::new
|
33
|
+
text=File.read(filename)
|
34
|
+
text.scan(/(\w+)<\/Platform/).each{ | var_match | results << var_match[0].to_s if !results.include?(var_match[0].to_s)}
|
35
|
+
results
|
36
|
+
end
|
37
|
+
end # class Compile
|
38
|
+
end # module Cmd
|
39
|
+
end # module Dev
|
data/lib/dev/cmd/Info.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.146
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -165,6 +165,9 @@ files:
|
|
165
165
|
- LICENSE
|
166
166
|
- README
|
167
167
|
- lib/dev/BoostBuild.rb
|
168
|
+
- lib/dev/cmd/Compile.rb
|
169
|
+
- lib/dev/cmd/Info.rb
|
170
|
+
- lib/dev/Commands.rb
|
168
171
|
- lib/dev/Database.rb
|
169
172
|
- lib/dev/Dep.rb
|
170
173
|
- lib/dev/Environment.rb
|