flak 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.gitignore +1 -0
  2. data/.yardoc/checksums +28 -0
  3. data/.yardoc/objects/root.dat +0 -0
  4. data/.yardoc/proxy_types +0 -0
  5. data/.yardopts +1 -0
  6. data/Architecture.md +152 -0
  7. data/Documenting.md +2 -0
  8. data/MayaModules.md +2 -0
  9. data/README.md +173 -0
  10. data/flak.gemspec +6 -3
  11. data/lib/core_ext/hash.rb +82 -0
  12. data/lib/core_ext/string.rb +41 -0
  13. data/lib/flak.rb +20 -12
  14. data/lib/flak/rake/errors.rb +28 -0
  15. data/lib/flak/rake/file_actions.rb +70 -0
  16. data/lib/flak/rake/os.rb +18 -0
  17. data/lib/flak/rake/target.rb +47 -69
  18. data/lib/flak/rake/templates/cpp.rb +211 -0
  19. data/lib/flak/rake/templates/delight.rb +168 -0
  20. data/lib/flak/rake/templates/doc.rb +106 -0
  21. data/lib/flak/rake/templates/environment.rb +189 -0
  22. data/lib/flak/rake/templates/gl.rb +20 -0
  23. data/lib/flak/rake/templates/mac.rb +29 -0
  24. data/lib/flak/rake/templates/max.rb +22 -0
  25. data/lib/flak/rake/templates/maya.rb +172 -0
  26. data/lib/flak/rake/templates/maya_app.rb +97 -0
  27. data/lib/flak/rake/templates/maya_plugin.rb +93 -0
  28. data/lib/flak/rake/templates/merge_engine.rb +45 -0
  29. data/lib/flak/rake/templates/nuke.rb +60 -0
  30. data/lib/flak/rake/templates/release.rb +101 -0
  31. data/lib/flak/rake/templates/shell.rb +54 -0
  32. data/lib/flak/thor/cli.rb +5 -0
  33. data/lib/flak/thor/generate.rb +88 -144
  34. data/lib/flak/thor/target_file.rb +36 -17
  35. data/lib/flak/thor/templates/INSTALL.tt +3 -3
  36. data/lib/flak/thor/templates/Rakefile.tt +4 -2
  37. data/lib/flak/thor/templates/{cpp.tt → config/cpp.yml.tt} +6 -8
  38. data/lib/flak/thor/templates/{delight.tt → config/delight.yml.tt} +1 -1
  39. data/lib/flak/thor/templates/{doc.tt → config/doc.yml.tt} +0 -0
  40. data/lib/flak/thor/templates/{env.tt → config/environment.yml.tt} +6 -7
  41. data/lib/flak/thor/templates/{gl.tt → config/gl.yml.tt} +0 -0
  42. data/lib/flak/thor/templates/{mac.tt → config/mac.yml.tt} +0 -0
  43. data/lib/flak/thor/templates/{max.tt → config/max.yml.tt} +0 -0
  44. data/lib/flak/thor/templates/{maya.tt → config/maya.yml.tt} +9 -1
  45. data/lib/flak/thor/templates/{maya_app.tt → config/maya_app.yml.tt} +0 -2
  46. data/lib/flak/thor/templates/{maya_plugin.tt → config/maya_plugin.yml.tt} +0 -2
  47. data/lib/flak/thor/templates/config/nuke.yml.tt +3 -0
  48. data/lib/flak/thor/templates/config/release.yml.tt +3 -0
  49. data/lib/flak/thor/templates/config/shell.yml.tt +1 -0
  50. data/lib/flak/thor/templates/doc/content/install_guide.txt.tt +71 -25
  51. data/lib/flak/thor/templates/maya_plugin_cpp.tt +37 -0
  52. data/lib/flak/thor/templates/name_cpp.tt +6 -0
  53. data/lib/flak/thor/templates/name_h.tt +34 -0
  54. data/lib/flak/thor/templates/product.sh.tt +2 -2
  55. data/lib/flak/thor/wizard.rb +28 -15
  56. data/lib/flak/version.rb +1 -1
  57. data/target.jpg +0 -0
  58. metadata +127 -94
  59. data/README.textile +0 -59
  60. data/lib/flak/rake/base.rb +0 -316
  61. data/lib/flak/rake/cpp.rb +0 -139
  62. data/lib/flak/rake/delight.rb +0 -121
  63. data/lib/flak/rake/doc.rb +0 -69
  64. data/lib/flak/rake/gl.rb +0 -10
  65. data/lib/flak/rake/mac.rb +0 -23
  66. data/lib/flak/rake/max.rb +0 -29
  67. data/lib/flak/rake/maya.rb +0 -142
  68. data/lib/flak/rake/maya_app.rb +0 -45
  69. data/lib/flak/rake/maya_plugin.rb +0 -47
  70. data/lib/flak/rake/mod.rb +0 -46
  71. data/lib/flak/rake/nuke.rb +0 -29
  72. data/lib/flak/thor/templates/mod.tt +0 -0
  73. data/lib/flak/thor/templates/nuke.tt +0 -2
@@ -0,0 +1,168 @@
1
+ module Flak::Template
2
+
3
+
4
+ module Delight
5
+ module Settings
6
+
7
+ extend Flak::Template::MergeEngine
8
+
9
+ def self.extended target
10
+ infuse target
11
+ end
12
+
13
+
14
+ def self.settings_modifications settings
15
+ mods = Hash.new
16
+
17
+ bind = binding()
18
+
19
+ Flak::Errors.assert("settings[:delight_location]", "String", bind,__FILE__)
20
+ Flak::Errors.assert("settings[:delight_version]", "String", bind,__FILE__)
21
+ Flak::Errors.assert("settings[:build_directory]", "String", bind,__FILE__)
22
+
23
+ v_loc = File.join( "#{settings[:delight_location]}-#{settings[:delight_version]}" )
24
+
25
+
26
+ mods[:lib_paths] = [ File.join( v_loc ,"lib") ]
27
+
28
+ mods[:include_paths] = [ File.join( v_loc ,"include")]
29
+
30
+ mods[:shader_compiler] = File.join( v_loc, "bin","shaderdl")
31
+
32
+ mods[:shader_build_directory] = settings[:build_directory]
33
+
34
+ mods[:libs] = ["3delight"]
35
+
36
+ mods[:shader_include_paths] = [ File.join( v_loc, "maya","rsl")]
37
+
38
+ mods
39
+ end
40
+
41
+
42
+
43
+
44
+ # all shader build files
45
+ def shader_files()
46
+ @settings[:sl_files].collect { |f| shader_file(f) }
47
+ end
48
+
49
+
50
+ # path to shader build: e.g. /hq/dev/jtools/build/2009.3/darwin/debug/goosebump.sdl
51
+ def shader_file(source)
52
+ bind = binding()
53
+ Flak::Errors.assert("@settings[:shader_build_directory]", "String", bind,__FILE__)
54
+
55
+ File.join(@settings[:shader_build_directory], source.gsub("/src/","/").ext('sdl'))
56
+ end
57
+
58
+ def shader_release_path(file)
59
+ bind = binding()
60
+ Flak::Errors.assert("@settings[:path_to_revision]", "String", bind,__FILE__)
61
+
62
+ File.join(@settings[:path_to_revision] , 'delight','shader', file.pathmap('%f'))
63
+ end
64
+
65
+ def delight_shader_compile_cmd(dest,src)
66
+ bind = binding()
67
+ Flak::Errors.assert("@settings[:shader_compiler]", "String", bind,__FILE__)
68
+
69
+ include_path_string = (@settings[:sl_files].collect {|f| f.pathmap('%d')}.uniq | ( @settings[:shader_include_paths] || [] )).collect { |el| "-I#{el.to_s}" }.join(" ")
70
+ shader_type_string = "-DSHADER_TYPE_#{src.pathmap('%d').pathmap('%f')}"
71
+ "#{@settings[:shader_compiler]} #{shader_type_string} #{include_path_string} -d #{dest} #{src}"
72
+ end
73
+
74
+
75
+ def delight_clean_cmd
76
+ "rm -f #{shader_files}"
77
+ end
78
+
79
+
80
+
81
+
82
+ end
83
+
84
+
85
+
86
+
87
+
88
+ module Tasks
89
+ def self.extended target
90
+ task_factory target
91
+ end
92
+
93
+
94
+ def self.task_factory target
95
+ settings = target.settings
96
+
97
+
98
+
99
+ files = settings[:sl_files]
100
+ unless files.nil?
101
+
102
+ files.each do |f|
103
+
104
+
105
+
106
+ # file tasks to build shader from sources
107
+ ######################################################
108
+ target_shader = target.shader_file(f)
109
+ file target_shader => f do |t|
110
+ dest = target.make_directory_for(target_shader)
111
+ sh delight_shader_compile_cmd(dest,f)
112
+ end
113
+
114
+ namespace settings[:name].to_sym do
115
+ desc "build the #{settings[:name].to_sym} delight shaader"
116
+ task :build => target_shader
117
+ end
118
+ task :build => "#{settings[:name].to_sym}:build"
119
+ ######################################################
120
+
121
+
122
+
123
+ # file tasks to release shaders
124
+ ######################################################
125
+ release_shader = target.shader_release_path(target_shader)
126
+ file release_shader => target_shader do
127
+ target.make_directory_for(release_shader)
128
+ cp target_shader, release_shader
129
+ end
130
+
131
+ namespace settings[:name].to_sym do
132
+ task :release => release_shader
133
+ end
134
+ task :release => "#{settings[:name].to_sym}:release"
135
+ ######################################################
136
+
137
+
138
+ end
139
+
140
+
141
+ # task to clean the build files
142
+ ######################################################
143
+ namespace settings[:name].to_sym do
144
+ desc "clean the #{settings[:name].to_sym} build files"
145
+ task :clean do
146
+ sh delight_clean_cmd
147
+ end
148
+ end
149
+ task :clean => "#{settings[:name].to_sym}:clean"
150
+ ######################################################
151
+
152
+
153
+
154
+
155
+
156
+
157
+ end
158
+ end
159
+
160
+ end
161
+
162
+
163
+ end
164
+
165
+
166
+
167
+ end
168
+
@@ -0,0 +1,106 @@
1
+ module Flak::Template
2
+
3
+
4
+ module Doc
5
+ module Settings
6
+
7
+ extend Flak::Template::MergeEngine
8
+
9
+ def self.extended target
10
+ infuse target
11
+ end
12
+
13
+ def self.settings_modifications settings
14
+
15
+ mods = Hash.new
16
+
17
+ bind = binding()
18
+ Flak::Errors.assert("settings[:product_revision]", "String", bind,__FILE__)
19
+ Flak::Errors.assert("settings[:release_root]", "String", bind,__FILE__)
20
+
21
+ mods[:doc_directory_name] = "#{settings[:product_revision]}-doc"
22
+
23
+ mods[:doc_destination] = File.join( settings[:release_root] , mods[:doc_directory_name] )
24
+
25
+ mods
26
+ end
27
+
28
+ def doc_default_hash(item)
29
+ bind = binding()
30
+ Flak::Errors.assert("@settings[:product_name]", "String", bind,__FILE__)
31
+ Flak::Errors.assert("@settings[:product_revision]", "String", bind,__FILE__)
32
+ Flak::Errors.assert("@settings[:author_name]", "String", bind,__FILE__)
33
+ Flak::Errors.assert("@settings[:author_email]", "String", bind,__FILE__)
34
+
35
+ {
36
+ :title => "#{@settings[:product_name].capitalize} #{item[:type]}",
37
+ :description=> "#{@settings[:product_name].capitalize} #{@settings[:product_revision]} #{item[:type]}",
38
+ :author=> @settings[:author_name],
39
+ :email=> @settings[:author_email],
40
+ :created_at => Time.now.strftime("%d %B %Y")
41
+ }
42
+ end
43
+
44
+
45
+ def doc_plug_metadata(site)
46
+ site.items.each do |item|
47
+ unless item.binary?
48
+ item[:type] = "Index" if item.identifier == "/"
49
+ item[:type] = "Release Notes" if item.identifier == "/release_notes/"
50
+ item.attributes= doc_default_hash(item).merge(item.attributes)
51
+ end
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+
58
+ module Tasks
59
+
60
+ def self.extended target
61
+ task_factory target
62
+ end
63
+
64
+
65
+
66
+ def self.task_factory target
67
+ settings = target.settings
68
+
69
+
70
+ desc "Release documentation"
71
+ task :doc do
72
+ docroot = File.join(settings[:root],'doc')
73
+ Dir.chdir(docroot) do |d|
74
+ site = Nanoc::Site.new(YAML.load_file('config.yaml'))
75
+ site.config[:output_dir] = settings[:doc_destination]
76
+ target.doc_plug_metadata(site)
77
+
78
+
79
+ puts "Compiling site..."
80
+ site.compile
81
+ puts "Done... ;)"
82
+ end
83
+ end
84
+
85
+ namespace :doc do
86
+ desc "Build and tar up documentation to tar.gz."
87
+ task :tar => :doc do
88
+ Dir.chdir( settings[:tools_directory] ) do |d|
89
+ sh "tar cfz #{settings[:product_name]}-#{settings[:product_revision]}-doc.tar.gz #{settings[:product_name]}/#{settings[:product_revision]}-doc"
90
+ end
91
+ end
92
+ end
93
+
94
+ end
95
+
96
+
97
+ end
98
+
99
+
100
+ end
101
+
102
+
103
+
104
+
105
+ end
106
+
@@ -0,0 +1,189 @@
1
+ module Flak::Template
2
+ module Environment
3
+
4
+ module Settings
5
+
6
+ extend Flak::Template::MergeEngine
7
+
8
+ def self.extended target
9
+ infuse target
10
+ end
11
+
12
+
13
+ def self.settings_modifications settings
14
+
15
+ mods = Hash.new
16
+
17
+ bind = binding()
18
+
19
+ Flak::Errors.assert("settings[:product_revision]", "String", bind,__FILE__)
20
+ Flak::Errors.assert("settings[:os]", "String", bind,__FILE__)
21
+ Flak::Errors.assert("settings[:configuration]", "String", bind,__FILE__)
22
+ Flak::Errors.assert("settings[:tools_directory]", "String", bind,__FILE__)
23
+ Flak::Errors.assert("settings[:product_name]", "String", bind,__FILE__)
24
+
25
+ mods[:build_directory] = File.join( "build", settings[:product_revision] , settings[:os], settings[:configuration])
26
+
27
+ mods[:release_root] = File.join(settings[:tools_directory], settings[:product_name])
28
+
29
+ mods[:path_to_revision] = File.join( mods[:release_root] , settings[:product_revision] )
30
+
31
+ mods[:path_to_revision] += "-#{settings[:os]}" unless settings[:agnostic]
32
+
33
+ mods
34
+ end
35
+
36
+
37
+ def destination_filepath(relative_path, file)
38
+ bind = binding()
39
+ Flak::Errors.assert("@settings[:path_to_revision]", "String", bind,__FILE__)
40
+ File.join(@settings[:path_to_revision] , relative_path , file.pathmap('%f').no_erb)
41
+ end
42
+
43
+
44
+ end
45
+
46
+
47
+ module Tasks
48
+
49
+ def self.extended target
50
+ task_factory target
51
+ end
52
+
53
+ # We want to release erb files by binding them using ERB.
54
+ # To help identify erb files we define them as Filelists in
55
+ # yaml files under the key <identifier>_erb_files
56
+ # e.g. shell_erb_files or maya_script_erb_files
57
+ # for the identifiers: shell, and maya_script respectively
58
+ def self.generate_erb_tasks target
59
+ settings = target.settings
60
+
61
+ namespace settings[:name].to_sym do
62
+
63
+ erb_keys = settings.keys.find_all {|el| ( el.to_s =~ /^.*_erb_files$/)}
64
+
65
+ erb_keys.each do |k|
66
+ identifier = k.to_s.gsub("_erb_files", "") # shell or mel
67
+ files_key = identifier.to_sym # :shell or :mel
68
+ destination_path_key = "#{identifier}_destination".to_sym
69
+
70
+ write_erb_opts = {:chmod => 0755}
71
+
72
+ files = settings[k]
73
+ unless files.nil?
74
+ files.each do |f|
75
+
76
+ if settings.has_key? destination_path_key
77
+ destination_file = target.destination_filepath( settings[destination_path_key], f)
78
+ else
79
+ destination_file = target.send destination_path_key, f
80
+ end
81
+
82
+ file destination_file => f do
83
+ target.make_directory_for(destination_file)
84
+ target.write_erb_template(f,destination_file,write_erb_opts)
85
+ end
86
+
87
+ # desc "bind and release ERB #{destination_file.pathmap('%f')}"
88
+ task destination_file.pathmap('%f') => destination_file
89
+
90
+ task :release => destination_file.pathmap('%f')
91
+
92
+
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ end
99
+
100
+
101
+
102
+ def self.generate_copy_tasks target
103
+ settings = target.settings
104
+
105
+ namespace settings[:name].to_sym do
106
+
107
+ # copy_keys is an array of keys representing file types that should be copied
108
+ # for example maya_script_copy_files
109
+ # If so, there should be a proc called maya_script_release_path which is responsible for generating the release path
110
+ # this smells a bit - not sure if it can be fixed - we will see
111
+ ##############################################
112
+ copy_keys = settings.keys.find_all {|el| ( el.to_s =~ /^.*_copy_files$/)}
113
+
114
+ copy_keys.each do |k|
115
+ identifier = k.to_s.gsub("_copy_files", "")
116
+
117
+ # destination_path_proc = "#{identifier}_destination".to_sym
118
+ destination_path_key = "#{identifier}_destination".to_sym
119
+
120
+
121
+
122
+ files = settings[k]
123
+
124
+ unless files.nil?
125
+
126
+ files.each do |f|
127
+
128
+ if settings.has_key? destination_path_key
129
+ destination_file = target.destination_filepath(settings[destination_path_key], f)
130
+ else
131
+ destination_file = target.send destination_path_key, f
132
+ end
133
+
134
+ file destination_file => f do
135
+ target.make_directory_for(destination_file)
136
+ sh "cp -r #{f} #{destination_file}"
137
+ File.chmod 0755, destination_file
138
+ end
139
+ task :release => destination_file
140
+ end
141
+ end
142
+ end
143
+ ##############################################
144
+ end
145
+
146
+
147
+ end
148
+
149
+
150
+ def self.generate_inspect_and_release_tasks target
151
+ settings = target.settings
152
+
153
+ namespace settings[:name].to_sym do
154
+
155
+ desc "See resolved configuration settings for #{settings[:name].to_sym}"
156
+ task :inspect do
157
+ ap settings
158
+ end
159
+
160
+ desc "Release #{settings[:name].to_sym}"
161
+ task :release
162
+
163
+ end
164
+ task :release => "#{settings[:name].to_sym}:release"
165
+
166
+ end
167
+
168
+
169
+
170
+
171
+
172
+ def self.task_factory target
173
+ self.generate_erb_tasks target
174
+ self.generate_copy_tasks target
175
+ self.generate_inspect_and_release_tasks target
176
+ end
177
+
178
+
179
+ end
180
+
181
+
182
+ end
183
+
184
+
185
+
186
+
187
+
188
+ end
189
+