flak 0.0.4 → 0.0.5
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/.gitignore +1 -0
- data/.yardoc/checksums +28 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/.yardopts +1 -0
- data/Architecture.md +152 -0
- data/Documenting.md +2 -0
- data/MayaModules.md +2 -0
- data/README.md +173 -0
- data/flak.gemspec +6 -3
- data/lib/core_ext/hash.rb +82 -0
- data/lib/core_ext/string.rb +41 -0
- data/lib/flak.rb +20 -12
- data/lib/flak/rake/errors.rb +28 -0
- data/lib/flak/rake/file_actions.rb +70 -0
- data/lib/flak/rake/os.rb +18 -0
- data/lib/flak/rake/target.rb +47 -69
- data/lib/flak/rake/templates/cpp.rb +211 -0
- data/lib/flak/rake/templates/delight.rb +168 -0
- data/lib/flak/rake/templates/doc.rb +106 -0
- data/lib/flak/rake/templates/environment.rb +189 -0
- data/lib/flak/rake/templates/gl.rb +20 -0
- data/lib/flak/rake/templates/mac.rb +29 -0
- data/lib/flak/rake/templates/max.rb +22 -0
- data/lib/flak/rake/templates/maya.rb +172 -0
- data/lib/flak/rake/templates/maya_app.rb +97 -0
- data/lib/flak/rake/templates/maya_plugin.rb +93 -0
- data/lib/flak/rake/templates/merge_engine.rb +45 -0
- data/lib/flak/rake/templates/nuke.rb +60 -0
- data/lib/flak/rake/templates/release.rb +101 -0
- data/lib/flak/rake/templates/shell.rb +54 -0
- data/lib/flak/thor/cli.rb +5 -0
- data/lib/flak/thor/generate.rb +88 -144
- data/lib/flak/thor/target_file.rb +36 -17
- data/lib/flak/thor/templates/INSTALL.tt +3 -3
- data/lib/flak/thor/templates/Rakefile.tt +4 -2
- data/lib/flak/thor/templates/{cpp.tt → config/cpp.yml.tt} +6 -8
- data/lib/flak/thor/templates/{delight.tt → config/delight.yml.tt} +1 -1
- data/lib/flak/thor/templates/{doc.tt → config/doc.yml.tt} +0 -0
- data/lib/flak/thor/templates/{env.tt → config/environment.yml.tt} +6 -7
- data/lib/flak/thor/templates/{gl.tt → config/gl.yml.tt} +0 -0
- data/lib/flak/thor/templates/{mac.tt → config/mac.yml.tt} +0 -0
- data/lib/flak/thor/templates/{max.tt → config/max.yml.tt} +0 -0
- data/lib/flak/thor/templates/{maya.tt → config/maya.yml.tt} +9 -1
- data/lib/flak/thor/templates/{maya_app.tt → config/maya_app.yml.tt} +0 -2
- data/lib/flak/thor/templates/{maya_plugin.tt → config/maya_plugin.yml.tt} +0 -2
- data/lib/flak/thor/templates/config/nuke.yml.tt +3 -0
- data/lib/flak/thor/templates/config/release.yml.tt +3 -0
- data/lib/flak/thor/templates/config/shell.yml.tt +1 -0
- data/lib/flak/thor/templates/doc/content/install_guide.txt.tt +71 -25
- data/lib/flak/thor/templates/maya_plugin_cpp.tt +37 -0
- data/lib/flak/thor/templates/name_cpp.tt +6 -0
- data/lib/flak/thor/templates/name_h.tt +34 -0
- data/lib/flak/thor/templates/product.sh.tt +2 -2
- data/lib/flak/thor/wizard.rb +28 -15
- data/lib/flak/version.rb +1 -1
- data/target.jpg +0 -0
- metadata +127 -94
- data/README.textile +0 -59
- data/lib/flak/rake/base.rb +0 -316
- data/lib/flak/rake/cpp.rb +0 -139
- data/lib/flak/rake/delight.rb +0 -121
- data/lib/flak/rake/doc.rb +0 -69
- data/lib/flak/rake/gl.rb +0 -10
- data/lib/flak/rake/mac.rb +0 -23
- data/lib/flak/rake/max.rb +0 -29
- data/lib/flak/rake/maya.rb +0 -142
- data/lib/flak/rake/maya_app.rb +0 -45
- data/lib/flak/rake/maya_plugin.rb +0 -47
- data/lib/flak/rake/mod.rb +0 -46
- data/lib/flak/rake/nuke.rb +0 -29
- data/lib/flak/thor/templates/mod.tt +0 -0
- data/lib/flak/thor/templates/nuke.tt +0 -2
data/lib/core_ext/string.rb
CHANGED
@@ -1,5 +1,46 @@
|
|
1
1
|
class String
|
2
|
+
|
3
|
+
# Find words, capitalize and join
|
4
|
+
# @return [String] camel cased string
|
2
5
|
def camelize
|
3
6
|
self.split(/[^a-z0-9]/i).map{|w| w.capitalize}.join
|
4
7
|
end
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
# Find words breaks and insert underscores
|
12
|
+
# @return [String] underscorized string
|
13
|
+
def underscoreize
|
14
|
+
self.gsub(/::/, '/').
|
15
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
16
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
17
|
+
tr("-", "_").
|
18
|
+
downcase
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
# Remove the erb extension if there is one
|
25
|
+
# @return [String] string with no erb extension
|
26
|
+
def no_erb
|
27
|
+
self.sub(/\.erb$/,'')
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
# Replace dollar-curly braces, with
|
32
|
+
# the value of environment variable
|
33
|
+
# @return [String] string with all environment variables replaced
|
34
|
+
def substitute_env_vars
|
35
|
+
str = String.new(self)
|
36
|
+
str.scan(/\$\{([A-Z][A-Z,0-9,_]*)\}/).uniq.each do |m|
|
37
|
+
begin
|
38
|
+
str.gsub!("${#{m[0]}}", ENV[m[0]])
|
39
|
+
rescue
|
40
|
+
$stderr.puts "problem with enviroment variable #{m[0]}."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
str
|
44
|
+
end
|
45
|
+
|
5
46
|
end
|
data/lib/flak.rb
CHANGED
@@ -10,20 +10,28 @@ require "thor/group"
|
|
10
10
|
require "ap"
|
11
11
|
require 'nanoc'
|
12
12
|
require 'core_ext/string'
|
13
|
+
require 'core_ext/hash'
|
13
14
|
|
14
|
-
|
15
|
-
require 'flak/rake/
|
16
|
-
require 'flak/rake/
|
17
|
-
require 'flak/rake/
|
18
|
-
require 'flak/rake/mac'
|
19
|
-
require 'flak/rake/max'
|
20
|
-
require 'flak/rake/maya'
|
21
|
-
require 'flak/rake/maya_app'
|
22
|
-
require 'flak/rake/maya_plugin'
|
23
|
-
require 'flak/rake/nuke'
|
15
|
+
|
16
|
+
require 'flak/rake/file_actions'
|
17
|
+
require 'flak/rake/os'
|
18
|
+
require 'flak/rake/errors'
|
24
19
|
require 'flak/rake/target'
|
25
|
-
|
26
|
-
require 'flak/rake/
|
20
|
+
|
21
|
+
require 'flak/rake/templates/merge_engine'
|
22
|
+
|
23
|
+
require 'flak/rake/templates/environment'
|
24
|
+
require 'flak/rake/templates/maya'
|
25
|
+
require 'flak/rake/templates/nuke'
|
26
|
+
require 'flak/rake/templates/release'
|
27
|
+
require 'flak/rake/templates/doc'
|
28
|
+
require 'flak/rake/templates/maya_plugin'
|
29
|
+
require 'flak/rake/templates/maya_app'
|
30
|
+
require 'flak/rake/templates/shell'
|
31
|
+
require 'flak/rake/templates/gl'
|
32
|
+
require 'flak/rake/templates/delight'
|
33
|
+
require 'flak/rake/templates/cpp'
|
34
|
+
|
27
35
|
|
28
36
|
require 'flak/version'
|
29
37
|
require 'flak/thor/wizard'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Flak
|
4
|
+
|
5
|
+
# Module that contains flak error functions
|
6
|
+
module Errors
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# Assert that a variable exists and has the correct type.
|
11
|
+
# Prints a bright red informative message if not.
|
12
|
+
# @param var [String] the variable's name
|
13
|
+
# @param type [String] the variable's type
|
14
|
+
# @param bind [Binding] the binding for the calling object so that the variable can be evaluated.
|
15
|
+
# @param file [String] the filename where the call for this assertion came from.
|
16
|
+
# @return [String] formatted error message.
|
17
|
+
def self.assert(var, type, bind, file)
|
18
|
+
param = eval(var,bind)
|
19
|
+
ap "#{var} is not a #{type}. It is a #{param.class}. (#{File.basename(file)})" , :color => {:string => :red} unless param.class == Kernel.const_get(type)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Flak
|
2
|
+
|
3
|
+
module FileActions
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
# in order to make a symlink, we need to remove it
|
9
|
+
# if it already exists
|
10
|
+
|
11
|
+
|
12
|
+
# Create a symlink.
|
13
|
+
# Remove it if it already exists.
|
14
|
+
# @param target_file [String] the file to point the new file at.
|
15
|
+
# @param new_file [String] the new file.
|
16
|
+
def rebuild_symlink(target_file,new_file)
|
17
|
+
if File.symlink?(new_file)
|
18
|
+
File.unlink(new_file)
|
19
|
+
end
|
20
|
+
File.symlink(target_file, new_file)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
# Remove a file and copy a new file over.
|
27
|
+
# If we just copy source to destination and destination exists and is a directory,
|
28
|
+
# then the src is put in the destination, as opposed to overwriting it. For
|
29
|
+
# this reason, we delete destination first.
|
30
|
+
# @param source [String] the source file.
|
31
|
+
# @param destination [String] the destination file.
|
32
|
+
def remove_and_copy(source,destination)
|
33
|
+
remove_file(destination, true)
|
34
|
+
cp_r source, destination
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
# Make a directory to contain a file.
|
41
|
+
# Create directories recursively if necessary.
|
42
|
+
# @param file [String] the file that needs a directory.
|
43
|
+
def make_directory_for(file)
|
44
|
+
FileUtils.mkdir_p file.pathmap('%d')
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
# Create a destination file by filtering a source file through ERB.
|
50
|
+
# @param erb_file [String] the file to be filtered.
|
51
|
+
# @param released_file [String] the result filename.
|
52
|
+
# @param opts [Hash] the options.
|
53
|
+
# @option opts :chmod [String] The file mode.
|
54
|
+
def write_erb_template(erb_file,released_file, opts={})
|
55
|
+
if (!(opts[:no_force] && File.exists?(released_file) ))
|
56
|
+
template = ERB.new( File.read(erb_file) , 0, "%<>")
|
57
|
+
File.open(released_file, 'w') do |f|
|
58
|
+
puts "template #{erb_file} #{released_file}"
|
59
|
+
f.puts(template.result(binding))
|
60
|
+
f.chmod(opts[:chmod].to_i) if opts[:chmod]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
end
|
data/lib/flak/rake/os.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Flak
|
2
|
+
# Provide a slightly nicer OS string than the
|
3
|
+
# RUBY_PLATFORM variable
|
4
|
+
# @return [String] Either 'linux_64', 'linux_32', 'darwin', or 'win_64'
|
5
|
+
def self.os
|
6
|
+
case RUBY_PLATFORM
|
7
|
+
when /64-linux/
|
8
|
+
'linux_64'
|
9
|
+
when /i686_linux/
|
10
|
+
'linux_32'
|
11
|
+
when /darwin/
|
12
|
+
'darwin'
|
13
|
+
when /i386-cygwin/
|
14
|
+
'win_64'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/lib/flak/rake/target.rb
CHANGED
@@ -1,110 +1,88 @@
|
|
1
1
|
# This is where we prepare a target.
|
2
|
-
# The target will "
|
2
|
+
# The target will "get" settings and methods from modules specified in the target.yml file
|
3
|
+
|
3
4
|
module Flak
|
4
5
|
|
5
6
|
class Target
|
6
7
|
|
8
|
+
include Flak::FileActions
|
9
|
+
|
7
10
|
attr_accessor :settings
|
8
11
|
|
9
|
-
|
12
|
+
# Constructs a target object.
|
13
|
+
#
|
14
|
+
# @param root [String] the directory containing the Rakefile.
|
15
|
+
# @param target_file [String] the root-relative file that specifies how to build this target. Either project.yml or tool.yml
|
16
|
+
def initialize(root, target_file)
|
10
17
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
tmp_env = YAML::load_file( root + '/config/environment.yml' )
|
19
|
+
tmp_goal = YAML::load_file( target_file )
|
20
|
+
|
21
|
+
@settings = Hash.new
|
22
|
+
@settings[:configuration] = tmp_env['configuration']
|
23
|
+
@settings[:templates] = tmp_goal['templates']
|
24
|
+
@settings[:os] = Flak.os
|
15
25
|
@settings[:root] = root
|
26
|
+
@settings[:target_file] = target_file
|
27
|
+
@settings[:full_target_file] = File.join(@settings[:root], target_file )
|
28
|
+
@settings[:relative_goal_root] = File.dirname(target_file)
|
29
|
+
@settings[:goal_root] = File.dirname( @settings[:full_target_file] )
|
30
|
+
@settings[:templates] = (["environment"] | @settings[:templates])
|
16
31
|
|
17
|
-
|
18
|
-
@settings[:configuration] = tmp['configuration']
|
19
|
-
@settings[:os] = Flak::Base.os
|
20
|
-
|
21
|
-
# settings goes in as config and os, and comes back fully resolved
|
22
|
-
|
23
|
-
h = Hash.new
|
24
|
-
|
25
|
-
@settings = Flak::Base.resolve_settings(@settings)
|
32
|
+
end
|
26
33
|
|
27
34
|
|
28
|
-
|
29
|
-
|
30
|
-
|
35
|
+
# After the Target has been constructed, generate settings and tasks.
|
36
|
+
def build
|
37
|
+
generate_settings
|
38
|
+
generate_tasks
|
39
|
+
end
|
31
40
|
|
32
|
-
@settings[:target_root] = File.join(@settings[:root], @settings[:target_dir] )
|
33
41
|
|
34
|
-
|
35
|
-
|
36
|
-
template_array = h['templates'] || []
|
42
|
+
# Extend this Target with settings and methods from templates declared in the target file
|
43
|
+
def generate_settings
|
37
44
|
|
38
|
-
|
39
|
-
|
40
|
-
|
45
|
+
@settings[:templates].each do |template_name|
|
46
|
+
mod = Flak::Template.const_get("#{template_name.camelize}")
|
47
|
+
mod = mod.const_get("Settings")
|
48
|
+
raise TypeError, "#{mod.inspect} must be a Module" unless mod.kind_of? Module
|
49
|
+
self.extend( mod )
|
41
50
|
end
|
42
51
|
|
43
|
-
|
44
|
-
@settings =
|
45
|
-
|
52
|
+
yml = Flak::Template::MergeEngine.flatten_yaml_file(@settings, @settings[:target_file])
|
53
|
+
@settings = @settings.flak_merge(yml)
|
46
54
|
expand_filelists
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
def self.resolve_settings(existing_settings)
|
52
|
-
Flak::Base.flatten_settings(existing_settings[:target_file], existing_settings[:configuration],existing_settings[:os] )
|
55
|
+
|
53
56
|
end
|
54
57
|
|
55
58
|
|
59
|
+
# Extend this Target with tasks from templates declared in the target file
|
60
|
+
def generate_tasks
|
56
61
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
# See the merge settings method in base for details of the merging strategy
|
62
|
-
def integrate_templates(template_array)
|
63
|
-
template_array.each do |template_name|
|
64
|
-
mod = Flak.const_get(template_name.split('_').collect {|w| w.capitalize}.join())
|
65
|
-
unless mod.kind_of? Module
|
66
|
-
raise TypeError, "#{mod.inspect} must be a Module"
|
67
|
-
end
|
62
|
+
@settings[:templates].each do |template_name|
|
63
|
+
mod = Flak::Template.const_get("#{template_name.camelize}")
|
64
|
+
mod = mod.const_get("Tasks")
|
65
|
+
raise TypeError, "#{mod.inspect} must be a Module" unless mod.kind_of? Module
|
68
66
|
self.extend( mod )
|
69
|
-
@settings = Flak::Base.merge_settings(@settings, mod.resolve_settings(@settings))
|
70
67
|
end
|
71
|
-
end
|
72
68
|
|
73
|
-
|
74
|
-
|
75
|
-
# run all task synthesis methods that have been mixed in to this instance
|
76
|
-
# the convention is to name these tasks <filename>_instance_tasks in the module files
|
77
|
-
# in which they are defined.
|
78
|
-
# only make tasks if the target has a name - a target with no has probably been limited
|
79
|
-
# to only generate tasks for a specific OS (or configuration)
|
80
|
-
def instance_tasks
|
81
|
-
unless (@settings[:name].nil?)
|
82
|
-
self.public_methods.grep(/_instance_tasks/).each do |t|
|
83
|
-
self.send t
|
84
|
-
end
|
85
|
-
end
|
86
69
|
end
|
87
70
|
|
88
71
|
|
89
72
|
|
90
73
|
private
|
91
74
|
|
92
|
-
#
|
93
|
-
# and path arrays. Its important that when specifying files in
|
94
|
-
#the yaml, the user sets the key names to be "<something>_files"
|
95
|
-
# or "<something>_paths".
|
96
|
-
# If the path given is relative, we prepend the path to
|
97
|
-
# the target file (target_dir) so that Rake has somewhere to work from
|
75
|
+
# Expand FileList objects into arrays so that calling inspect on a target gives a more readable output.
|
98
76
|
def expand_filelists
|
99
77
|
@settings.each do |k,v|
|
100
78
|
if k.to_s =~ /_files$|_paths$/
|
101
79
|
unless v.nil?
|
102
|
-
v = v.collect { |el| (el[0] == '/') || (el[1] ==":") ? el : File.join(@settings[:
|
103
|
-
@settings[(k.to_sym)] = k.to_s =~ /_files$/ ? FileList[v] : v
|
80
|
+
v = v.collect { |el| (el[0] == '/') || (el[1] ==":") ? el : File.join(@settings[:relative_goal_root],el) }
|
81
|
+
@settings[(k.to_sym)] = k.to_s =~ /_files$/ ? FileList[v].to_a : v
|
104
82
|
end
|
105
83
|
end
|
106
84
|
end
|
107
85
|
end
|
108
|
-
|
86
|
+
|
109
87
|
end
|
110
88
|
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
module Flak::Template
|
2
|
+
module Cpp
|
3
|
+
|
4
|
+
module Settings
|
5
|
+
|
6
|
+
extend Flak::Template::MergeEngine
|
7
|
+
|
8
|
+
def self.extended target
|
9
|
+
infuse target
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
# these methods will become instance methods of the target
|
16
|
+
# and as such will have access to te @settings instance variable
|
17
|
+
###################################################
|
18
|
+
def build_filename
|
19
|
+
bind = binding()
|
20
|
+
Flak::Errors.assert("@settings[:build_directory]", "String", bind,__FILE__)
|
21
|
+
Flak::Errors.assert("@settings[:name]", "String", bind,__FILE__)
|
22
|
+
Flak::Errors.assert("@settings[:target_extension]", "String", bind,__FILE__)
|
23
|
+
File.join(@settings[:build_directory],'products',@settings[:name].ext(@settings[:target_extension]))
|
24
|
+
end
|
25
|
+
|
26
|
+
def release_filename
|
27
|
+
bind = binding()
|
28
|
+
Flak::Errors.assert("@settings[:path_to_revision]", "String", bind,__FILE__)
|
29
|
+
File.join( @settings[:path_to_revision], 'bin', build_filename.pathmap('%f'))
|
30
|
+
end
|
31
|
+
|
32
|
+
# generate path to object file from source: e.g. /hq/dev/jtools/build/2009.3/darwin/debug/animal/sensor.o"
|
33
|
+
def object_file(source)
|
34
|
+
bind = binding()
|
35
|
+
Flak::Errors.assert("@settings[:build_directory]", "String", bind,__FILE__)
|
36
|
+
Flak::Errors.assert("@settings[:object_extension]", "String", bind,__FILE__)
|
37
|
+
File.join(@settings[:build_directory], source.gsub("/src/","/").ext( @settings[:object_extension] ))
|
38
|
+
end
|
39
|
+
|
40
|
+
# collect all object files for this target
|
41
|
+
def object_files
|
42
|
+
@settings[:source_files].collect { |s| object_file(s) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def c_compile_cmd(source)
|
46
|
+
bind = binding()
|
47
|
+
Flak::Errors.assert("@settings[:compiler]", "String", bind,__FILE__)
|
48
|
+
Flak::Errors.assert("@settings[:object_flag]", "String", bind,__FILE__)
|
49
|
+
Flak::Errors.assert("@settings[:include_flag]", "String", bind,__FILE__)
|
50
|
+
|
51
|
+
compiler = "\"#{@settings[:compiler]}\""
|
52
|
+
object = "#{@settings[:object_flag]}\"#{object_file(source)}\""
|
53
|
+
source = "\"#{source}\""
|
54
|
+
inc_path = (@settings[:source_files].collect {|f| f.pathmap('%d')}.uniq | ( @settings[:include_paths] || [] )).collect { |el| "#{@settings[:include_flag]}\"#{el.to_s}\"" }.join(" ")
|
55
|
+
includes = ( @settings[:includes] || [] ).collect { |el| "-include \"#{el.to_s}\"" }.join(" ")
|
56
|
+
compiler_options = (@settings[:compiler_options] || [] ).collect { |el| el.to_s }.join(" ")
|
57
|
+
# puts "*" * 80
|
58
|
+
# puts @settings[:compiler_options]
|
59
|
+
# puts "*" * 80
|
60
|
+
"#{compiler} #{compiler_options} #{source} #{object} #{inc_path} #{includes}"
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def c_link_cmd
|
65
|
+
bind = binding()
|
66
|
+
Flak::Errors.assert("@settings[:linker]", "String", bind,__FILE__)
|
67
|
+
Flak::Errors.assert("@settings[:lib_flag]", "String", bind,__FILE__)
|
68
|
+
Flak::Errors.assert("@settings[:lib_ext]", "String", bind,__FILE__)
|
69
|
+
Flak::Errors.assert("@settings[:libpath_flag]", "String", bind,__FILE__)
|
70
|
+
Flak::Errors.assert("@settings[:framework_flag]", "String", bind,__FILE__)
|
71
|
+
Flak::Errors.assert("@settings[:outputfile_flag]", "String", bind,__FILE__)
|
72
|
+
|
73
|
+
|
74
|
+
linker = "\"#{@settings[:linker]}\""
|
75
|
+
objects = object_files.collect { |el| "\"#{el.to_s}\"" }.join(" ")
|
76
|
+
# libstr = ((@settings[:libs] || []).collect { |el| "-l#{el.to_s}" } | (@settings[:static_libs] || []).collect { |el| "#{@settings[:static_prefix_flag]} -l#{el.to_s}" }).join(" ")
|
77
|
+
libstr = (@settings[:libs] || []).collect { |el| "#{@settings[:lib_flag]}#{el.to_s}#{@settings[:lib_ext]}" }.join(" ")
|
78
|
+
libpathstr = (@settings[:lib_paths] || []).collect { |el| "#{@settings[:libpath_flag]}\"#{el.to_s}\"" }.join(" ")
|
79
|
+
linkflagstr = ( @settings[:linker_options] || [] ).collect { |el| el.to_s }.join(" ")
|
80
|
+
dso_flagstr = (@settings[:dso_options] || [] ).collect { |el| el.to_s }.join(" ")
|
81
|
+
fwrk = (@settings[:frameworks] || [] ).collect { |el| "#{@settings[:framework_flag]} #{el.to_s}" }.join(" ")
|
82
|
+
"#{linker} #{dso_flagstr} #{linkflagstr} #{libpathstr} #{libstr} #{fwrk} #{@settings[:outputfile_flag]}\"#{build_filename}\" #{objects}"
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def c_clean_cmd
|
87
|
+
objects = object_files.collect { |el| "\"#{el.to_s}\"" }
|
88
|
+
"rm -f \"#{build_filename}\" #{objects}"
|
89
|
+
end
|
90
|
+
###################################################
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
module Tasks
|
102
|
+
def self.extended target
|
103
|
+
task_factory target
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
def self.task_factory target
|
108
|
+
settings = target.settings
|
109
|
+
|
110
|
+
|
111
|
+
files = settings[:source_files]
|
112
|
+
unless files.nil?
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
# file tasks to compile objects from sources
|
118
|
+
# make sure the object file depends on the
|
119
|
+
# source and header if it exists
|
120
|
+
######################################################
|
121
|
+
files.each do |f|
|
122
|
+
object = target.object_file(f)
|
123
|
+
file object => f do |t|
|
124
|
+
target.make_directory_for(object)
|
125
|
+
sh target.c_compile_cmd(f)
|
126
|
+
end
|
127
|
+
header = f.ext('h')
|
128
|
+
file object => header if File.exists?(header)
|
129
|
+
end
|
130
|
+
######################################################
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
# file tasks to link targets
|
137
|
+
######################################################
|
138
|
+
objects = target.object_files
|
139
|
+
build_file = target.build_filename
|
140
|
+
file build_file => objects do
|
141
|
+
target.make_directory_for(build_file)
|
142
|
+
sh target.c_link_cmd
|
143
|
+
end
|
144
|
+
|
145
|
+
namespace settings[:name].to_sym do
|
146
|
+
desc "build the #{settings[:name].to_sym} binary"
|
147
|
+
task :build => build_file # add named target
|
148
|
+
end
|
149
|
+
task :build => "#{settings[:name].to_sym}:build"
|
150
|
+
######################################################
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
# tasks to clean the build
|
159
|
+
######################################################
|
160
|
+
namespace settings[:name].to_sym do
|
161
|
+
desc "clean the #{settings[:name].to_sym} build files"
|
162
|
+
task :clean do
|
163
|
+
sh target.c_clean_cmd
|
164
|
+
end
|
165
|
+
end
|
166
|
+
task :clean => "#{settings[:name].to_sym}:clean"
|
167
|
+
######################################################
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
# plugins and executables release tasks
|
176
|
+
######################################################
|
177
|
+
release_binary = target.release_filename
|
178
|
+
build_file = target.build_filename
|
179
|
+
file release_binary => build_file do
|
180
|
+
target.make_directory_for(release_binary)
|
181
|
+
rm_r release_binary if File.exists?(release_binary)
|
182
|
+
cp build_file, release_binary
|
183
|
+
File.chmod 0755, release_binary
|
184
|
+
end
|
185
|
+
######################################################
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
# add the release_binary file task to the tool's release task
|
192
|
+
# and add the tool's release task to the release task
|
193
|
+
# in the global namespace
|
194
|
+
######################################################
|
195
|
+
namespace settings[:name].to_sym do
|
196
|
+
task :release => release_binary
|
197
|
+
end
|
198
|
+
|
199
|
+
task :release => "#{settings[:name].to_sym}:release"
|
200
|
+
######################################################
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|