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
@@ -1,10 +1,10 @@
1
1
  <% upname = name.upcase -%>
2
2
  # append <%= upname %> bin paths to PATH
3
- PATH=$PATH:${<%= upname %>}/bin
3
+ export PATH=$PATH:${<%= upname %>}/bin
4
4
 
5
5
  <% if project_options[:delight] -%>
6
6
  # append <%= upname %> delight paths to bin
7
- PATH=$PATH:${<%= upname %>}/delight/procedural
7
+ export PATH=$PATH:${<%= upname %>}/delight/procedural
8
8
 
9
9
  # append <%= upname %> delight resource paths
10
10
  if [[ -n $DELIGHT ]] ;then
@@ -1,44 +1,57 @@
1
1
  module Flak
2
2
  module Wizard
3
3
 
4
-
5
- # include Thor::Shell::Basic
6
-
4
+ # Promt the user for information about the project to be created.
5
+ # The result values are used to decide what files to generate and in some cases
6
+ # to define the content of files such as project.yml.
7
+ # @return [Hash] true or false values indicating the type of project.
7
8
  def self.project_options
8
9
  asker = Thor::Shell::Basic.new
9
10
  opts = Hash.new
10
- asker.say("In order to set up paths, I need to know what will be included in this project")
11
+
12
+ asker.say("Flak can set up environment variables for this project based on the tools it contains. So please answer the following questions:")
13
+
11
14
  opts[:maya_module] = asker.yes?("Will this project contain a Maya module? (y/n)")
15
+
12
16
  opts[:delight] = asker.yes?("Will this project contain 3delight tools? (y/n)")
17
+
13
18
  opts[:nuke] = asker.yes?("Will this project contain nuke tools? (y/n)")
19
+
14
20
  opts
15
21
  end
16
22
 
17
23
 
18
-
24
+ # Promt the user for information about the tool to be created.
25
+ # The result values are used to decide what files to generate and in some cases
26
+ # to define the content of files such as tool.yml.
27
+ # @return [Hash] true or false values indicating the type of tool.
19
28
  def self.tool_options
20
29
  asker = Thor::Shell::Basic.new
21
30
  opts = Hash.new
22
31
 
23
- # just determine what the compiled target is, if any:
24
-
25
32
  opts[:maya_plugin_target] = false
26
33
  opts[:maya_app_target] = false
27
34
  opts[:delight_target] = false
28
- opts[:nuke_target] = false
29
35
  opts[:standalone_target] = false
36
+ opts[:maya_scripts] = false
37
+ opts[:nuke_scripts] = false
38
+ opts[:shell_scripts] = false
30
39
 
31
- finished = false
32
-
33
- finished = opts[:maya_plugin_target] = asker.yes?("Is this tool a Maya plugin? (y/n)") unless finished
40
+ finished_target = false
41
+
42
+ finished_target = opts[:maya_plugin_target] = opts[:maya_scripts] = asker.yes?("Is this tool a Maya plugin? (y/n)") unless finished_target
34
43
 
35
- finished = opts[:maya_app_target] = asker.yes?("Is this tool a Maya standalone application? (y/n)") unless finished
44
+ finished_target = opts[:maya_app_target] = opts[:maya_scripts] = asker.yes?("Is this tool a Maya standalone application? (y/n)") unless finished_target
36
45
 
37
- finished = opts[:delight_target] = asker.yes?("Will this tool contain 3delight shaders filters or DSOs? (y/n)") unless finished
46
+ finished_target = opts[:delight_target] = asker.yes?("Will this tool contain 3delight shaders filters or DSOs? (y/n)") unless finished_target
38
47
 
39
- finished = opts[:nuke_target] = asker.yes?("Will this tool contain Nuke plugins? (y/n)") unless finished
48
+ finished_target = opts[:standalone_target] = asker.yes?("Will this tool contain a standalone application? (y/n)") unless finished_target
40
49
 
41
- finished = opts[:standalone_target] = asker.yes?("Will this tool contain a standalone application? (y/n)") unless finished
50
+ opts[:maya_scripts] = asker.yes?("Will this tool also contain maya scripts? (y/n)") unless opts[:maya_scripts]
51
+
52
+ opts[:nuke_scripts] = asker.yes?("Will this tool also contain nuke scripts? (y/n)")
53
+
54
+ opts[:shell_scripts] = asker.yes?("Will this tool also contain shell scripts? (y/n)")
42
55
 
43
56
  opts
44
57
  end
data/lib/flak/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Flak
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/target.jpg ADDED
Binary file
metadata CHANGED
@@ -1,112 +1,154 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: flak
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
4
5
  prerelease:
5
- version: 0.0.4
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Julian Mann
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-02-29 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-03-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: thor
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70316772857580 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: awesome_print
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70316772857580
25
+ - !ruby/object:Gem::Dependency
26
+ name: awesome_print
27
+ requirement: &70316772852520 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
35
33
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
34
+ prerelease: false
35
+ version_requirements: *70316772852520
36
+ - !ruby/object:Gem::Dependency
38
37
  name: nanoc
38
+ requirement: &70316772852080 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
39
45
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
46
+ version_requirements: *70316772852080
47
+ - !ruby/object:Gem::Dependency
48
+ name: sass
49
+ requirement: &70316772851280 !ruby/object:Gem::Requirement
41
50
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
46
55
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
56
+ prerelease: false
57
+ version_requirements: *70316772851280
58
+ - !ruby/object:Gem::Dependency
49
59
  name: RedCloth
60
+ requirement: &70316772850740 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
50
67
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
68
+ version_requirements: *70316772850740
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: &70316772850000 !ruby/object:Gem::Requirement
52
72
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
57
- type: :runtime
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: sass
73
+ requirements:
74
+ - - =
75
+ - !ruby/object:Gem::Version
76
+ version: 0.7.2
77
+ type: :development
61
78
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
79
+ version_requirements: *70316772850000
80
+ - !ruby/object:Gem::Dependency
81
+ name: redcarpet
82
+ requirement: &70316772848780 !ruby/object:Gem::Requirement
63
83
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
68
- type: :runtime
69
- version_requirements: *id005
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70316772848780
70
91
  description: VFX tool build and documentation framework based on rake with thor generators
71
- email:
92
+ email:
72
93
  - julian.mann@gmail.com
73
- executables:
94
+ executables:
74
95
  - flak
75
96
  extensions: []
76
-
77
97
  extra_rdoc_files: []
78
-
79
- files:
98
+ files:
80
99
  - .gitignore
100
+ - .yardoc/checksums
101
+ - .yardoc/objects/root.dat
102
+ - .yardoc/proxy_types
103
+ - .yardopts
104
+ - Architecture.md
105
+ - Documenting.md
81
106
  - Gemfile
82
- - README.textile
107
+ - MayaModules.md
108
+ - README.md
83
109
  - Rakefile
84
110
  - bin/flak
85
111
  - flak.gemspec
112
+ - lib/core_ext/hash.rb
86
113
  - lib/core_ext/string.rb
87
114
  - lib/flak.rb
88
- - lib/flak/rake/base.rb
89
- - lib/flak/rake/cpp.rb
90
- - lib/flak/rake/delight.rb
91
- - lib/flak/rake/doc.rb
92
- - lib/flak/rake/gl.rb
93
- - lib/flak/rake/mac.rb
94
- - lib/flak/rake/max.rb
95
- - lib/flak/rake/maya.rb
96
- - lib/flak/rake/maya_app.rb
97
- - lib/flak/rake/maya_plugin.rb
98
- - lib/flak/rake/mod.rb
99
- - lib/flak/rake/nuke.rb
115
+ - lib/flak/rake/errors.rb
116
+ - lib/flak/rake/file_actions.rb
117
+ - lib/flak/rake/os.rb
100
118
  - lib/flak/rake/target.rb
119
+ - lib/flak/rake/templates/cpp.rb
120
+ - lib/flak/rake/templates/delight.rb
121
+ - lib/flak/rake/templates/doc.rb
122
+ - lib/flak/rake/templates/environment.rb
123
+ - lib/flak/rake/templates/gl.rb
124
+ - lib/flak/rake/templates/mac.rb
125
+ - lib/flak/rake/templates/max.rb
126
+ - lib/flak/rake/templates/maya.rb
127
+ - lib/flak/rake/templates/maya_app.rb
128
+ - lib/flak/rake/templates/maya_plugin.rb
129
+ - lib/flak/rake/templates/merge_engine.rb
130
+ - lib/flak/rake/templates/nuke.rb
131
+ - lib/flak/rake/templates/release.rb
132
+ - lib/flak/rake/templates/shell.rb
101
133
  - lib/flak/thor/cli.rb
102
134
  - lib/flak/thor/generate.rb
103
135
  - lib/flak/thor/junk/junk.rb
104
136
  - lib/flak/thor/target_file.rb
105
137
  - lib/flak/thor/templates/INSTALL.tt
106
138
  - lib/flak/thor/templates/Rakefile.tt
107
- - lib/flak/thor/templates/cpp.tt
108
- - lib/flak/thor/templates/delight.tt
109
- - lib/flak/thor/templates/doc.tt
139
+ - lib/flak/thor/templates/config/cpp.yml.tt
140
+ - lib/flak/thor/templates/config/delight.yml.tt
141
+ - lib/flak/thor/templates/config/doc.yml.tt
142
+ - lib/flak/thor/templates/config/environment.yml.tt
143
+ - lib/flak/thor/templates/config/gl.yml.tt
144
+ - lib/flak/thor/templates/config/mac.yml.tt
145
+ - lib/flak/thor/templates/config/max.yml.tt
146
+ - lib/flak/thor/templates/config/maya.yml.tt
147
+ - lib/flak/thor/templates/config/maya_app.yml.tt
148
+ - lib/flak/thor/templates/config/maya_plugin.yml.tt
149
+ - lib/flak/thor/templates/config/nuke.yml.tt
150
+ - lib/flak/thor/templates/config/release.yml.tt
151
+ - lib/flak/thor/templates/config/shell.yml.tt
110
152
  - lib/flak/thor/templates/doc/Rules
111
153
  - lib/flak/thor/templates/doc/config.yaml
112
154
  - lib/flak/thor/templates/doc/content/assets/css/include.scss
@@ -143,47 +185,38 @@ files:
143
185
  - lib/flak/thor/templates/doc/lib/helpers.rb
144
186
  - lib/flak/thor/templates/doc/scenes/.empty_directory
145
187
  - lib/flak/thor/templates/doc/scenes/module_logo.psd
146
- - lib/flak/thor/templates/env.tt
147
188
  - lib/flak/thor/templates/gitignore.tt
148
- - lib/flak/thor/templates/gl.tt
149
189
  - lib/flak/thor/templates/init.mel.tt
150
- - lib/flak/thor/templates/mac.tt
151
- - lib/flak/thor/templates/max.tt
152
- - lib/flak/thor/templates/maya.tt
153
- - lib/flak/thor/templates/maya_app.tt
154
- - lib/flak/thor/templates/maya_plugin.tt
155
- - lib/flak/thor/templates/mod.tt
156
- - lib/flak/thor/templates/nuke.tt
190
+ - lib/flak/thor/templates/maya_plugin_cpp.tt
191
+ - lib/flak/thor/templates/name_cpp.tt
192
+ - lib/flak/thor/templates/name_h.tt
157
193
  - lib/flak/thor/templates/product.mel.tt
158
194
  - lib/flak/thor/templates/product.sh.tt
159
195
  - lib/flak/thor/wizard.rb
160
196
  - lib/flak/version.rb
161
- homepage: ""
197
+ - target.jpg
198
+ homepage: ''
162
199
  licenses: []
163
-
164
200
  post_install_message:
165
201
  rdoc_options: []
166
-
167
- require_paths:
202
+ require_paths:
168
203
  - lib
169
- required_ruby_version: !ruby/object:Gem::Requirement
204
+ required_ruby_version: !ruby/object:Gem::Requirement
170
205
  none: false
171
- requirements:
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- version: "0"
175
- required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ! '>='
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
211
  none: false
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: "0"
212
+ requirements:
213
+ - - ! '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
181
216
  requirements: []
182
-
183
217
  rubyforge_project: flak
184
- rubygems_version: 1.8.15
218
+ rubygems_version: 1.8.10
185
219
  signing_key:
186
220
  specification_version: 3
187
221
  summary: build system for VFX tools
188
222
  test_files: []
189
-
data/README.textile DELETED
@@ -1,59 +0,0 @@
1
- h1. Flak
2
-
3
- h2. _Flak is Under development - there are hardly any docs or anything at the moment. Best not to use until this message goes away_
4
-
5
- h2. What is flak?
6
-
7
- Flak is a framework to help you write VFX tools. You will find it especially useful if you write tools for Maya but it also helps you write shell scripts, Nuke tools, 3delight shaders and more.
8
-
9
- Flak projects use Rake (Ruby Make), so there are common configuration files across all platforms.
10
-
11
- Flak also encourages good documentation by setting up a website skeleton based on "nanoc":http://http://nanoc.stoneship.org/. There are templates for an introduction page, release notes, installation guide, and tutorials so you can concentrate on content and let flak handle presentation at compile time. In addition there are Maya tools to generate flak documentation for nodes and commands.
12
-
13
- h2. Project structure
14
-
15
- A flak project produces a module at build time. We'll use the word 'project' for the local source, and 'module' for the compiled result.
16
-
17
- A module contains any number of tools, each of which can have at most one compiled target plus any number of scripts, icons or other support files. As such, your local flak project contains a subdirectory containing source files for each tool. In addition, the project will contain project wide-configuration files and a documentation tree.
18
-
19
- Each tool directory contains a structure where you arrange your source code. This structure is flexible, although sensible defaults will be set up at generation time.
20
-
21
- h2. Example workflow
22
-
23
- Lets say you want a project called flintstone with tools fred and wilma. You would issue the generate command for the project:
24
-
25
- flak generate project flintstone
26
-
27
- It will ask a few questions about the kind of module you want to make. Then:
28
-
29
- cd flintstone
30
- flak generate tool fred
31
- flak generate tool wilma
32
-
33
- There are shortcuts: g = generate, p = project, t = tool. So the commands above could be entered as:
34
-
35
- flak g p flintstone
36
- flak g t fred
37
- flak g t wilma
38
-
39
- At this point, you have a skeleton project set up. Then you would edit config files where necessary, write your code and documentation and finally type:
40
-
41
- rake
42
- rake doc
43
-
44
- This will build and release the module and the documentation site. Whether you release locally or in a shared location, users can install the module by in their environment by running the install script:
45
- <pre><path to module>/bin/INSTALL_FLINTSTONE</pre>
46
-
47
- There's much more coolness which we'll get into. So now you've seen how easy it is to develop using flak, lets get started.
48
-
49
- h2. Getting flak
50
-
51
- Flak is a ruby gem. So update rubygems, just to be sure, then install the gem:
52
-
53
- gem update --system
54
-
55
- gem install flak
56
-
57
-
58
-
59
-
@@ -1,316 +0,0 @@
1
-
2
-
3
- module Flak
4
-
5
- module Base
6
- # return a slightly nicer OS string than the
7
- # RUBY_PLATFORM variable
8
- def self.os
9
- case RUBY_PLATFORM
10
- when /64-linux/
11
- 'linux_64'
12
- when /i686_linux/
13
- 'linux_32'
14
- when /darwin/
15
- 'darwin'
16
- when /i386-cygwin/
17
- 'win_64'
18
- end
19
- end
20
-
21
-
22
-
23
- # merge_setting TODO - move to a Hash#merge block
24
- # if the same key is being offered and the value is an array, then we merge the arrays.
25
- # otherwise it is a string, so the new one overrides the existing one.
26
- def self.merge_setting(hash, setting_key, setting_value)
27
- if hash.has_key?(setting_key)
28
- if setting_value.kind_of?(Array)
29
- hash[setting_key.to_sym] |= setting_value
30
- else
31
- hash[(setting_key.to_sym)] = setting_value
32
- end
33
- else
34
- hash[(setting_key.to_sym)] = setting_value
35
- end
36
- hash
37
- end
38
-
39
-
40
- # given a yml settings file, resolve the configuration and OS
41
- # and return the new flattened hash
42
- def self.merge_settings(hash1,hash2)
43
- hash2.each do |k,v|
44
- merge_setting(hash1,k,v)
45
- end
46
- hash1
47
- end
48
-
49
- # given a yml settings file, resolve the configuration and OS
50
- # and return the new flattened hash
51
- def self.flatten_settings(yml,configuration, os)
52
-
53
- h = Hash.new
54
- y_hash = YAML::load_file( yml) || {}
55
- y_hash.each do |k,v|
56
-
57
- # root level settings
58
- ################
59
- if ( ! ((k =~/^os_.*/) || (k =~/^configuration_.*/)) )
60
- h =Flak::Base.merge_setting(h,k.to_sym, v)
61
- else
62
-
63
- # os specific settings
64
- ################
65
- if (k == "os_#{os}" )
66
- # puts "OS => #{os}"
67
- v.each do |k1,v1|
68
- if (k1 =~ /^configuration_.*/ )
69
- if (k1 == "configuration_#{configuration}" )
70
- v1.each do |k2,v2|
71
- h =Flak::Base.merge_setting(h,k2.to_sym, v2)
72
- end
73
- end
74
- else
75
- h=Flak::Base.merge_setting(h,k1.to_sym, v1)
76
- end
77
- end
78
- else
79
- # configuration settings (not os specific)
80
- ################
81
- if (k == "configuration_#{configuration}" )
82
- v.each do |k1,v1|
83
- h=Flak::Base.merge_setting(h,k1.to_sym, v1)
84
- end
85
- end
86
- ################
87
- end
88
-
89
- end
90
- ################
91
- end
92
- # ap h
93
- h
94
- end
95
-
96
-
97
- # method responsible for returning a flat and comprehensive
98
- # settings hash by gathering all the base config settings from
99
- # yaml and generating others programatically.
100
- # This settings hash will be used by targets, and by the
101
- # release mechanism.
102
- def self.resolve_settings( existing_settings )
103
-
104
- # bootstrap to get the configuration and the os up front because these are needed to
105
- # handle the logic to extract the right configuration and os settings from this and
106
- # all subsequent yml files
107
- # f = File.dirname(File.dirname(__FILE__)) + '/config/base.yml'
108
- # tmp = YAML::load_file( base_file )
109
-
110
- f = existing_settings[:root] + '/config/env.yml'
111
- h =Flak::Base.flatten_settings(f, existing_settings[:configuration], existing_settings[:os] )
112
- h[:root] = existing_settings[:root]
113
-
114
- h[:os] = Flak::Base.os
115
-
116
- # after this point we get values from the hash (h) wherever possible -
117
- # Why? - because h is the flattened hash - meaning that configuration and OS specific
118
- # settings will be correct. For example, product_revision may be different for debug and release
119
- # sr = File.dirname(File.dirname(File.dirname(__FILE__)))
120
- # sr = File.join("/cygdrive/c/cygwin",sr) if (Flak::Base.os == 'win_64')
121
-
122
- #h.merge!({:os => Flak::Base.os})
123
-
124
- h[:build_dir] = File.join("build", h[:product_revision] , h[:os])
125
- h[:release_root] = File.join(h[:target_release_path], h[:product_name])
126
-
127
-
128
- h[:versioned_os_release_path] = File.join( h[:release_root] , h[:product_revision] )
129
- h[:versioned_os_release_path] += "-#{h[:os]}" unless h[:agnostic]
130
-
131
- h[:doc_dirname] = "#{h[:product_revision]}-doc"
132
- h[:doc_release_root] = File.join( h[:release_root] , h[:doc_dirname] )
133
-
134
- # ap h
135
-
136
-
137
- h
138
- end
139
-
140
- # in order to make a symlink, we need to remove it
141
- # if it already exists
142
- def self.rebuild_symlink(target_file,new_file)
143
- if File.symlink?(new_file)
144
- File.unlink(new_file)
145
- end
146
- File.symlink(target_file, new_file)
147
- end
148
-
149
- # if we just copy src to dest and dest exists and is a directory,
150
- # then the src is put in the dest, as opposed to overwriting it. For
151
- # this reason, we delete dest first.
152
- def self.copy_over(src,dest)
153
- remove_file(dest, true)
154
- cp_r src, dest
155
- end
156
-
157
-
158
- # make a directory for a file
159
- def self.make_dir_for(file)
160
- FileUtils.mkdir_p file.pathmap('%d')
161
- end
162
-
163
-
164
- ####################################################################################
165
- ######################### I N S T A N C E M E T H O D S ##########################
166
- ####################################################################################
167
- def filename
168
- f = @settings[:name]
169
- f = f.ext(@settings[:target_extension] ) unless @settings[:target_extension].nil?
170
- f = File.join(@settings[:build_dir],f)
171
- end
172
-
173
-
174
- def shell_script_release_path(file)
175
- File.join(@settings[:versioned_os_release_path], 'bin', file.pathmap('%f'))
176
- end
177
-
178
-
179
- def write_erb_template(erb_file,released_file, opts={})
180
- if (!(opts[:no_force] && File.exists?(released_file) ))
181
- product_name = @settings[:product_name]
182
- template = ERB.new( File.read(erb_file) , 0, "%<>")
183
- File.open(released_file, 'w') do |f|
184
- puts "template #{erb_file} #{released_file}"
185
- f.puts(template.result(binding))
186
- f.chmod(opts[:chmod].to_i) if opts[:chmod]
187
- end
188
- end
189
- end
190
-
191
-
192
-
193
- def base_instance_tasks
194
-
195
-
196
- namespace @settings[:name].to_sym do
197
-
198
- desc "Build everything"
199
- task :build
200
-
201
- CLEAN.include( File.dirname(@settings[:build_dir]) ) unless CLEAN.include? File.dirname(@settings[:build_dir])
202
-
203
- CLOBBER.include( @settings[:versioned_os_release_path]) unless CLOBBER.include? @settings[:versioned_os_release_path]
204
-
205
-
206
- # We want to release erb files by binding them using ERB. To help identify erb files we define them in
207
- # yaml files under the key <type>_erb_files e.g. shell_erb_files or maya_script_erb_files for example
208
-
209
- ##############################################
210
- erb_keys = @settings.keys.find_all {|el| ( el.to_s =~ /^.*_erb_files$/)}
211
-
212
- erb_keys.each do |k|
213
- type = k.to_s.gsub("_erb_files", "") # shell or mel
214
- files_key = type.to_sym # :shell or :mel
215
-
216
- release_path_proc = "#{type}_release_path".to_sym
217
-
218
- files = @settings[k]
219
- unless files.nil?
220
-
221
- files.each do |f|
222
-
223
- # if a filename is a key in the settings hash
224
- # and that key is a string, replace the filename with the
225
- # value. Also, get rid of the erb extension
226
- # For example, if @settings[:product_name] is 'jtools' then
227
- # product_name.csh.erb becomes jtools.csh
228
- filename_key = f.pathmap('%f').gsub(/\..*/,'').to_sym
229
-
230
- # hack chmod for INSTALL - really must find a better way soon
231
- # write_erb_opts = (filename_key == :INSTALL) ? {:chmod => 0755} : {}
232
- write_erb_opts = {:chmod => 0755}
233
-
234
- f_resolved = f.pathmap('%f').pathmap('%n')
235
- if @settings.has_key?(filename_key)
236
- f_resolved = "#{@settings[filename_key]}#{f_resolved.pathmap('%x')}"
237
- end
238
-
239
- released_file = self.send release_path_proc, f_resolved
240
-
241
-
242
- file released_file => f do
243
-
244
- Flak::Base.make_dir_for(released_file)
245
- write_erb_template(f,released_file,write_erb_opts)
246
- end
247
-
248
- desc "bind and release ERB #{released_file.pathmap('%f')}"
249
- task released_file.pathmap('%f') => released_file
250
-
251
- task :release => released_file.pathmap('%f')
252
- end
253
- end
254
- end
255
- ##############################################
256
-
257
-
258
-
259
- # copy_keys is an array of keys representing file types that should be copied
260
- # for example maya_script_copy_files
261
- # If so, there should be a proc called maya_script_release_path which is responsible for generating the release path
262
- # this smells a bit - not sure if it can be fixed - we will see
263
- ##############################################
264
- copy_keys = @settings.keys.find_all {|el| ( el.to_s =~ /^.*_copy_files$/)}
265
-
266
- copy_keys.each do |k|
267
- type = k.to_s.gsub("_copy_files", "")
268
-
269
- release_path_proc = "#{type}_release_path".to_sym
270
- files = @settings[k]
271
-
272
- unless files.nil?
273
-
274
- files.each do |f|
275
- released_file = self.send release_path_proc, f
276
- file released_file => f do
277
- Flak::Base.make_dir_for(released_file)
278
- sh "cp -r #{f} #{released_file}"
279
- File.chmod 0755, released_file if (type == 'shell' )
280
- end
281
- task :release => released_file
282
- end
283
- end
284
- end
285
- ##############################################
286
-
287
- desc "See resolved configuration settings for #{@settings[:name].to_sym}"
288
- task :inspect do
289
- ap @settings
290
- end
291
-
292
- desc "Release #{@settings[:name].to_sym}"
293
- task :release # => [:rebuild_label_link ]
294
-
295
- end # namespace name
296
-
297
- task :release => "#{@settings[:name].to_sym}:release"
298
-
299
- task :default => ["release"]
300
-
301
-
302
-
303
-
304
-
305
- task :inspect do
306
- ap @settings
307
- end
308
-
309
- end
310
-
311
-
312
- end
313
-
314
-
315
-
316
- end