flak 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/flak +5 -0
- data/flak.gemspec +31 -0
- data/lib/core_ext/string.rb +5 -0
- data/lib/flak/cpp.rb +137 -0
- data/lib/flak/delight.rb +121 -0
- data/lib/flak/doc.rb +259 -0
- data/lib/flak/gl.rb +10 -0
- data/lib/flak/mac.rb +23 -0
- data/lib/flak/max.rb +29 -0
- data/lib/flak/maya.rb +142 -0
- data/lib/flak/maya_app.rb +45 -0
- data/lib/flak/maya_plugin.rb +47 -0
- data/lib/flak/nuke.rb +29 -0
- data/lib/flak/target.rb +120 -0
- data/lib/flak/thor/cli.rb +7 -0
- data/lib/flak/thor/generate.rb +295 -0
- data/lib/flak/thor/junk/junk.rb +65 -0
- data/lib/flak/thor/templates/INSTALL.tt +115 -0
- data/lib/flak/thor/templates/Rakefile.tt +10 -0
- data/lib/flak/thor/templates/cpp.tt +153 -0
- data/lib/flak/thor/templates/delight.tt +14 -0
- data/lib/flak/thor/templates/env.tt +26 -0
- data/lib/flak/thor/templates/gl.tt +27 -0
- data/lib/flak/thor/templates/mac.tt +0 -0
- data/lib/flak/thor/templates/max.tt +1 -0
- data/lib/flak/thor/templates/maya.tt +16 -0
- data/lib/flak/thor/templates/maya_app.tt +80 -0
- data/lib/flak/thor/templates/maya_plugin.tt +59 -0
- data/lib/flak/thor/templates/nuke.tt +2 -0
- data/lib/flak/thor/templates/product.mel.tt +34 -0
- data/lib/flak/thor/templates/product.sh.tt +35 -0
- data/lib/flak/version.rb +3 -0
- data/lib/flak.rb +357 -0
- metadata +122 -0
data/lib/flak.rb
ADDED
@@ -0,0 +1,357 @@
|
|
1
|
+
require 'flak/version'
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'find'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'erb'
|
8
|
+
require "thor"
|
9
|
+
require "thor/group"
|
10
|
+
require "ap"
|
11
|
+
|
12
|
+
require 'core_ext/string'
|
13
|
+
|
14
|
+
require 'flak/cpp'
|
15
|
+
require 'flak/delight'
|
16
|
+
require 'flak/doc'
|
17
|
+
require 'flak/gl'
|
18
|
+
require 'flak/mac'
|
19
|
+
require 'flak/max'
|
20
|
+
require 'flak/maya'
|
21
|
+
require 'flak/maya_app'
|
22
|
+
require 'flak/maya_plugin'
|
23
|
+
require 'flak/nuke'
|
24
|
+
require 'flak/target'
|
25
|
+
require 'flak/version'
|
26
|
+
require 'flak/thor/generate'
|
27
|
+
require 'flak/thor/cli'
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
module Flak
|
32
|
+
|
33
|
+
# return a slightly nicer OS string than the
|
34
|
+
# RUBY_PLATFORM variable
|
35
|
+
def self.os
|
36
|
+
case RUBY_PLATFORM
|
37
|
+
when /64-linux/
|
38
|
+
'linux_64'
|
39
|
+
when /i686_linux/
|
40
|
+
'linux_32'
|
41
|
+
when /darwin/
|
42
|
+
'darwin'
|
43
|
+
when /i386-cygwin/
|
44
|
+
'win_64'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
# merge_setting TODO - move to a Hash#merge block
|
51
|
+
# if the same key is being offered and the value is an array, then we merge the arrays.
|
52
|
+
# otherwise it is a string, so the new one overrides the existing one.
|
53
|
+
def self.merge_setting(hash, setting_key, setting_value)
|
54
|
+
if hash.has_key?(setting_key)
|
55
|
+
if setting_value.kind_of?(Array)
|
56
|
+
hash[setting_key.to_sym] |= setting_value
|
57
|
+
else
|
58
|
+
hash[(setting_key.to_sym)] = setting_value
|
59
|
+
end
|
60
|
+
else
|
61
|
+
hash[(setting_key.to_sym)] = setting_value
|
62
|
+
end
|
63
|
+
hash
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
# given a yml settings file, resolve the configuration and OS
|
68
|
+
# and return the new flattened hash
|
69
|
+
def self.merge_settings(hash1,hash2)
|
70
|
+
hash2.each do |k,v|
|
71
|
+
merge_setting(hash1,k,v)
|
72
|
+
end
|
73
|
+
hash1
|
74
|
+
end
|
75
|
+
|
76
|
+
# given a yml settings file, resolve the configuration and OS
|
77
|
+
# and return the new flattened hash
|
78
|
+
def self.flatten_settings(yml,configuration, os)
|
79
|
+
|
80
|
+
h = Hash.new
|
81
|
+
y_hash = YAML::load_file( yml) || {}
|
82
|
+
y_hash.each do |k,v|
|
83
|
+
|
84
|
+
# root level settings
|
85
|
+
################
|
86
|
+
if ( ! ((k =~/^os_.*/) || (k =~/^configuration_.*/)) )
|
87
|
+
h =Flak.merge_setting(h,k.to_sym, v)
|
88
|
+
else
|
89
|
+
|
90
|
+
# os specific settings
|
91
|
+
################
|
92
|
+
if (k == "os_#{os}" )
|
93
|
+
# puts "OS => #{os}"
|
94
|
+
v.each do |k1,v1|
|
95
|
+
if (k1 =~ /^configuration_.*/ )
|
96
|
+
if (k1 == "configuration_#{configuration}" )
|
97
|
+
v1.each do |k2,v2|
|
98
|
+
h =Flak.merge_setting(h,k2.to_sym, v2)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
else
|
102
|
+
h=Flak.merge_setting(h,k1.to_sym, v1)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
else
|
106
|
+
# configuration settings (not os specific)
|
107
|
+
################
|
108
|
+
if (k == "configuration_#{configuration}" )
|
109
|
+
v.each do |k1,v1|
|
110
|
+
h=Flak.merge_setting(h,k1.to_sym, v1)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
################
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
################
|
118
|
+
end
|
119
|
+
# ap h
|
120
|
+
h
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
# method responsible for returning a flat and comprehensive
|
125
|
+
# settings hash by gathering all the base config settings from
|
126
|
+
# yaml and generating others programatically.
|
127
|
+
# This settings hash will be used by targets, and by the
|
128
|
+
# release mechanism.
|
129
|
+
def self.resolve_settings( existing_settings )
|
130
|
+
|
131
|
+
# bootstrap to get the configuration and the os up front because these are needed to
|
132
|
+
# handle the logic to extract the right configuration and os settings from this and
|
133
|
+
# all subsequent yml files
|
134
|
+
# f = File.dirname(File.dirname(__FILE__)) + '/config/base.yml'
|
135
|
+
# tmp = YAML::load_file( base_file )
|
136
|
+
|
137
|
+
f = existing_settings[:root] + '/config/env.yml'
|
138
|
+
h =Flak.flatten_settings(f, existing_settings[:configuration], existing_settings[:os] )
|
139
|
+
h[:root] = existing_settings[:root]
|
140
|
+
h[:os] = Flak.os
|
141
|
+
|
142
|
+
# after this point we get values from the hash (h) wherever possible -
|
143
|
+
# Why? - because h is the flattened hash - meaning that configuration and OS specific
|
144
|
+
# settings will be correct. For example, product_revision may be different for debug and release
|
145
|
+
# sr = File.dirname(File.dirname(File.dirname(__FILE__)))
|
146
|
+
# sr = File.join("/cygdrive/c/cygwin",sr) if (Flak.os == 'win_64')
|
147
|
+
|
148
|
+
#h.merge!({:os => Flak.os})
|
149
|
+
|
150
|
+
h[:build_dir] = File.join("build", h[:product_revision] , h[:os])
|
151
|
+
h[:release_root] = File.join(h[:target_release_path], h[:product_name])
|
152
|
+
|
153
|
+
|
154
|
+
h[:versioned_os_release_path] = File.join( h[:release_root] , "#{h[:product_revision]}-#{h[:os]}" )
|
155
|
+
h[:doc_dirname] = "#{h[:product_revision]}-doc"
|
156
|
+
h[:doc_release_root] = File.join( h[:release_root] , h[:doc_dirname] )
|
157
|
+
|
158
|
+
# ap h
|
159
|
+
|
160
|
+
|
161
|
+
h
|
162
|
+
end
|
163
|
+
|
164
|
+
# in order to make a symlink, we need to remove it
|
165
|
+
# if it already exists
|
166
|
+
def self.rebuild_symlink(target_file,new_file)
|
167
|
+
if File.symlink?(new_file)
|
168
|
+
File.unlink(new_file)
|
169
|
+
end
|
170
|
+
File.symlink(target_file, new_file)
|
171
|
+
end
|
172
|
+
|
173
|
+
# if we just copy src to dest and dest exists and is a directory,
|
174
|
+
# then the src is put in the dest, as opposed to overwriting it. For
|
175
|
+
# this reason, we delete dest first.
|
176
|
+
def self.copy_over(src,dest)
|
177
|
+
remove_file(dest, true)
|
178
|
+
cp_r src, dest
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
# make a directory for a file
|
183
|
+
def self.make_dir_for(file)
|
184
|
+
FileUtils.mkdir_p file.pathmap('%d')
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
####################################################################################
|
189
|
+
######################### I N S T A N C E M E T H O D S ##########################
|
190
|
+
####################################################################################
|
191
|
+
def filename
|
192
|
+
f = @settings[:name]
|
193
|
+
f = f.ext(@settings[:target_extension] ) unless @settings[:target_extension].nil?
|
194
|
+
f = File.join(@settings[:build_dir],f)
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
def shell_script_release_path(file)
|
199
|
+
File.join(@settings[:versioned_os_release_path], 'bin', file.pathmap('%f'))
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
def write_erb_template(erb_file,released_file, opts={})
|
204
|
+
if (!(opts[:no_force] && File.exists?(released_file) ))
|
205
|
+
product_name = @settings[:product_name]
|
206
|
+
template = ERB.new( File.read(erb_file) , 0, "%<>")
|
207
|
+
File.open(released_file, 'w') do |f|
|
208
|
+
f.puts(template.result(binding))
|
209
|
+
f.chmod(opts[:chmod].to_i) if opts[:chmod]
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
def base_instance_tasks
|
217
|
+
|
218
|
+
namespace @settings[:name].to_sym do
|
219
|
+
|
220
|
+
if @settings[:name] == 'jRelease'
|
221
|
+
desc "Build everything"
|
222
|
+
task :build
|
223
|
+
|
224
|
+
clobber_list = [File.dirname(@settings[:build_dir]) , @settings[:versioned_os_release_path]]
|
225
|
+
CLOBBER.include( clobber_list )
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
# We want to release erb files by binding them using ERB. To help identify erb files we define them in
|
231
|
+
# yaml files under the key <type>_erb_files e.g. shell_erb_files or maya_script_erb_files for example
|
232
|
+
|
233
|
+
##############################################
|
234
|
+
erb_keys = @settings.keys.find_all {|el| ( el.to_s =~ /^.*_erb_files$/)}
|
235
|
+
|
236
|
+
erb_keys.each do |k|
|
237
|
+
type = k.to_s.gsub("_erb_files", "") # shell or mel
|
238
|
+
files_key = type.to_sym # :shell or :mel
|
239
|
+
|
240
|
+
release_path_proc = "#{type}_release_path".to_sym
|
241
|
+
|
242
|
+
# ap [type, files_key, release_path_proc]
|
243
|
+
|
244
|
+
files = @settings[k]
|
245
|
+
unless files.nil?
|
246
|
+
|
247
|
+
files.each do |f|
|
248
|
+
|
249
|
+
# if a filename is a key in the settings hash
|
250
|
+
# and that key is a string, replace the filename with the
|
251
|
+
# value. Also, get rid of the erb extension
|
252
|
+
# For example, if @settings[:product_name] is 'jtools' then
|
253
|
+
# product_name.csh.erb becomes jtools.csh
|
254
|
+
filename_key = f.pathmap('%f').gsub(/\..*/,'').to_sym
|
255
|
+
|
256
|
+
|
257
|
+
# hack chmod for INSTALL - really must find a better way soon
|
258
|
+
write_erb_opts = (filename_key == :INSTALL) ? {:chmod => 0755} : {}
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
f_resolved = f.pathmap('%f').pathmap('%n')
|
263
|
+
#ap filename_key
|
264
|
+
if @settings.has_key?(filename_key)
|
265
|
+
|
266
|
+
#if @settings[filename_key].kind_of?(Symbol)
|
267
|
+
f_resolved = "#{@settings[filename_key]}#{f_resolved.pathmap('%x')}"
|
268
|
+
# puts f_resolved
|
269
|
+
#end
|
270
|
+
end
|
271
|
+
|
272
|
+
released_file = self.send release_path_proc, f_resolved
|
273
|
+
|
274
|
+
|
275
|
+
file released_file => f do
|
276
|
+
|
277
|
+
Flak.make_dir_for(released_file)
|
278
|
+
write_erb_template(f,released_file,write_erb_opts)
|
279
|
+
end
|
280
|
+
|
281
|
+
desc "bind and release ERB #{released_file.pathmap('%f')}"
|
282
|
+
task released_file.pathmap('%f') => released_file
|
283
|
+
|
284
|
+
task :release => released_file.pathmap('%f')
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
##############################################
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
# @settings[:copy_only] is an array of file types that should be copied
|
293
|
+
# for example ruby files.
|
294
|
+
# If so, there should be a proc called ruby_release_path which responsible for generating the release path
|
295
|
+
# this smells a bit - not sure if it can be fixed - we will see
|
296
|
+
##############################################
|
297
|
+
copy_keys = @settings.keys.find_all {|el| ( el.to_s =~ /^.*_copy_files$/)}
|
298
|
+
|
299
|
+
copy_keys.each do |k|
|
300
|
+
type = k.to_s.gsub("_copy_files", "")
|
301
|
+
|
302
|
+
#@settings[:copy_only].each do |type|
|
303
|
+
#files_key = "#{type}_files".to_sym
|
304
|
+
release_path_proc = "#{type}_release_path".to_sym
|
305
|
+
files = @settings[k]
|
306
|
+
|
307
|
+
ap files if release_path_proc == "shell_script_release_path"
|
308
|
+
|
309
|
+
#files = @settings[files_key]
|
310
|
+
unless files.nil?
|
311
|
+
|
312
|
+
files.each do |f|
|
313
|
+
released_file = self.send release_path_proc, f
|
314
|
+
file released_file => f do
|
315
|
+
Flak.make_dir_for(released_file)
|
316
|
+
sh "cp -r #{f} #{released_file}"
|
317
|
+
File.chmod 0755, released_file if (type == 'shell' )
|
318
|
+
end
|
319
|
+
task :release => released_file
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
##############################################
|
324
|
+
|
325
|
+
desc "See resolved configuration settings for #{@settings[:name].to_sym}"
|
326
|
+
task :inspect do
|
327
|
+
ap @settings
|
328
|
+
end
|
329
|
+
|
330
|
+
desc "Release #{@settings[:name].to_sym}"
|
331
|
+
task :release # => [:rebuild_label_link ]
|
332
|
+
|
333
|
+
|
334
|
+
# every target needs the ability to initialize a doc hierarchy
|
335
|
+
# so this is where it goes
|
336
|
+
namespace :doc do
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
end # namespace doc
|
341
|
+
|
342
|
+
end # namespace name
|
343
|
+
|
344
|
+
task :release => "#{@settings[:name].to_sym}:release"
|
345
|
+
|
346
|
+
task :default => ["release"]
|
347
|
+
|
348
|
+
task :inspect do
|
349
|
+
ap @settings
|
350
|
+
end
|
351
|
+
|
352
|
+
end
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flak
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Julian Mann
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-02-20 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: thor
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: awesome_print
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: nanoc
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id003
|
48
|
+
description: VFX tool build and documentation framework based on rake with thor generators
|
49
|
+
email:
|
50
|
+
- julian.mann@gmail.com
|
51
|
+
executables:
|
52
|
+
- flak
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
57
|
+
files:
|
58
|
+
- .gitignore
|
59
|
+
- Gemfile
|
60
|
+
- Rakefile
|
61
|
+
- bin/flak
|
62
|
+
- flak.gemspec
|
63
|
+
- lib/core_ext/string.rb
|
64
|
+
- lib/flak.rb
|
65
|
+
- lib/flak/cpp.rb
|
66
|
+
- lib/flak/delight.rb
|
67
|
+
- lib/flak/doc.rb
|
68
|
+
- lib/flak/gl.rb
|
69
|
+
- lib/flak/mac.rb
|
70
|
+
- lib/flak/max.rb
|
71
|
+
- lib/flak/maya.rb
|
72
|
+
- lib/flak/maya_app.rb
|
73
|
+
- lib/flak/maya_plugin.rb
|
74
|
+
- lib/flak/nuke.rb
|
75
|
+
- lib/flak/target.rb
|
76
|
+
- lib/flak/thor/cli.rb
|
77
|
+
- lib/flak/thor/generate.rb
|
78
|
+
- lib/flak/thor/junk/junk.rb
|
79
|
+
- lib/flak/thor/templates/INSTALL.tt
|
80
|
+
- lib/flak/thor/templates/Rakefile.tt
|
81
|
+
- lib/flak/thor/templates/cpp.tt
|
82
|
+
- lib/flak/thor/templates/delight.tt
|
83
|
+
- lib/flak/thor/templates/env.tt
|
84
|
+
- lib/flak/thor/templates/gl.tt
|
85
|
+
- lib/flak/thor/templates/mac.tt
|
86
|
+
- lib/flak/thor/templates/max.tt
|
87
|
+
- lib/flak/thor/templates/maya.tt
|
88
|
+
- lib/flak/thor/templates/maya_app.tt
|
89
|
+
- lib/flak/thor/templates/maya_plugin.tt
|
90
|
+
- lib/flak/thor/templates/nuke.tt
|
91
|
+
- lib/flak/thor/templates/product.mel.tt
|
92
|
+
- lib/flak/thor/templates/product.sh.tt
|
93
|
+
- lib/flak/version.rb
|
94
|
+
homepage: ""
|
95
|
+
licenses: []
|
96
|
+
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: "0"
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: "0"
|
114
|
+
requirements: []
|
115
|
+
|
116
|
+
rubyforge_project: flak
|
117
|
+
rubygems_version: 1.8.15
|
118
|
+
signing_key:
|
119
|
+
specification_version: 3
|
120
|
+
summary: build system for VFX tools
|
121
|
+
test_files: []
|
122
|
+
|