build-tool 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +1 -0
- data/History.txt +14 -0
- data/Rakefile +2 -1
- data/lib/build-tool.rb +1 -1
- data/lib/build-tool/application.rb +1 -1
- data/lib/build-tool/build-system/autoconf.rb +3 -21
- data/lib/build-tool/build-system/base.rb +117 -12
- data/lib/build-tool/build-system/cmake.rb +7 -22
- data/lib/build-tool/build-system/custom.rb +3 -13
- data/lib/build-tool/build-system/none.rb +0 -18
- data/lib/build-tool/build-system/qmake.rb +2 -20
- data/lib/build-tool/build-system/qt.rb +1 -30
- data/lib/build-tool/cfg/lexer.rb +10 -1
- data/lib/build-tool/cfg/lexer.rex +4 -1
- data/lib/build-tool/cfg/parser.rb +358 -320
- data/lib/build-tool/cfg/parser.y +8 -4
- data/lib/build-tool/cfg/visitor.rb +59 -26
- data/lib/build-tool/command_actions.rb +63 -4
- data/lib/build-tool/commands.rb +3 -1
- data/lib/build-tool/commands/environments/list.rb +26 -11
- data/lib/build-tool/commands/modules/info.rb +5 -2
- data/lib/build-tool/configuration.rb +30 -20
- data/lib/build-tool/module.rb +9 -0
- data/lib/mj/logging.rb +14 -4
- metadata +54 -18
- metadata.gz.sig +1 -0
data/lib/build-tool/cfg/parser.y
CHANGED
@@ -78,8 +78,6 @@ rule
|
|
78
78
|
: LOG_DIRECTORY STRING { result = LogDirectoryNode.new( val[1] ); }
|
79
79
|
| DISABLE FEATURE identifier { result = DisableFeatureNode.new( val[2] ); }
|
80
80
|
| ENABLE FEATURE identifier { result = EnableFeatureNode.new( val[2] ); }
|
81
|
-
| DISABLE MODULE identifier { result = DisableModuleNode.new( val[2] ); }
|
82
|
-
| ENABLE MODULE identifier { result = EnableModuleNode.new( val[2] ); }
|
83
81
|
| statement { result = val[0]; }
|
84
82
|
;
|
85
83
|
|
@@ -96,6 +94,8 @@ rule
|
|
96
94
|
| ssh_key_declaration { result = val[0]; }
|
97
95
|
| include_directive { result = val[0]; }
|
98
96
|
| feature_declaration { result = val[0]; }
|
97
|
+
| DISABLE MODULE identifier { result = DisableModuleNode.new( val[2] ); }
|
98
|
+
| ENABLE MODULE identifier { result = EnableModuleNode.new( val[2] ); }
|
99
99
|
;
|
100
100
|
|
101
101
|
vcs_declaration
|
@@ -133,7 +133,10 @@ rule
|
|
133
133
|
;
|
134
134
|
|
135
135
|
build_system_statement
|
136
|
-
: OPTION identifier
|
136
|
+
: OPTION identifier STRING { result = BuildSystemOptionNode.new( val[1..-1] ); }
|
137
|
+
| OPTION identifier SET STRING { result = BuildSystemOptionNode.new( val[1..-1] ); }
|
138
|
+
| OPTION identifier PREPEND STRING { result = BuildSystemOptionNode.new( val[1..-1] ); }
|
139
|
+
| OPTION identifier APPEND STRING { result = BuildSystemOptionNode.new( val[1..-1] ); }
|
137
140
|
| INPLACE { result = BuildSystemInplaceNode.new(); }
|
138
141
|
;
|
139
142
|
|
@@ -151,7 +154,8 @@ rule
|
|
151
154
|
;
|
152
155
|
|
153
156
|
environment_statement
|
154
|
-
: VAR TOKEN
|
157
|
+
: VAR TOKEN STRING { result = EnvironmentVariableNode.new( val[1..-1] ); }
|
158
|
+
| VAR TOKEN SET STRING { result = EnvironmentVariableNode.new( val[1..-1] ); }
|
155
159
|
| VAR TOKEN PREPEND STRING { result = EnvironmentVariableNode.new( val[1..-1] ); }
|
156
160
|
| VAR TOKEN APPEND STRING { result = EnvironmentVariableNode.new( val[1..-1] ); }
|
157
161
|
;
|
@@ -52,16 +52,12 @@ class BuildSystemDeclarationNodeVisitor < ListVisitor
|
|
52
52
|
|
53
53
|
# Initialize a build system. If no build system is provided we will
|
54
54
|
# create a new one. Which is not registered with the configuration.
|
55
|
-
def initialize( configuration, build_system
|
55
|
+
def initialize( configuration, build_system )
|
56
56
|
super( configuration )
|
57
57
|
@build_system = build_system
|
58
58
|
end
|
59
59
|
|
60
60
|
def visit_BuildSystemDeclarationNode( node )
|
61
|
-
if @build_system.nil?
|
62
|
-
name = node.values[0]
|
63
|
-
@build_system = configuration.build_system( name ).dup
|
64
|
-
end
|
65
61
|
visit_nodes( node.values[1] )
|
66
62
|
return @build_system
|
67
63
|
end
|
@@ -71,7 +67,19 @@ def visit_BuildSystemInplaceNode( node )
|
|
71
67
|
end
|
72
68
|
|
73
69
|
def visit_BuildSystemOptionNode( node )
|
74
|
-
|
70
|
+
case node.values.length
|
71
|
+
when 3
|
72
|
+
case node.values[1]
|
73
|
+
when 'append'; @build_system.append( node.values[0], node.values[2] )
|
74
|
+
when 'prepend'; @build_system.prepend( node.values[0], node.values[2] )
|
75
|
+
when 'set'; @build_system.set( node.values[0], node.values[2] )
|
76
|
+
else raise StandardError, "Unexpected token #{node.values[1]}!"
|
77
|
+
end
|
78
|
+
when 2
|
79
|
+
@build_system.set( node.values[0], node.values[1] )
|
80
|
+
else
|
81
|
+
raise StandardError, "Unexpected number of tokens #{node.values.length} #{node.values.join(', ')}"
|
82
|
+
end
|
75
83
|
end
|
76
84
|
|
77
85
|
end
|
@@ -82,8 +90,11 @@ class StatementVisitor < ListVisitor
|
|
82
90
|
def visit_BuildSystemDeclarationNode( node )
|
83
91
|
raise ArgumentsError if node.values.length != 2
|
84
92
|
name = node.values[0]
|
85
|
-
|
86
|
-
|
93
|
+
bs = configuration.build_system_defaults( name )
|
94
|
+
visitor = BuildSystemDeclarationNodeVisitor.new(
|
95
|
+
configuration,
|
96
|
+
bs )
|
97
|
+
node.accept( visitor )
|
87
98
|
end
|
88
99
|
|
89
100
|
def visit_ConfigurationFileList( node )
|
@@ -104,15 +115,6 @@ def visit_EnableFeatureNode( node )
|
|
104
115
|
feat.active = true
|
105
116
|
end
|
106
117
|
|
107
|
-
def visit_EnableModuleNode( node )
|
108
|
-
modName = node.value
|
109
|
-
mod = configuration.module( modName )
|
110
|
-
if mod.nil?
|
111
|
-
raise ConfigurationError, "Attempt to enable unknown module '%s'!" % modName
|
112
|
-
end
|
113
|
-
mod.active = true
|
114
|
-
end
|
115
|
-
|
116
118
|
def visit_DisableFeatureNode( node )
|
117
119
|
featureName = node.value
|
118
120
|
feat = configuration.feature( featureName )
|
@@ -122,6 +124,15 @@ def visit_DisableFeatureNode( node )
|
|
122
124
|
feat.active = false
|
123
125
|
end
|
124
126
|
|
127
|
+
def visit_EnableModuleNode( node )
|
128
|
+
modName = node.value
|
129
|
+
mod = configuration.module( modName )
|
130
|
+
if mod.nil?
|
131
|
+
raise ConfigurationError, "Attempt to enable unknown module '%s'!" % modName
|
132
|
+
end
|
133
|
+
mod.active = true
|
134
|
+
end
|
135
|
+
|
125
136
|
def visit_DisableModuleNode( node )
|
126
137
|
modName = node.value
|
127
138
|
mod = configuration.module( modName )
|
@@ -220,11 +231,18 @@ def visit_EnvironmentDeclarationNode( node )
|
|
220
231
|
end
|
221
232
|
|
222
233
|
def visit_EnvironmentVariableNode( node )
|
223
|
-
case node.values
|
224
|
-
when
|
225
|
-
|
226
|
-
|
227
|
-
|
234
|
+
case node.values.length
|
235
|
+
when 3
|
236
|
+
case node.values[1]
|
237
|
+
when 'append'; @environment.append( node.values[0], node.values[2] )
|
238
|
+
when 'prepend'; @environment.prepend( node.values[0], node.values[2] )
|
239
|
+
when 'set'; @environment.set( node.values[0], node.values[2] )
|
240
|
+
else raise StandardError, "Unexpected token #{node.values[1]}!"
|
241
|
+
end
|
242
|
+
when 2
|
243
|
+
@environment.set( node.values[0], node.values[1] )
|
244
|
+
else
|
245
|
+
raise StandardError, "Unexpected number of tokens #{node.values.length} #{node.values.join(', ')}"
|
228
246
|
end
|
229
247
|
end
|
230
248
|
|
@@ -353,14 +371,26 @@ def visit_ArchiveDeclarationNode( node )
|
|
353
371
|
def visit_BuildSystemDeclarationNode( node )
|
354
372
|
raise ArgumentsError if node.values.length != 2
|
355
373
|
name = node.values[0]
|
356
|
-
|
357
|
-
|
374
|
+
# We have to create a build-system. There are some possibilities:
|
375
|
+
# 1. The module has a build-system. Inherit from that one (Overloading)
|
376
|
+
# 2. The module has a parent but no build-system: Create the build-system parentless
|
377
|
+
# so it forwards to the parent module
|
378
|
+
# 3. The module has no parent and no build-system. Inherit from the build-system
|
379
|
+
# standard module.
|
380
|
+
if @module.our_build_system
|
381
|
+
# puts "Inherit from previous build-system for #{@module.name}"
|
382
|
+
build_system = configuration.build_system_adjust( name, @module.our_build_system )
|
383
|
+
elsif @module.parent
|
384
|
+
# puts "Inherit without parent for #{@module.name}"
|
385
|
+
build_system = configuration.build_system_adjust( name, nil )
|
358
386
|
else
|
359
|
-
|
387
|
+
# puts "Inherit from #{name} for #{@module.name}"
|
388
|
+
build_system = configuration.build_system_adjust( name, configuration.build_system_defaults( name ) )
|
360
389
|
end
|
361
390
|
visitor = BuildSystemDeclarationNodeVisitor.new( configuration, build_system )
|
362
391
|
@module.build_system = node.accept( visitor )
|
363
392
|
@module.build_system.module = @module
|
393
|
+
@module.build_system.feature = configuration.active_feature
|
364
394
|
end
|
365
395
|
|
366
396
|
def visit_LongDescriptionNode( node )
|
@@ -481,7 +511,10 @@ def visit_SvnDeclarationNode( node )
|
|
481
511
|
end
|
482
512
|
|
483
513
|
def visit_UseBuildSystemNode( node )
|
484
|
-
|
514
|
+
# puts "Inherit from build-system #{node.value} for #{@module.name}"
|
515
|
+
@module.build_system = configuration.build_system_adjust(
|
516
|
+
node.value,
|
517
|
+
configuration.build_system_defaults( node.value ) )
|
485
518
|
@module.build_system.module = @module
|
486
519
|
end
|
487
520
|
|
@@ -1,7 +1,64 @@
|
|
1
|
+
require 'ansi'
|
2
|
+
require 'logging'
|
1
3
|
require 'ftools'
|
2
4
|
|
3
5
|
module BuildTool
|
4
6
|
|
7
|
+
class Progressbar < Logging::Appender
|
8
|
+
|
9
|
+
def initialize( title, &block )
|
10
|
+
super( 'Progressbar', :level => :DEBUG )
|
11
|
+
@pbar = nil
|
12
|
+
@oldlogger = nil
|
13
|
+
if Logging.appenders['stdout'].level >= ::Logging::level_num(:INFO)
|
14
|
+
# We only do the progressbar thing if there is no verbose output active.
|
15
|
+
begin
|
16
|
+
# Remove the old stdout logger.
|
17
|
+
@oldlogger = Logging.appenders[ 'stdout' ]
|
18
|
+
Logging.logger[ 'root' ].remove_appenders( 'stdout' )
|
19
|
+
Logging.logger[ 'root' ].add_appenders( self )
|
20
|
+
# Add the progressbar logger
|
21
|
+
@pbar = ANSI::Progressbar.new( title, 100 )
|
22
|
+
yield
|
23
|
+
ensure
|
24
|
+
@pbar.finish
|
25
|
+
# Reset the logger
|
26
|
+
Logging.logger[ 'root' ].remove_appenders( 'Progressbar' )
|
27
|
+
Logging.logger[ 'root' ].add_appenders( @oldlogger )
|
28
|
+
end
|
29
|
+
else
|
30
|
+
# If there is verbose output just print the text
|
31
|
+
logger.info( title )
|
32
|
+
yield
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def write( event )
|
38
|
+
message = event.data
|
39
|
+
return if message.empty?
|
40
|
+
|
41
|
+
case event.level
|
42
|
+
when ::Logging::level_num( :ERROR )
|
43
|
+
when ::Logging::level_num( :WARN )
|
44
|
+
# This should never happen. In case of errors an exception is thrown which should
|
45
|
+
# be catched in the initialize() method above. And this logger is removed there.
|
46
|
+
raise NotImplementedError
|
47
|
+
|
48
|
+
else
|
49
|
+
match = /^\[ *(\d+)%\]/.match( message )
|
50
|
+
if match
|
51
|
+
# puts match[ 1 ]
|
52
|
+
@pbar.set( match[ 1 ].to_i )
|
53
|
+
end
|
54
|
+
end
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
58
|
+
end # class ProgressLayout
|
59
|
+
|
60
|
+
|
61
|
+
|
5
62
|
module ModuleActions
|
6
63
|
|
7
64
|
class Base
|
@@ -176,8 +233,9 @@ def initialize( command, mod, target = nil )
|
|
176
233
|
end
|
177
234
|
|
178
235
|
def execute()
|
179
|
-
|
180
|
-
|
236
|
+
pb = Progressbar.new( "Make #{@target}" ) do
|
237
|
+
@module.build_system_required.make( @target )
|
238
|
+
end
|
181
239
|
end
|
182
240
|
|
183
241
|
end
|
@@ -190,8 +248,9 @@ def initialize( command, mod, fast = false )
|
|
190
248
|
end
|
191
249
|
|
192
250
|
def execute()
|
193
|
-
|
194
|
-
|
251
|
+
pb = Progressbar.new( "Install #{@fast ? 'fast' : '' }" ) do
|
252
|
+
@module.build_system_required.install( @fast )
|
253
|
+
end
|
195
254
|
end
|
196
255
|
|
197
256
|
end
|
data/lib/build-tool/commands.rb
CHANGED
@@ -365,7 +365,9 @@ def complete_modules( name, include_templates = false )
|
|
365
365
|
end
|
366
366
|
end
|
367
367
|
# Raise an error if the module was not found
|
368
|
-
|
368
|
+
if !found
|
369
|
+
raise UsageError, "Unknown module/package #{name}"
|
370
|
+
end
|
369
371
|
# Give a warning if all modules where
|
370
372
|
logger.warn "All modules for #{name} are inactive! Will ignore it." if res.empty?
|
371
373
|
return res
|
@@ -24,20 +24,35 @@ def initialize_options
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def do_execute( args )
|
27
|
-
if args.length
|
28
|
-
|
29
|
-
|
27
|
+
if args.length == 0
|
28
|
+
|
29
|
+
say "%-15s (%s)" % [ "Environment", "Inherits" ]
|
30
|
+
say "------------------------------------------------------------"
|
31
|
+
configuration.environments.keys.sort.each do |name|
|
32
|
+
env = configuration.environment(name)
|
33
|
+
next if !env.active? && !@all
|
34
|
+
if env.parent
|
35
|
+
say "%-15s %s" % [ name, env.parent.name ]
|
36
|
+
else
|
37
|
+
say name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
elsif args.length == 1
|
30
42
|
|
31
|
-
|
32
|
-
|
33
|
-
configuration.environments.keys.sort.each do |name|
|
34
|
-
env = configuration.environment(name)
|
35
|
-
next if !env.active? && !@all
|
43
|
+
say "Environment:"
|
44
|
+
env = configuration.environment( args[ 0 ] )
|
36
45
|
if env.parent
|
37
|
-
say "%-15s %s" % [
|
38
|
-
else
|
39
|
-
say name
|
46
|
+
say "%-15s %s" % [ "Parent", env.parent.name ]
|
40
47
|
end
|
48
|
+
env.vars.sort.each do |var|
|
49
|
+
say " %-20s %s" % [ var + ":", env[var] ]
|
50
|
+
end
|
51
|
+
|
52
|
+
else
|
53
|
+
|
54
|
+
return usage( "To many arguments" )
|
55
|
+
|
41
56
|
end
|
42
57
|
|
43
58
|
return 0
|
@@ -77,8 +77,8 @@ def do_execute_module( mod )
|
|
77
77
|
if bs
|
78
78
|
say "Build System: #{bs.name}"
|
79
79
|
say " Out Of Source Build #{bs.out_of_source}"
|
80
|
-
bs.
|
81
|
-
say " %-
|
80
|
+
bs.option_names.sort.each do |var|
|
81
|
+
say " %-28s %s" % [ var + ":", bs[var] ]
|
82
82
|
end
|
83
83
|
else
|
84
84
|
say "Build System: Not configured"
|
@@ -89,6 +89,9 @@ def do_execute_module( mod )
|
|
89
89
|
|
90
90
|
def initialize_options
|
91
91
|
@options.banner = "Usage: #{Pathname.new($0).basename} #{self.fullname} MODULES..."
|
92
|
+
options.on( "--all", "Include inactive modules." ) {
|
93
|
+
@all = true
|
94
|
+
}
|
92
95
|
super
|
93
96
|
end
|
94
97
|
|
@@ -111,30 +111,40 @@ def vcs( name )
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
def
|
114
|
+
def create_build_system( name, parent = nil, *args )
|
115
|
+
return case name
|
116
|
+
when "none"
|
117
|
+
BuildTool::BuildSystem::None.new( parent, *args )
|
118
|
+
when "cmake"
|
119
|
+
BuildTool::BuildSystem::CMake.new( parent, *args )
|
120
|
+
when "kdel10n"
|
121
|
+
BuildTool::BuildSystem::KdeL10n.new( parent, *args )
|
122
|
+
when "qt"
|
123
|
+
BuildTool::BuildSystem::Qt.new( parent, *args )
|
124
|
+
when "qmake"
|
125
|
+
BuildTool::BuildSystem::QMake.new( parent, *args )
|
126
|
+
when "custom"
|
127
|
+
BuildTool::BuildSystem::Custom.new( parent, *args )
|
128
|
+
when "autoconf"
|
129
|
+
BuildTool::BuildSystem::AutoConf.new( parent, *args )
|
130
|
+
else
|
131
|
+
raise StandardError, "Unknown Version Control System #{name}"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def build_system_adjust( name, parent = nil, *args )
|
136
|
+
bs = create_build_system( name )
|
137
|
+
bs.defaults = build_system_defaults( name )
|
138
|
+
return bs
|
139
|
+
end
|
140
|
+
|
141
|
+
def build_system_defaults( name, *args )
|
115
142
|
return @build_system[name] if @build_system[name]
|
116
|
-
|
117
|
-
when "none"
|
118
|
-
return BuildTool::BuildSystem::None.new
|
119
|
-
when "cmake"
|
120
|
-
return BuildTool::BuildSystem::CMake.new
|
121
|
-
when "kdel10n"
|
122
|
-
return BuildTool::BuildSystem::KdeL10n.new
|
123
|
-
when "qt"
|
124
|
-
return BuildTool::BuildSystem::Qt.new
|
125
|
-
when "qmake"
|
126
|
-
return BuildTool::BuildSystem::QMake.new
|
127
|
-
when "custom"
|
128
|
-
return BuildTool::BuildSystem::Custom.new
|
129
|
-
when "autoconf"
|
130
|
-
return BuildTool::BuildSystem::AutoConf.new
|
131
|
-
else
|
132
|
-
raise StandardError, "Unknown Version Control System #{name}"
|
133
|
-
end
|
143
|
+
add_build_system( create_build_system( name ) )
|
134
144
|
end
|
135
145
|
|
136
146
|
def add_build_system( bs )
|
137
|
-
@build_system[bs.name] = bs
|
147
|
+
return @build_system[bs.name] = bs
|
138
148
|
end
|
139
149
|
|
140
150
|
end # Configuration
|
data/lib/build-tool/module.rb
CHANGED
@@ -38,6 +38,7 @@ def initialize( name, parent = nil )
|
|
38
38
|
attr_writer :feature
|
39
39
|
attr_writer :active
|
40
40
|
attr_reader :patches
|
41
|
+
attr_reader :parent
|
41
42
|
|
42
43
|
def active?
|
43
44
|
# If the module is activated that wins
|
@@ -96,6 +97,10 @@ def build_system
|
|
96
97
|
nil
|
97
98
|
end
|
98
99
|
|
100
|
+
def our_build_system
|
101
|
+
@build_system
|
102
|
+
end
|
103
|
+
|
99
104
|
# Will throw a exception if build_system is not set
|
100
105
|
def build_system_required
|
101
106
|
return self.build_system if self.build_system
|
@@ -343,6 +348,10 @@ def prepare_for_installation
|
|
343
348
|
return true
|
344
349
|
end
|
345
350
|
|
351
|
+
def to_s
|
352
|
+
"#{object_id}: #{name}"
|
353
|
+
end
|
354
|
+
|
346
355
|
end # Module
|
347
356
|
|
348
357
|
|