flak 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in flak.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/flak ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'flak'
4
+
5
+ Flak::CLI.start
data/flak.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "flak/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "flak"
7
+ s.version = Flak::VERSION
8
+ s.authors = ["Julian Mann"]
9
+ s.email = ["julian.mann@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{build system for VFX tools}
12
+ s.description = %q{VFX tool build and documentation framework based on rake with thor generators}
13
+ s.add_dependency('thor')
14
+ s.rubyforge_project = "flak"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "awesome_print"
24
+ s.add_runtime_dependency "nanoc"
25
+
26
+
27
+
28
+ end
29
+
30
+
31
+
@@ -0,0 +1,5 @@
1
+ class String
2
+ def camelize
3
+ self.split(/[^a-z0-9]/i).map{|w| w.capitalize}.join
4
+ end
5
+ end
data/lib/flak/cpp.rb ADDED
@@ -0,0 +1,137 @@
1
+
2
+
3
+ module Flak
4
+
5
+ # module methods in this module set up defaults when doing c++ builds
6
+ # some instance methods are provided - they will be inherited by target objects
7
+
8
+ module Cpp
9
+
10
+
11
+ def self.resolve_settings( existing_settings )
12
+ f = existing_settings[:root] + '/config/cpp.yml'
13
+ h =Flak.flatten_settings(f,existing_settings[:configuration], existing_settings[:os] )
14
+ #override the build dir
15
+ h[:build_dir] = File.join("build", existing_settings[:product_revision] , existing_settings[:os], existing_settings[:configuration])
16
+
17
+ h
18
+ end
19
+
20
+ # path to target build: e.g. /hq/dev/jtools/build/2009.3/darwin/debug/jAnimal.bundle
21
+
22
+ # generate path to object build from source: e.g. /hq/dev/jtools/build/2009.3/darwin/debug/animal/sensor.o"
23
+ def object_file(source)
24
+ File.join(@settings[:build_dir], source.gsub("/src/","/").ext( @settings[:object_extension] ))
25
+ end
26
+
27
+ # collect all object files for this target
28
+ def object_files
29
+ @settings[:source_files].collect { |s| object_file(s) }
30
+ end
31
+
32
+ def c_compile_cmd(source)
33
+ compiler = "\"#{@settings[:compiler]}\""
34
+ object = "#{@settings[:object_flag]}\"#{object_file(source)}\""
35
+ source = "\"#{source}\""
36
+ inc_path = (@settings[:source_files].collect {|f| f.pathmap('%d')}.uniq | ( @settings[:include_paths] || [] )).collect { |el| "#{@settings[:include_flag]}\"#{el.to_s}\"" }.join(" ")
37
+ includes = ( @settings[:includes] || [] ).collect { |el| "-include \"#{el.to_s}\"" }.join(" ")
38
+ compiler_options = (@settings[:compiler_options] || [] ).collect { |el| el.to_s }.join(" ")
39
+ "#{compiler} #{compiler_options} #{source} #{object} #{inc_path} #{includes}"
40
+ end
41
+
42
+
43
+ def c_link_cmd
44
+ #puts "c_link_cmd" + ("*" * 10)
45
+ # puts @settings[:linker_options]
46
+
47
+ linker = "\"#{@settings[:linker]}\""
48
+ objects = object_files.collect { |el| "\"#{el.to_s}\"" }
49
+ # libstr = ((@settings[:libs] || []).collect { |el| "-l#{el.to_s}" } | (@settings[:static_libs] || []).collect { |el| "#{@settings[:static_prefix_flag]} -l#{el.to_s}" }).join(" ")
50
+ libstr = (@settings[:libs] || []).collect { |el| "#{@settings[:lib_flag]}#{el.to_s}#{@settings[:lib_ext]}" }.join(" ")
51
+ libpathstr = (@settings[:lib_paths] || []).collect { |el| "#{@settings[:libpath_flag]}\"#{el.to_s}\"" }.join(" ")
52
+ linkflagstr = ( @settings[:linker_options] || [] ).collect { |el| el.to_s }.join(" ")
53
+ dso_flagstr = (@settings[:dso_options] || [] ).collect { |el| el.to_s }.join(" ")
54
+ fwrk = (@settings[:frameworks] || [] ).collect { |el| "#{@settings[:framework_flag]} #{el.to_s}" }.join(" ")
55
+ "#{linker} #{dso_flagstr} #{linkflagstr} #{libpathstr} #{libstr} #{fwrk} #{@settings[:outputfile_flag]}\"#{filename}\" #{objects}"
56
+ end
57
+
58
+ def c_clean_cmd
59
+ objects = object_files.collect { |el| "\"#{el.to_s}\"" }
60
+ "rm -f \"#{filename}\" #{objects}"
61
+ end
62
+
63
+
64
+ def target_release_path
65
+ File.join( @settings[:versioned_os_release_path], @settings[:target_release_prefix], self.filename.pathmap('%f'))
66
+ end
67
+
68
+ def cpp_instance_tasks
69
+ files = @settings[:source_files]
70
+ unless files.nil?
71
+
72
+ # file tasks to compile objects from sources
73
+ ######################################################
74
+ files.each do |f|
75
+ object = object_file(f)
76
+ file object => f do |t|
77
+ Flak.make_dir_for(object)
78
+
79
+ sh c_compile_cmd(f)
80
+ end
81
+ header = f.ext('h')
82
+ file object => header if File.exists?(header)
83
+ end
84
+ ######################################################
85
+
86
+ # file tasks to link targets
87
+ ######################################################
88
+ objects = object_files
89
+ file self.filename => objects do
90
+ Flak.make_dir_for(self.filename)
91
+ sh c_link_cmd
92
+ end
93
+
94
+ namespace @settings[:name].to_sym do
95
+ desc "build the #{@settings[:name].to_sym} binary"
96
+ task :build => self.filename # add named target
97
+ end
98
+ task :build => "#{@settings[:name].to_sym}:build"
99
+ ######################################################
100
+
101
+ # tasks to clean the build
102
+ ######################################################
103
+ namespace @settings[:name].to_sym do
104
+ desc "clean the #{@settings[:name].to_sym} build files"
105
+ task :clean do
106
+ sh c_clean_cmd
107
+ end
108
+ end
109
+ task :clean => "#{@settings[:name].to_sym}:clean"
110
+ ######################################################
111
+
112
+ # plugins and executables release tasks
113
+ ######################################################
114
+ released_binary = self.target_release_path
115
+ file released_binary => self.filename do
116
+ Flak.make_dir_for(released_binary)
117
+ rm_r released_binary if File.exists?(released_binary)
118
+ cp self.filename, released_binary
119
+ File.chmod 0755, released_binary
120
+ end
121
+
122
+ namespace @settings[:name].to_sym do
123
+ task :release => released_binary
124
+ end
125
+ task :release => "#{@settings[:name].to_sym}:release"
126
+ ######################################################
127
+
128
+ end
129
+ end
130
+
131
+
132
+
133
+ end
134
+ end
135
+
136
+
137
+
@@ -0,0 +1,121 @@
1
+
2
+ module Flak
3
+
4
+ module Delight
5
+
6
+ # to resolve settings for a template, we have access to the full hash of existing settings
7
+ # so that we may use, for example, some existing paths to build new paths for this object.
8
+ # in the first place, we call flatten_settings with the configuration and os, which
9
+ # definitely already exist.
10
+ def self.resolve_settings( existing_settings )
11
+
12
+ f = existing_settings[:root] + '/config/delight.yml'
13
+ h =Flak.flatten_settings(f,existing_settings[:configuration], existing_settings[:os] )
14
+
15
+ versioned_location = File.join("#{h[:delight_location]}-#{h[:delight_version]}")
16
+
17
+ h[:lib_paths] = [ File.join(versioned_location, "lib" ) ]
18
+ h[:include_paths] = [ File.join(versioned_location, "include") ]
19
+ h[:shader_compiler] = File.join(versioned_location, "bin","shaderdl")
20
+ h[:shader_build_dir] = existing_settings[:build_dir]
21
+ h[:libs] = ["3delight"]
22
+ h[:shader_include_paths] = [File.join(versioned_location, "maya","rsl") ]
23
+
24
+ h
25
+ end
26
+
27
+ # all shader build files
28
+ def shader_files()
29
+ @settings[:sl_files].collect { |f| shader_file(f) }
30
+ end
31
+
32
+
33
+ # path to shader build: e.g. /hq/dev/jtools/build/2009.3/darwin/debug/goosebump.sdl
34
+ def shader_file(source)
35
+ File.join(@settings[:shader_build_dir], source.gsub("/src/","/").ext('sdl'))
36
+ end
37
+
38
+ def shader_release_path(file)
39
+ File.join(@settings[:versioned_os_release_path] , @settings[:shader_release_prefix], file.pathmap('%f'))
40
+ end
41
+
42
+ def delight_shader_compile_cmd(dest,src)
43
+ include_path_string = (@settings[:sl_files].collect {|f| f.pathmap('%d')}.uniq | ( @settings[:shader_include_paths] || [] )).collect { |el| "-I#{el.to_s}" }.join(" ")
44
+ shader_type_string = "-DSHADER_TYPE_#{src.pathmap('%d').pathmap('%f')}"
45
+ "#{@settings[:shader_compiler]} #{shader_type_string} #{include_path_string} -d #{dest} #{src}"
46
+ end
47
+
48
+
49
+ def delight_clean_cmd
50
+ "rm -f #{shader_files}"
51
+ end
52
+
53
+
54
+ def delight_instance_tasks
55
+ # delight shader build and release tasks
56
+ ######################################################
57
+ files = @settings[:sl_files]
58
+ unless files.nil?
59
+
60
+ files.each do |f|
61
+
62
+
63
+
64
+ # file tasks to build shader from sources
65
+ ######################################################
66
+ target_shader = shader_file(f)
67
+ file target_shader => f do |t|
68
+ dest = Flak.make_dir_for(target_shader)
69
+ sh delight_shader_compile_cmd(dest,f)
70
+ end
71
+
72
+ namespace @settings[:name].to_sym do
73
+ desc "build the #{@settings[:name].to_sym} delight shaader"
74
+ task :build => target_shader
75
+ end
76
+ task :build => "#{@settings[:name].to_sym}:build"
77
+ ######################################################
78
+
79
+
80
+
81
+ # file tasks to release shaders
82
+ ######################################################
83
+ released_shader = shader_release_path(target_shader)
84
+ file released_shader => target_shader do
85
+ Flak.make_dir_for(released_shader)
86
+ cp target_shader, released_shader
87
+ end
88
+
89
+ namespace @settings[:name].to_sym do
90
+ task :release => released_shader
91
+ end
92
+ task :release => "#{@settings[:name].to_sym}:release"
93
+ ######################################################
94
+
95
+
96
+ end
97
+
98
+
99
+ # task to clean the build files
100
+ ######################################################
101
+ namespace @settings[:name].to_sym do
102
+ desc "clean the #{@settings[:name].to_sym} build files"
103
+ task :clean do
104
+ sh delight_clean_cmd
105
+ end
106
+ end
107
+ task :clean => "#{@settings[:name].to_sym}:clean"
108
+ ######################################################
109
+
110
+
111
+
112
+
113
+
114
+
115
+ end
116
+ end
117
+
118
+
119
+ end
120
+ end
121
+
data/lib/flak/doc.rb ADDED
@@ -0,0 +1,259 @@
1
+
2
+
3
+ module Flak
4
+
5
+ module Doc
6
+
7
+ def self.resolve_settings( existing_settings )
8
+ f = existing_settings[:root] + '/config/doc.yml'
9
+ h =Flak.flatten_settings(f,existing_settings[:configuration], existing_settings[:os] )
10
+
11
+ h[:full_site_index_file] = File.join(existing_settings[:root],h[:site_index_file])
12
+ # puts "doc_release_root = #{existing_settings[:doc_release_root]}"
13
+ # puts "name = #{@settings[:name]}"
14
+ # h[:doc_release_path] = File.join( existing_settings[:doc_release_root] , existing_settings[:name])
15
+ h
16
+ end
17
+
18
+ def doc_dir
19
+ File.join( @settings[:target_root],"doc")
20
+ end
21
+ def output_dir()
22
+ File.join(doc_dir ,"output")
23
+ end
24
+
25
+ def content_dir()
26
+ File.join(doc_dir ,"content")
27
+ end
28
+
29
+ #h[:versioned_doc_release_path] = File.join( h[:release_root] , "#{h[:product_revision]}-#{h[:os]}" )
30
+
31
+ #def doc_release_path
32
+ # File.join( @settings[:doc_release_root] , @settings[:name])
33
+ ## File.join(@settings[:release_root], "#{@settings[:product_revision]}-doc")
34
+ #end
35
+
36
+ def release_dir
37
+ File.join( @settings[:doc_release_root] , @settings[:name])
38
+ end
39
+
40
+ def copy_to_release_dir
41
+ r = release_dir
42
+ rm_rf r if File.exists? r
43
+ Flak.make_dir_for(r)
44
+ FileUtils.cp_r output_dir, r if File.exists? output_dir
45
+ end
46
+
47
+
48
+ # get the header information out of the index file so we can
49
+ # build its site index entry
50
+ #def index_hash
51
+ # h={}
52
+ # Dir.chdir(@root) do
53
+ # h = YAML::load_file( File.join(self.content_dir,'index.txt') )
54
+ # end
55
+ # h
56
+ #end
57
+
58
+
59
+ ######################################################
60
+ def site_index_hash
61
+ h = {
62
+ 'title' => "#{@settings[:product_revision]}",
63
+ 'author' => @settings[:author],
64
+ 'email' => @settings[:email],
65
+ 'created_at' => "#{Date.today.day} #{Date::MONTHNAMES[Date.today.month]} #{Date.today.year}",
66
+ 'description' => "#{@settings[:product_revision]} documentation",
67
+ 'doc_type' => "Site Index",
68
+ 'layout' => "tools_doc",
69
+ 'filter' => ['erb', 'textile']
70
+ }
71
+ end
72
+
73
+
74
+
75
+ def write_site_index_header(f)
76
+ YAML.dump(site_index_hash, f)
77
+ f.puts '---'
78
+ f.puts "h3. Projects\n\n"
79
+ f.puts "table(d1)."
80
+ f.puts "|_(projname). Project Name |_(projauth). Author|_(projdate). Created|\n\n"
81
+ end
82
+
83
+
84
+
85
+ def write_header_to_site_index(f,hash)
86
+ unless hash.nil?
87
+ if hash.has_key?('description') && (!hash['description'].nil?)
88
+
89
+ doc_link = File.join(hash['title'],'index.html')
90
+ f.puts 'table(d1).'
91
+ f.puts "|(projname). \"#{hash['title']}\":#{doc_link} |(projauth). \"#{hash['author']}\":mailto:#{hash['email']} |(projdate). #{hash['created_at']}|"
92
+ f.puts '|\3(projdesc). '+ hash['description'] +'|'
93
+ f.puts "\n\n"
94
+ else
95
+ "WARNING: Problem with description for #{hash['title']}. Please check header in #{f}"
96
+ end
97
+ end
98
+ end
99
+
100
+
101
+ # List of documentation objects
102
+ ##############################################
103
+ def doc_objects
104
+ arr = Array.new
105
+ FileList.new('**/target.yml').each do |path|
106
+ path = File.join(@settings[:root],path)
107
+ h = YAML::load_file(path)
108
+ if h.has_key?('templates')
109
+ if (h['templates']).kind_of?(Array)
110
+ if h['templates'].include?('doc')
111
+ index_file = File.join(File.dirname(path) , 'doc/content/index.txt')
112
+ if File.exists?(index_file)
113
+ arr << YAML::load_file(index_file )
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+ arr.sort! {|x,y| x['title'] <=> y['title'] }
120
+ end
121
+ ##############################################
122
+
123
+ def write_site_index
124
+ File.open(@settings[:full_site_index_file] , 'w') do |f|
125
+ self.write_site_index_header(f)
126
+ doc_objects.each do |hash|
127
+ write_header_to_site_index(f,hash)
128
+ end
129
+ end
130
+ end
131
+
132
+ # if a command exists to do the conversion - make a file task for each of icon and out_icon
133
+ # that is - one for the hypershade and one for the outliner
134
+ def doc_instance_tasks
135
+
136
+ namespace @settings[:name].to_sym do
137
+ namespace :doc do
138
+
139
+ desc "build documentation for #{@settings[:name]}"
140
+ task :rebuild do
141
+
142
+ write_site_index if @settings[:name] == 'jRelease'
143
+ puts "doc_dir #{doc_dir}"
144
+ Dir.chdir(doc_dir) do |d|
145
+ sh "webby rebuild"
146
+ end
147
+ end
148
+
149
+
150
+ desc "release documentation for #{@settings[:name]}"
151
+ task :release => "#{@settings[:name].to_sym}:doc:rebuild" do
152
+ # release_doc
153
+ Dir.chdir(@settings[:target_dir]) do |d|
154
+ self.copy_to_release_dir
155
+ end
156
+
157
+ if (@settings[:name] == "jRelease" )
158
+ index = File.join( self.release_dir, 'site_index.html' )
159
+ # rel_notes = File.join(@settings[:versioned_os_release_path], 'doc',@settings[:name],'release_notes.html' )
160
+ css = File.join(self.release_dir,'css' )
161
+ images = File.join(self.release_dir,'images' )
162
+ dest = File.join(@settings[:doc_release_root],'' )
163
+ mv index , dest
164
+ # mv rel_notes , dest
165
+ cp_r css , dest
166
+ cp_r images , dest
167
+ end
168
+
169
+ end
170
+
171
+ desc "clobber documentation for #{@settings[:name]}"
172
+ task :clobber do
173
+ Dir.chdir(doc_dir) do |d|
174
+ sh "webby clobber"
175
+ end
176
+ # d = self.release_dir
177
+ rm_rf self.release_dir if File.exists? self.release_dir
178
+ end
179
+
180
+
181
+
182
+
183
+
184
+
185
+ desc "initialize a project for documenation"
186
+ task :init do
187
+ doc_dir = File.join(@settings[:target_dir],"doc")
188
+ flak_doc_dir = File.join(@settings[:root],"flak","doc")
189
+ index_erb_file = File.join(flak_doc_dir,"erb","index.txt.erb")
190
+ index_destination_file = File.join(content_dir,"index.txt")
191
+
192
+
193
+ FileUtils.mkdir_p doc_dir
194
+
195
+ Dir.chdir(doc_dir) do
196
+ Flak.copy_over File.join(flak_doc_dir,"Sitefile"), File.join(Dir.pwd, "Sitefile")
197
+ Flak.copy_over File.join(flak_doc_dir,"lib"), File.join(Dir.pwd, "lib")
198
+ Flak.copy_over File.join(flak_doc_dir,"tasks"), File.join(Dir.pwd, "tasks")
199
+ FileUtils.mkdir_p ["content","layouts","output","scenes"]
200
+ Dir.chdir("content") do
201
+ FileUtils.mkdir_p ["css","images","media"]
202
+ Dir.chdir("css") do
203
+ Flak.copy_over File.join(flak_doc_dir,"content/css/page.css"), File.join(Dir.pwd, "page.css")
204
+ end
205
+ Dir.chdir("images") do
206
+ [ "array.gif" , "connectable.gif" , "create.gif","edit.gif","forkme_right_red_aa0000.png","hidden.gif","input.gif","jToolsSnapon.jpg" ,"keyable.gif","logo.jpg","multiuse.gif","output.gif","query.gif","storable.gif","vfxoverflow_ribbon.png" ].each do |img|
207
+ #puts "******************"
208
+ #puts File.exists? File.join(flak_doc_dir,"content/images/",img)
209
+ # puts Dir.pwd
210
+ # puts File.exists? img
211
+
212
+ Flak.copy_over File.join(flak_doc_dir,"content/images/",img) , File.join(Dir.pwd, img)
213
+ end
214
+ end
215
+ end
216
+ Dir.chdir("layouts") do
217
+ Flak.copy_over File.join(flak_doc_dir,"layouts/tools_doc.html"), File.join(Dir.pwd, "tools_doc.html")
218
+ end
219
+
220
+ # make the index
221
+
222
+ write_erb_template(index_erb_file,index_destination_file, {:no_force => true})
223
+
224
+ end
225
+ end
226
+
227
+ # desc "create index.txt with common textile markup examples"
228
+ # task :create_skeleton_index => "#{@settings[:name].to_sym}:doc:create_doc_links" do
229
+ # write_erb_template(index_erb_file,index_destination_file)
230
+ # end
231
+ #
232
+ # desc "initialize a project for documenation"
233
+ # task :init => "#{@settings[:name].to_sym}:doc:create_skeleton_index"
234
+
235
+
236
+ end
237
+ end
238
+
239
+
240
+ task :doc => "#{@settings[:name].to_sym}:doc:release"
241
+
242
+ namespace :doc do
243
+ task :clobber => "#{@settings[:name].to_sym}:doc:clobber"
244
+ end
245
+
246
+ end
247
+ ################################################################################
248
+
249
+
250
+ desc "release all documentation"
251
+ task :doc
252
+
253
+ desc "clobber all documentation"
254
+ namespace :doc do
255
+ task :clobber
256
+ end
257
+ end
258
+ end
259
+
data/lib/flak/gl.rb ADDED
@@ -0,0 +1,10 @@
1
+
2
+
3
+ module Flak
4
+ module Gl
5
+ def self.resolve_settings( existing_settings )
6
+ f = existing_settings[:root] + '/config/gl.yml'
7
+ Flak.flatten_settings(f,existing_settings[:configuration], existing_settings[:os] )
8
+ end
9
+ end
10
+ end
data/lib/flak/mac.rb ADDED
@@ -0,0 +1,23 @@
1
+
2
+
3
+
4
+ module Flak
5
+
6
+ module Mac
7
+
8
+
9
+ def self.resolve_settings( existing_settings )
10
+
11
+ f = existing_settings[:root] + '/config/mac.yml'
12
+ h =Flak.flatten_settings(f,existing_settings[:configuration], existing_settings[:os] )
13
+
14
+ h
15
+ end
16
+
17
+ def mac_app_release_path(file)
18
+ File.join(@settings[:versioned_os_release_path], 'bin', "#{file.pathmap('%f').pathmap('%X')}-#{@settings[:product_revision]}#{file.pathmap('%x')}")
19
+ end
20
+
21
+ end
22
+ end
23
+
data/lib/flak/max.rb ADDED
@@ -0,0 +1,29 @@
1
+
2
+
3
+
4
+ module Flak
5
+
6
+ module Max
7
+
8
+ def self.resolve_settings( existing_settings )
9
+
10
+ f = existing_settings[:root] + '/config/max.yml'
11
+ h =Flak.flatten_settings(f,existing_settings[:configuration], existing_settings[:os] )
12
+
13
+ case existing_settings[:os]
14
+ when /linux_64/
15
+ h[:nuke_location] = ""
16
+ when /darwin/
17
+ h[:nuke_location] = ""
18
+ when /win_64/
19
+ h[:nuke_location] = ""
20
+ end
21
+ h
22
+ end
23
+
24
+ def max_script_release_path(file)
25
+ File.join(@settings[:versioned_os_release_path], 'max', 'scripts', file.pathmap('%f'))
26
+ end
27
+ end
28
+ end
29
+