build-tool 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +3 -0
- data/History.txt +7 -0
- data/Manifest.txt +51 -0
- data/PostInstall.txt +3 -0
- data/README.rdoc +55 -0
- data/Rakefile +30 -0
- data/TODO +2 -0
- data/bin/kde-build.rb +21 -0
- data/config/website.yml +2 -0
- data/config/website.yml.sample +2 -0
- data/lib/kde-build.rb +18 -0
- data/lib/kde-build/application.rb +258 -0
- data/lib/kde-build/build_system.rb +26 -0
- data/lib/kde-build/build_system/autoconf.rb +109 -0
- data/lib/kde-build/build_system/base.rb +132 -0
- data/lib/kde-build/build_system/cmake.rb +82 -0
- data/lib/kde-build/build_system/qtcopy.rb +125 -0
- data/lib/kde-build/command.rb +30 -0
- data/lib/kde-build/command/build.rb +119 -0
- data/lib/kde-build/command/fetch.rb +28 -0
- data/lib/kde-build/command/help.rb +71 -0
- data/lib/kde-build/command/info.rb +42 -0
- data/lib/kde-build/command/version.rb +43 -0
- data/lib/kde-build/configuration.rb +186 -0
- data/lib/kde-build/exception.rb +6 -0
- data/lib/kde-build/metaaid.rb +18 -0
- data/lib/kde-build/module.rb +203 -0
- data/lib/kde-build/module_configuration.rb +107 -0
- data/lib/kde-build/moduleregistry.rb +85 -0
- data/lib/kde-build/subprocess.rb +82 -0
- data/lib/kde-build/tools/ctags.rb +34 -0
- data/lib/kde-build/tools/logging.rb +49 -0
- data/lib/kde-build/tools/make.rb +58 -0
- data/lib/kde-build/tools/ssh.rb +47 -0
- data/lib/kde-build/vcs.rb +26 -0
- data/lib/kde-build/vcs/base.rb +81 -0
- data/lib/kde-build/vcs/git-svn.rb +133 -0
- data/lib/kde-build/vcs/git.rb +96 -0
- data/lib/kde-build/vcs/svn.rb +105 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +71 -0
- data/test.yaml.tmpl +552 -0
- data/test/test_helper.rb +12 -0
- data/test/test_kde-build.rb +11 -0
- data/test/test_vcs_svn.rb +44 -0
- data/website/index.html +84 -0
- data/website/index.txt +59 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +159 -0
- data/website/template.html.erb +50 -0
- metadata +171 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require 'cmdparse'
|
4
|
+
|
5
|
+
module BuildTool
|
6
|
+
|
7
|
+
|
8
|
+
class Command < CmdParse::Command
|
9
|
+
|
10
|
+
|
11
|
+
def show_help
|
12
|
+
puts "#{name}: #{short_desc}"
|
13
|
+
puts description if description
|
14
|
+
if has_commands?
|
15
|
+
list_commands
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def complete( args )
|
20
|
+
if options.instance
|
21
|
+
puts options.instance.complete( :long, "-v", true )
|
22
|
+
return ["#{name} Yeah"]
|
23
|
+
else
|
24
|
+
return []
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'kde-build/command'
|
5
|
+
require 'kde-build/command/help'
|
6
|
+
|
7
|
+
module BuildTool
|
8
|
+
|
9
|
+
|
10
|
+
class BuildCommand < Command
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super( 'build', false )
|
14
|
+
self.short_desc = "build [options] [:package|module|path/]..."
|
15
|
+
self.description = "fetch, rebase, build and install the specified modules."
|
16
|
+
@update = true
|
17
|
+
@configure = false
|
18
|
+
@reconfigure = false
|
19
|
+
@install = true
|
20
|
+
@from_scratch = false
|
21
|
+
self.options = CmdParse::OptionParserWrapper.new do |opt|
|
22
|
+
opt.separator "Global Options"
|
23
|
+
opt.on( "--no-update", "Do not update from the repository" ) { |t|
|
24
|
+
@update = false
|
25
|
+
}
|
26
|
+
opt.on( "--configure", "Run the configuration step again" ) { |t|
|
27
|
+
@configure = true
|
28
|
+
}
|
29
|
+
opt.on( "--reconfigure", "Remove old configuration then run configuration again" ) { |t|
|
30
|
+
@reconfigure = true
|
31
|
+
}
|
32
|
+
opt.on( "--no-install", "Do not install" ) { |t|
|
33
|
+
@install = false
|
34
|
+
}
|
35
|
+
opt.on( "--from-scratch", "Remove build dir" ) { |t|
|
36
|
+
@from_scratch = true
|
37
|
+
}
|
38
|
+
opt.on( "--help", "Show this help" ) { |t|
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def prepare_execution( mod )
|
44
|
+
skip = false
|
45
|
+
if @update
|
46
|
+
mod.activate_ssh_key
|
47
|
+
else
|
48
|
+
if !mod.checkedout?
|
49
|
+
$log.error("Module #{mod.name} is not checkedout and will be skipped!")
|
50
|
+
skip = true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
!skip
|
54
|
+
end
|
55
|
+
|
56
|
+
def execute( args )
|
57
|
+
if args.length == 0
|
58
|
+
show_help
|
59
|
+
return
|
60
|
+
end
|
61
|
+
|
62
|
+
real_modules = []
|
63
|
+
|
64
|
+
ModuleRegistry.get_modules( args ) do |mod|
|
65
|
+
if prepare_execution( mod )
|
66
|
+
real_modules.push( mod )
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
real_modules.each do |mod|
|
71
|
+
begin
|
72
|
+
$log.info( "###############################################################" )
|
73
|
+
$log.info( "### Building module #{mod.name}" )
|
74
|
+
$log.info( "###############################################################" )
|
75
|
+
|
76
|
+
if @from_scratch
|
77
|
+
mod.remove_build_directory
|
78
|
+
end
|
79
|
+
|
80
|
+
if @update
|
81
|
+
|
82
|
+
if mod.checkedout?
|
83
|
+
mod.fetch
|
84
|
+
mod.rebase
|
85
|
+
else
|
86
|
+
mod.init
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
if @reconfigure
|
92
|
+
mod.reconfigure( true )
|
93
|
+
|
94
|
+
elsif @configure
|
95
|
+
if mod.configured?
|
96
|
+
mod.reconfigure
|
97
|
+
else
|
98
|
+
mod.configure
|
99
|
+
end
|
100
|
+
|
101
|
+
elsif !mod.configured?
|
102
|
+
mod.configure
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
mod.build( @install )
|
107
|
+
|
108
|
+
rescue Exception => e
|
109
|
+
$log.info("error: #{e.class}: #{e.message}")
|
110
|
+
puts e.backtrace if $verbose
|
111
|
+
end
|
112
|
+
$log.info("")
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require 'kde-build/command'
|
4
|
+
|
5
|
+
module BuildTool
|
6
|
+
|
7
|
+
class FetchCommand < Command
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super( 'fetch', false )
|
11
|
+
self.short_desc = "Fetch"
|
12
|
+
self.description = "Fetch long"
|
13
|
+
self.options = CmdParse::OptionParserWrapper.new do |opt|
|
14
|
+
opt.on( "--verbose", "Verbose output" ) { |t|
|
15
|
+
$verbose = true
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def execute( args )
|
22
|
+
puts "do: #{args}"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require 'kde-build/command'
|
4
|
+
|
5
|
+
module BuildTool
|
6
|
+
|
7
|
+
|
8
|
+
# The default help command. It adds the options "-h" and "--help" to the global options of the
|
9
|
+
# associated +CommandParser+. When the command is specified on the command line, it can show the
|
10
|
+
# main help or individual command help.
|
11
|
+
class HelpCommand < Command
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super( 'help', false )
|
15
|
+
self.short_desc = 'Provide help for individual commands'
|
16
|
+
self.description = 'This command prints the program help if no arguments are given. ' \
|
17
|
+
'If one or more command names are given as arguments, these arguments are interpreted ' \
|
18
|
+
'as a hierachy of commands and the help for the right most command is show.'
|
19
|
+
end
|
20
|
+
|
21
|
+
def init
|
22
|
+
case commandparser.main_command.options
|
23
|
+
when CmdParse::OptionParserWrapper
|
24
|
+
commandparser.main_command.options.instance do |opt|
|
25
|
+
opt.on_tail( "-h", "--help", "Show help" ) do
|
26
|
+
execute( [] )
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def usage
|
33
|
+
"Usage: #{commandparser.program_name} help [COMMAND SUBCOMMAND ...]"
|
34
|
+
end
|
35
|
+
|
36
|
+
def execute( args )
|
37
|
+
if args.length > 0
|
38
|
+
cmd = commandparser.main_command
|
39
|
+
arg = args.shift
|
40
|
+
while !arg.nil? && cmd.commands[ arg ]
|
41
|
+
cmd = cmd.commands[arg]
|
42
|
+
arg = args.shift
|
43
|
+
end
|
44
|
+
if arg.nil?
|
45
|
+
cmd.show_help
|
46
|
+
else
|
47
|
+
raise InvalidArgumentError, args.unshift( arg ).join(' ')
|
48
|
+
end
|
49
|
+
else
|
50
|
+
show_program_help
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
#######
|
55
|
+
private
|
56
|
+
#######
|
57
|
+
|
58
|
+
def show_program_help
|
59
|
+
puts commandparser.banner + "\n" if commandparser.banner
|
60
|
+
puts "Usage: #{commandparser.program_name} [options] COMMAND [options] [COMMAND [options] ...] [args]"
|
61
|
+
puts ""
|
62
|
+
list_commands( 1, commandparser.main_command )
|
63
|
+
puts ""
|
64
|
+
puts commandparser.main_command.options.summarize
|
65
|
+
puts
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require 'kde-build/command'
|
4
|
+
|
5
|
+
module BuildTool
|
6
|
+
|
7
|
+
|
8
|
+
class InfoCommand < Command
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super( 'info', false )
|
12
|
+
self.short_desc = "Information about a module"
|
13
|
+
self.description = "Retrieve Information aboud modules"
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute( args )
|
17
|
+
args.each do |modname|
|
18
|
+
mod = ModuleRegistry.get_modules( modname ) do |mod|
|
19
|
+
if mod == nil
|
20
|
+
puts "#{modname} is unknown"
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
puts "Building: #{modname}"
|
25
|
+
puts "Repository: #{mod.repository}"
|
26
|
+
puts "Remote Path: #{mod.remote_path}"
|
27
|
+
puts "Stage: #{mod.workdir}"
|
28
|
+
puts "Build Directory: #{mod.build_directory}"
|
29
|
+
puts "Source Directory: #{mod.source_directory}"
|
30
|
+
|
31
|
+
puts "VCS: #{mod.vcs.name}"
|
32
|
+
puts " #{mod.vcs.configuration.externals}"
|
33
|
+
puts " checkedout: #{mod.vcs.checkedout?}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require 'kde-build/command'
|
4
|
+
|
5
|
+
module BuildTool
|
6
|
+
|
7
|
+
|
8
|
+
# The default version command. It adds the options "-v" and "--version" to the global options of
|
9
|
+
# the associated +CommandParser+. When specified on the command line, it shows the version of the
|
10
|
+
# program.
|
11
|
+
class VersionCommand < Command
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super( 'version', false )
|
15
|
+
self.short_desc = "Show the version of the program"
|
16
|
+
end
|
17
|
+
|
18
|
+
def init
|
19
|
+
case commandparser.main_command.options
|
20
|
+
when CmdParse::OptionParserWrapper
|
21
|
+
commandparser.main_command.options.instance do |opt|
|
22
|
+
opt.on_tail( "--version", "-v", "Show the version of the program" ) do
|
23
|
+
execute( [] )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def usage
|
30
|
+
"Usage: #{commandparser.program_name} version"
|
31
|
+
end
|
32
|
+
|
33
|
+
def execute( args )
|
34
|
+
version = commandparser.program_version
|
35
|
+
version = version.join( '.' ) if version.instance_of?( Array )
|
36
|
+
puts commandparser.banner + "\n" if commandparser.banner
|
37
|
+
puts version
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'kde-build/metaaid'
|
5
|
+
|
6
|
+
module MJ;
|
7
|
+
|
8
|
+
class ConfigurationError < Exception
|
9
|
+
end
|
10
|
+
|
11
|
+
module Configuration
|
12
|
+
|
13
|
+
class Option
|
14
|
+
|
15
|
+
attr_accessor :name, :attribute, :description
|
16
|
+
|
17
|
+
def initialize( obj, name, description )
|
18
|
+
@name = name
|
19
|
+
@attribute =self.class.sanitize name
|
20
|
+
@description = description
|
21
|
+
@one_of = nil
|
22
|
+
@on_read = nil
|
23
|
+
@on_write = nil
|
24
|
+
@required = false
|
25
|
+
install obj
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.sanitize( name )
|
29
|
+
name.gsub( /[^a-zA-Z_]/, '_' )
|
30
|
+
end
|
31
|
+
|
32
|
+
def install( obj )
|
33
|
+
attribute = @attribute
|
34
|
+
|
35
|
+
obj.class_def( attribute ) do
|
36
|
+
opt = self.class.__options__[attribute]
|
37
|
+
value = self.values[attribute]
|
38
|
+
opt.read(value)
|
39
|
+
end
|
40
|
+
|
41
|
+
obj.class_def( "#{attribute}=" ) do
|
42
|
+
|value|
|
43
|
+
opt = self.class.__options__[attribute]
|
44
|
+
|
45
|
+
if !opt
|
46
|
+
puts self
|
47
|
+
puts self.class.__options__.inspect
|
48
|
+
end
|
49
|
+
# First validate the value
|
50
|
+
opt.validate(value)
|
51
|
+
value = opt.write(value)
|
52
|
+
|
53
|
+
# Then call the custom on_write method
|
54
|
+
self.values[attribute] = value
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def validate( value )
|
59
|
+
if @one_of and !@one_of.include? value
|
60
|
+
raise ConfigurationError, "Value #{value} is invalid for #{@name}."
|
61
|
+
end
|
62
|
+
if @required and value === nil || value.empty?
|
63
|
+
raise ConfigurationError, "Required option #{@name} is not set."
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def one_of( options )
|
68
|
+
@one_of = options
|
69
|
+
self
|
70
|
+
end
|
71
|
+
|
72
|
+
def on_write( &block )
|
73
|
+
@on_write = block
|
74
|
+
end
|
75
|
+
|
76
|
+
def required
|
77
|
+
@required = true
|
78
|
+
self
|
79
|
+
end
|
80
|
+
|
81
|
+
def write( value )
|
82
|
+
begin
|
83
|
+
return @on_write.call( value ) if @on_write
|
84
|
+
value
|
85
|
+
rescue Exception => e
|
86
|
+
$log.error("Error while setting #{@name} to #{value}")
|
87
|
+
raise e
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def on_read( &block )
|
92
|
+
@on_read = block
|
93
|
+
end
|
94
|
+
|
95
|
+
def read( value )
|
96
|
+
return @on_read.call( value ) if @on_read
|
97
|
+
value
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
def flatten_values( val, &block )
|
103
|
+
if val.instance_of?( Array )
|
104
|
+
val.each do |i|
|
105
|
+
flatten_values( i, &block )
|
106
|
+
end
|
107
|
+
elsif val.instance_of?( Hash )
|
108
|
+
val.each do |k, v|
|
109
|
+
yield k, v
|
110
|
+
end
|
111
|
+
else
|
112
|
+
puts o.class
|
113
|
+
puts o.inspect
|
114
|
+
exit( -1 )
|
115
|
+
end
|
116
|
+
end
|
117
|
+
module_function :flatten_values
|
118
|
+
|
119
|
+
|
120
|
+
module Configurable
|
121
|
+
|
122
|
+
def self.included( klass )
|
123
|
+
klass.extend( ClassMethods )
|
124
|
+
klass.send( :class_variable_set, '@@__options__', Hash.new )
|
125
|
+
end
|
126
|
+
|
127
|
+
module ClassMethods
|
128
|
+
|
129
|
+
def __options__
|
130
|
+
class_variable_get( '@@__options__' )
|
131
|
+
end
|
132
|
+
|
133
|
+
def option( name, description )
|
134
|
+
opt = Option.new( self, name, description )
|
135
|
+
self.__options__[opt.attribute] = opt
|
136
|
+
opt
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def values
|
144
|
+
@values ||= Hash.new
|
145
|
+
end
|
146
|
+
|
147
|
+
def set( key, val )
|
148
|
+
# puts "Options = #{self.class.options.inspect}"
|
149
|
+
self.send( "#{Option.sanitize( key )}=", val )
|
150
|
+
end
|
151
|
+
|
152
|
+
def validate
|
153
|
+
begin
|
154
|
+
self.class.__options__.each_pair do |name, opt|
|
155
|
+
opt.validate( @values[opt.attribute] )
|
156
|
+
end
|
157
|
+
rescue ConfigurationError => e
|
158
|
+
$log.error( "Validation for #{self.class} (#{self.to_s}) failed: #{e}" )
|
159
|
+
puts e.backtrace if $verbose
|
160
|
+
raise e
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def parse( val )
|
165
|
+
# If it is a array we expect it to only contain hashes
|
166
|
+
if val.instance_of?( Array )
|
167
|
+
val.each { |i| parse( i ) }
|
168
|
+
elsif val.instance_of?( Hash )
|
169
|
+
val.each_pair {
|
170
|
+
|k, v|
|
171
|
+
begin
|
172
|
+
# puts "#{self.class}.#{k} = #{v}"
|
173
|
+
send "#{Option.sanitize k}=", v
|
174
|
+
rescue NameError => e
|
175
|
+
$log.warn( "Unknown option '#{k}' for #{self.class} in #{self.name}: #{e}" )
|
176
|
+
end
|
177
|
+
}
|
178
|
+
else
|
179
|
+
throw "TODO"
|
180
|
+
end
|
181
|
+
self
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|