build-tool 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +28 -1
  3. data/Manifest.txt +91 -52
  4. data/README.txt +63 -0
  5. data/Rakefile +20 -23
  6. data/bin/build-tool +53 -0
  7. data/lib/build-tool.rb +7 -0
  8. data/lib/build-tool/GUI.rb +360 -0
  9. data/lib/build-tool/application.rb +84 -0
  10. data/lib/build-tool/build-system/autoconf.rb +60 -0
  11. data/lib/build-tool/build-system/base.rb +142 -0
  12. data/lib/build-tool/build-system/cmake.rb +119 -0
  13. data/lib/build-tool/build-system/custom.rb +115 -0
  14. data/lib/build-tool/build-system/qt.rb +113 -0
  15. data/lib/build-tool/cfg/lexer.rb +558 -0
  16. data/lib/build-tool/cfg/lexer.rex +248 -0
  17. data/lib/build-tool/cfg/lexer_base.rb +82 -0
  18. data/lib/build-tool/cfg/node.rb +94 -0
  19. data/lib/build-tool/cfg/parser.rb +871 -0
  20. data/lib/build-tool/cfg/parser.y +279 -0
  21. data/lib/build-tool/cfg/visitor.rb +471 -0
  22. data/lib/build-tool/commands.rb +639 -0
  23. data/lib/build-tool/commands/build.rb +120 -0
  24. data/lib/build-tool/commands/configure.rb +73 -0
  25. data/lib/build-tool/commands/ctags.rb +46 -0
  26. data/lib/build-tool/commands/environments.rb +29 -0
  27. data/lib/build-tool/commands/environments/list.rb +37 -0
  28. data/lib/build-tool/commands/environments/set.rb +33 -0
  29. data/lib/build-tool/commands/fetch.rb +50 -0
  30. data/lib/build-tool/commands/files.rb +73 -0
  31. data/lib/build-tool/commands/help.rb +22 -0
  32. data/lib/build-tool/commands/info.rb +48 -0
  33. data/lib/build-tool/commands/install.rb +56 -0
  34. data/lib/build-tool/commands/modules.rb +29 -0
  35. data/lib/build-tool/commands/modules/info.rb +75 -0
  36. data/lib/build-tool/commands/modules/list.rb +49 -0
  37. data/lib/build-tool/commands/modules/shell.rb +40 -0
  38. data/lib/build-tool/commands/rebase.rb +46 -0
  39. data/lib/build-tool/commands/recipes.rb +32 -0
  40. data/lib/build-tool/commands/recipes/info.rb +46 -0
  41. data/lib/build-tool/commands/recipes/install.rb +184 -0
  42. data/lib/build-tool/commands/recipes/list.rb +33 -0
  43. data/lib/build-tool/configuration.rb +115 -0
  44. data/lib/build-tool/environment.rb +119 -0
  45. data/lib/build-tool/errors.rb +9 -0
  46. data/lib/build-tool/module.rb +366 -0
  47. data/lib/build-tool/pluginbase.rb +43 -0
  48. data/lib/build-tool/recipe.rb +180 -0
  49. data/lib/build-tool/repository.rb +59 -0
  50. data/lib/build-tool/server.rb +43 -0
  51. data/lib/build-tool/singleton.rb +50 -0
  52. data/lib/build-tool/sshkey.rb +22 -0
  53. data/lib/build-tool/vcs/base.rb +105 -0
  54. data/lib/build-tool/vcs/git-svn.rb +154 -0
  55. data/lib/build-tool/vcs/git.rb +187 -0
  56. data/lib/build-tool/vcs/svn.rb +136 -0
  57. data/lib/mj/logging.rb +31 -0
  58. data/lib/mj/tools/ssh.rb +64 -0
  59. data/lib/{kde-build → mj/tools}/subprocess.rb +21 -16
  60. data/lib/mj/visitor.rb +21 -0
  61. data/recipes/kde/files/finish_installation.sh +16 -0
  62. data/recipes/kde/files/kde4.desktop +22 -0
  63. data/recipes/kde/files/xsession +89 -0
  64. data/recipes/kde/info.yaml +10 -0
  65. data/recipes/kde/recipe +585 -0
  66. data/recipes/kde/recipe-local +90 -0
  67. data/recipes/kde/settings.yaml +52 -0
  68. data/recipes/kde43/info.yaml +10 -0
  69. data/recipes/kde43/recipe +256 -0
  70. data/recipes/kde43/recipe-local +90 -0
  71. data/recipes/kde43/settings.yaml +32 -0
  72. data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/compile.sh +77 -0
  73. data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/configure.sh +70 -0
  74. data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/install.sh +39 -0
  75. data/recipes/kdeqt4.6/info.yaml +7 -0
  76. data/recipes/kdeqt4.6/recipe +155 -0
  77. data/recipes/kdeqt4.6/recipe-local +30 -0
  78. data/recipes/kdeqt4.6/settings.yaml +27 -0
  79. data/tags +745 -0
  80. data/tasks/genfiles.rake +28 -0
  81. data/tasks/rdoc.rake +34 -0
  82. data/tasks/rspec.rake +21 -0
  83. data/test.rb +28 -0
  84. data/test/commands/test_build.rb +29 -0
  85. data/test/test_build_system.rb +98 -0
  86. data/test/test_cli.rb +61 -0
  87. data/test/test_command.rb +175 -0
  88. data/test/test_configuration_parser.rb +542 -0
  89. data/test/test_environment.rb +82 -0
  90. data/test/test_helper.rb +39 -7
  91. data/test/test_module.rb +158 -0
  92. data/test/test_repository.rb +75 -0
  93. data/test/test_singleton.rb +51 -0
  94. data/test/test_ssh_key.rb +14 -0
  95. data/test/test_svn_parser.rb +28 -0
  96. data/test/test_vcs.rb +33 -0
  97. metadata +139 -90
  98. metadata.gz.sig +0 -0
  99. data/PostInstall.txt +0 -3
  100. data/TODO +0 -2
  101. data/bin/kde-build.rb +0 -21
  102. data/config/website.yml +0 -2
  103. data/config/website.yml.sample +0 -2
  104. data/lib/kde-build.rb +0 -18
  105. data/lib/kde-build/application.rb +0 -270
  106. data/lib/kde-build/build_system.rb +0 -28
  107. data/lib/kde-build/build_system/autoconf.rb +0 -108
  108. data/lib/kde-build/build_system/base.rb +0 -139
  109. data/lib/kde-build/build_system/cmake.rb +0 -94
  110. data/lib/kde-build/build_system/qtcopy.rb +0 -127
  111. data/lib/kde-build/command.rb +0 -42
  112. data/lib/kde-build/command/build.rb +0 -106
  113. data/lib/kde-build/command/compile.rb +0 -39
  114. data/lib/kde-build/command/configure.rb +0 -48
  115. data/lib/kde-build/command/ctags.rb +0 -41
  116. data/lib/kde-build/command/fetch.rb +0 -33
  117. data/lib/kde-build/command/help.rb +0 -71
  118. data/lib/kde-build/command/info.rb +0 -45
  119. data/lib/kde-build/command/install.rb +0 -39
  120. data/lib/kde-build/command/module_based.rb +0 -44
  121. data/lib/kde-build/command/rebase.rb +0 -50
  122. data/lib/kde-build/command/version.rb +0 -43
  123. data/lib/kde-build/configuration.rb +0 -209
  124. data/lib/kde-build/exception.rb +0 -6
  125. data/lib/kde-build/metaaid.rb +0 -18
  126. data/lib/kde-build/module.rb +0 -227
  127. data/lib/kde-build/module_configuration.rb +0 -107
  128. data/lib/kde-build/moduleregistry.rb +0 -85
  129. data/lib/kde-build/tools/ctags.rb +0 -59
  130. data/lib/kde-build/tools/logging.rb +0 -49
  131. data/lib/kde-build/tools/make.rb +0 -58
  132. data/lib/kde-build/tools/ssh.rb +0 -47
  133. data/lib/kde-build/vcs.rb +0 -28
  134. data/lib/kde-build/vcs/base.rb +0 -85
  135. data/lib/kde-build/vcs/git-svn.rb +0 -139
  136. data/lib/kde-build/vcs/git.rb +0 -121
  137. data/lib/kde-build/vcs/svn.rb +0 -102
  138. data/script/console +0 -10
  139. data/script/destroy +0 -14
  140. data/script/generate +0 -14
  141. data/script/txt2html +0 -71
  142. data/test.yaml.tmpl +0 -632
  143. data/test/test_kde-build.rb +0 -11
  144. data/test/test_vcs_svn.rb +0 -44
  145. data/website/index.html +0 -84
  146. data/website/index.txt +0 -59
  147. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  148. data/website/stylesheets/screen.css +0 -159
  149. data/website/template.html.erb +0 -50
@@ -0,0 +1,279 @@
1
+ class BuildTool::Cfg::Parser < BuildTool::Cfg::Lexer
2
+
3
+ token APPEND
4
+ token BUILD_PREFIX
5
+ token BUILD_SYSTEM
6
+ token END
7
+ token ENVIRONMENT
8
+ token EXTERNAL
9
+ token FILE
10
+ token GIT
11
+ token GIT_SVN
12
+ token HOST
13
+ token INHERITANCE
14
+ token INPLACE
15
+ token INSTALL_PREFIX
16
+ token LOCAL_PATH
17
+ token LOG_DIRECTORY
18
+ token MODULE
19
+ token OPTION
20
+ token PATH
21
+ token PREPEND
22
+ token PROTOCOL
23
+ token REMOTE
24
+ token REMOTE_PATH
25
+ token REPOSITORY
26
+ token SERVER
27
+ token SET
28
+ token SSH_KEY
29
+ token STRING
30
+ token TEMPLATE
31
+ token TOKEN
32
+ token TRACK_BRANCH
33
+ token USE
34
+ token USER
35
+ token VAR
36
+ token VCS
37
+
38
+ rule
39
+
40
+ main
41
+ : statements { result = ConfigurationFileList.new( val[0] ); }
42
+ ;
43
+
44
+ #
45
+ ### SOME HELPER
46
+ #
47
+
48
+ identifier
49
+ : STRING { result = val[0]; }
50
+ | TOKEN { result = val[0]; }
51
+ ;
52
+
53
+ inheritance
54
+ : INHERITANCE { result = :INHERITANCE; }
55
+ ;
56
+
57
+ #
58
+ ### TOP LEVEL STATEMENTS
59
+ #
60
+ statements
61
+ : /* empty */
62
+ | statement statements { result = val.flatten; }
63
+ ;
64
+
65
+ statement
66
+ : LOG_DIRECTORY STRING { result = LogDirectoryNode.new( val[1] ); }
67
+ | build_system_declaration { result = val[0]; }
68
+ | environment_declaration { result = val[0]; }
69
+ | vcs_declaration { result = val[0]; }
70
+ | module_declaration { result = val[0]; }
71
+ | repository_declaration { result = val[0]; }
72
+ | server_declaration { result = val[0]; }
73
+ | ssh_key_declaration { result = val[0]; }
74
+ ;
75
+
76
+ vcs_declaration
77
+ : git_declaration { result = val[0]; }
78
+ | git_svn_declaration { result = val[0]; }
79
+ ;
80
+
81
+ #
82
+ ### BUILD SYSTEM DECLARATION
83
+ #
84
+ build_system_declaration
85
+ : BUILD_SYSTEM identifier build_system_statements END { result = BuildSystemDeclarationNode.new( val[1,2] ); }
86
+ ;
87
+
88
+ build_system_statements
89
+ : /* empty */
90
+ | build_system_statement build_system_statements { result = val.flatten; }
91
+ ;
92
+
93
+ build_system_statement
94
+ : OPTION identifier STRING { result = BuildSystemOptionNode.new( val[1,2] ); }
95
+ | INPLACE { result = BuildSystemInplaceNode.new(); }
96
+ ;
97
+
98
+ #
99
+ ### ENVIRONMENT CONFIGURATION
100
+ #
101
+ environment_declaration
102
+ : ENVIRONMENT identifier environment_statements END { result = EnvironmentDeclarationNode.new( val[1..-1] ); }
103
+ | ENVIRONMENT identifier inheritance identifier environment_statements END { result = EnvironmentDeclarationNode.new( val[1..-1] ); }
104
+ ;
105
+
106
+ environment_statements
107
+ : /* empty */
108
+ | environment_statement environment_statements { result = val.flatten; }
109
+ ;
110
+
111
+ environment_statement
112
+ : VAR TOKEN SET STRING { result = EnvironmentVariableNode.new( val[1..-1] ); }
113
+ | VAR TOKEN PREPEND STRING { result = EnvironmentVariableNode.new( val[1..-1] ); }
114
+ | VAR TOKEN APPEND STRING { result = EnvironmentVariableNode.new( val[1..-1] ); }
115
+ ;
116
+
117
+ #
118
+ ### GIT CONFIGURATION
119
+ #
120
+ git_declaration
121
+ : VCS GIT git_statements END { result = GitDeclarationNode.new( val[2] ); }
122
+ ;
123
+
124
+ git_statements
125
+ : /* empty */
126
+ | git_statement git_statements { result = val.flatten; }
127
+ ;
128
+
129
+ git_statement
130
+ : REMOTE STRING git_remote_values END { result = GitRemoteNode.new( [ val[1], GitRemoteValueList.new( val[2] ) ] ); }
131
+ | TRACK_BRANCH STRING { result = GitTrackBranchNode.new( val[1] ); }
132
+ | EXTERNAL STRING { result = GitSvnExternalNode.new( val[1] ); }
133
+ ;
134
+
135
+ git_remote_values
136
+ : /* empty */
137
+ | git_remote_value git_remote_values { result = val.flatten; }
138
+ ;
139
+
140
+ git_remote_value
141
+ : server_declaration { result = val[0]; }
142
+ | USE SERVER identifier { result = UseServerNode.new( val[2] ); }
143
+ ;
144
+
145
+ #
146
+ ### GIT-SVN CONFIGURATION
147
+ #
148
+ git_svn_declaration
149
+ : VCS GIT_SVN git_svn_statements END { result = GitSvnDeclarationNode.new( val[2] ); }
150
+ ;
151
+
152
+ git_svn_statements
153
+ : /* empty */
154
+ | git_svn_statement git_svn_statements { result = val.flatten; }
155
+ ;
156
+
157
+ git_svn_statement
158
+ : git_statement
159
+ ;
160
+
161
+ #
162
+ ### MODULE DECLARATION
163
+ #
164
+ module_declaration
165
+ : MODULE identifier module_statements END { result = ModuleDeclarationNode.new( val[1..-1] ); }
166
+ | MODULE identifier inheritance identifier module_statements END { result = ModuleDeclarationNode.new( val[1..-1] ); }
167
+ ;
168
+
169
+ module_statements
170
+ : /* EMPTY */
171
+ | module_statement module_statements { result = val.flatten; }
172
+ ;
173
+
174
+ module_statement
175
+ : USE BUILD_SYSTEM identifier { result = UseBuildSystemNode.new( val[2] ); }
176
+ | USE ENVIRONMENT identifier { result = UseEnvironmentNode.new( val[2] ); }
177
+ | USE REPOSITORY identifier { result = UseRepositoryNode.new( val[2] ); }
178
+ | USE VCS identifier { result = UseVcsNode.new( val[2] ); }
179
+ | build_system_declaration { result = val[0]; }
180
+ | vcs_declaration { result = val[0]; }
181
+ | repository_declaration { result = val[0]; }
182
+ | environment_declaration { result = val[0]; }
183
+ | INSTALL_PREFIX STRING { result = ModuleInstallPrefixNode.new( val[1] ); }
184
+ | BUILD_PREFIX STRING { result = ModuleBuildPrefixNode.new( val[1] ); }
185
+ | REMOTE_PATH STRING { result = ModuleRemotePathNode.new( val[1] ); }
186
+ | LOCAL_PATH STRING { result = ModuleLocalPathNode.new( val[1] ); }
187
+ | TEMPLATE { result = ModuleTemplateNode.new(); }
188
+ ;
189
+
190
+ #
191
+ ### REPOSITORY DECLARATION
192
+ #
193
+ repository_declaration
194
+ : REPOSITORY identifier repository_statements END { result = RepositoryDeclarationNode.new( val[1..-1] ); }
195
+ ;
196
+
197
+ repository_statements
198
+ : /* empty */
199
+ | repository_statement repository_statements { result = val.flatten(); }
200
+ ;
201
+
202
+ repository_statement
203
+ : SERVER identifier { result = RepositoryServerNode.new( val[1] ); }
204
+ | PATH STRING { result = RepositoryPathNode.new( val[1] ); }
205
+ | USER identifier { result = RepositoryUserNode.new( val[1] ); }
206
+ | USE SSH_KEY identifier { result = UseSshKeyNode.new( val[2] ); }
207
+ | ssh_key_declaration { result = val[0]; }
208
+ ;
209
+
210
+ #
211
+ ### SERVER DECLARATION
212
+ #
213
+ server_declaration
214
+ : SERVER identifier server_statements END { result = ServerDeclarationNode.new( [ val[1], ServerStatementList.new( val[2] ) ] ); }
215
+ ;
216
+
217
+ server_statements
218
+ : /* empty */
219
+ | server_statement server_statements { result = val.flatten; }
220
+ ;
221
+
222
+ server_statement
223
+ : HOST STRING { result = ServerHostNode.new( val[1] ); }
224
+ | PROTOCOL STRING { result = ServerProtocolNode.new( val[1] ); }
225
+ | PATH STRING { result = ServerPathNode.new( val[1] ); }
226
+ ;
227
+
228
+ #
229
+ ### SSH KEY
230
+ #
231
+ ssh_key_declaration
232
+ : SSH_KEY identifier ssh_key_statements END { result = SshKeyDeclarationNode.new( val[1..-1] ); }
233
+ ;
234
+
235
+ ssh_key_statements
236
+ : /* empty */
237
+ | ssh_key_statement ssh_key_statements { result = val.flatten; }
238
+ ;
239
+
240
+ ssh_key_statement
241
+ : FILE STRING { result = SshKeyFileNode.new( val[1] ); }
242
+ ;
243
+
244
+
245
+ end # class BuildTool::Cfg::GitParser
246
+
247
+ ---- header ----
248
+ #
249
+ ### HEADER
250
+ #
251
+ require 'build-tool/cfg/lexer'
252
+ require 'build-tool/cfg/node'
253
+ require 'build-tool/cfg/visitor'
254
+
255
+
256
+ ---- inner ----
257
+ #
258
+ ### INNER
259
+ #
260
+ attr_accessor :configuration
261
+
262
+ def initialize( configuration = Configuration.new)
263
+ super()
264
+ @configuration = configuration
265
+ end
266
+
267
+ def parse_string( string, file = "<string>" )
268
+ tree = super
269
+ visitor = Cfg::ConfigurationFileVisitor.new( configuration )
270
+ conf = tree.accept( visitor )
271
+ return configuration
272
+ end
273
+
274
+ ---- footer ----
275
+ #
276
+ ### FOOTER
277
+ #
278
+
279
+
@@ -0,0 +1,471 @@
1
+ require 'build-tool/configuration'
2
+ require 'build-tool/environment'
3
+ require 'build-tool/repository'
4
+ require 'build-tool/module'
5
+ require 'build-tool/sshkey'
6
+ require 'build-tool/server'
7
+
8
+ module BuildTool; module Cfg;
9
+
10
+ # Base class for all Visitors.
11
+ class VisitorBase
12
+
13
+ # The configuration object to fill with our parse results.
14
+ attr_reader :configuration
15
+
16
+ def initialize( configuration )
17
+ @configuration = configuration
18
+ end
19
+
20
+ end # class VisitorBase
21
+
22
+
23
+ # Base class for all Visitors which need to iterate over their child
24
+ # nodes.
25
+ class ListVisitor < VisitorBase
26
+
27
+ # Visit one node.
28
+ def visit( node )
29
+ return self.visit_nodes( node.values )
30
+ end
31
+
32
+ # Visit all nodes.
33
+ def visit_nodes(nodes)
34
+ list = []
35
+ return list if nodes.nil?
36
+ nodes.each do |child|
37
+ break if child.nil?
38
+ list << child.accept( self )
39
+ end
40
+ return list
41
+ end
42
+
43
+ end # class ListVisitor
44
+
45
+
46
+ # Build System Declaration Visitor.
47
+ class BuildSystemDeclarationNodeVisitor < ListVisitor
48
+
49
+ # Initialize a build system. If no build system is provided we will
50
+ # create a new one. Which is not registered with the configuration.
51
+ def initialize( configuration, build_system = nil )
52
+ super( configuration )
53
+ @build_system = build_system
54
+ end
55
+
56
+ def visit_BuildSystemDeclarationNode( node )
57
+ if @build_system.nil?
58
+ name = node.values[0]
59
+ @build_system = configuration.build_system( name ).dup
60
+ end
61
+ visit_nodes( node.values[1] )
62
+ return @build_system
63
+ end
64
+
65
+ def visit_BuildSystemInplaceNode( node )
66
+ @build_system.out_of_source = false
67
+ end
68
+
69
+ def visit_BuildSystemOptionNode( node )
70
+ @build_system[ node.value[0] ] = node.value[1]
71
+ end
72
+
73
+ end
74
+
75
+
76
+ # The Configuration File Visitor.
77
+ #
78
+ # This is the toplevel visitor.
79
+ class ConfigurationFileVisitor < ListVisitor
80
+
81
+ def visit_BuildSystemDeclarationNode( node )
82
+ raise ArgumentsError if node.values.length != 2
83
+ name = node.values[0]
84
+ visitor = BuildSystemDeclarationNodeVisitor.new( configuration, configuration.build_system(name) )
85
+ configuration.add_build_system( node.accept( visitor ) )
86
+ end
87
+
88
+ def visit_ConfigurationFileList( node )
89
+ self.visit(node)
90
+ end
91
+
92
+ def visit_EnvironmentDeclarationNode( node )
93
+ visitor = EnvironmentDeclarationNodeVisitor.new( configuration )
94
+ node.accept( visitor )
95
+ end
96
+
97
+ def visit_GitDeclarationNode( node )
98
+ visitor = GitDeclarationNodeVisitor.new( configuration )
99
+ return node.accept( visitor )
100
+ end
101
+
102
+ def visit_LogDirectoryNode( node )
103
+ configuration.log_directory = node.value
104
+ end
105
+
106
+ def visit_ModuleDeclarationNode( node )
107
+ visitor = ModuleDeclarationNodeVisitor.new( configuration )
108
+ node.accept( visitor )
109
+ end
110
+
111
+ def visit_RepositoryDeclarationNode( node )
112
+ visitor = RepositoryDeclarationNodeVisitor.new( configuration )
113
+ node.accept(visitor)
114
+ end
115
+
116
+ def visit_ServerDeclarationNode( node )
117
+ visitor = ServerDeclarationNodeVisitor.new( configuration )
118
+ node.accept(visitor)
119
+ end
120
+
121
+ def visit_SshKeyDeclarationNode( node )
122
+ visitor = SshKeyDeclarationNodeVisitor.new( configuration )
123
+ node.accept(visitor)
124
+ end
125
+
126
+ end # class ConfigurationFileVisitor
127
+
128
+
129
+ class EnvironmentDeclarationNodeVisitor < ListVisitor
130
+
131
+ def visit_EnvironmentDeclarationNode( node )
132
+ name = node.values[0]
133
+ @environment = configuration.environment( name )
134
+ @environment = BuildTool::Environment.new( name ) if @environment.nil?
135
+ configuration.add_environment( @environment )
136
+ if node.values[1] == :INHERITANCE
137
+ @environment.parent = configuration.environment(node.values[2])
138
+ self.visit_nodes( node.values[3] )
139
+ else
140
+ self.visit_nodes( node.values[1] )
141
+ end
142
+ return @environment
143
+ end
144
+
145
+ def visit_EnvironmentVariableNode( node )
146
+ case node.values[1]
147
+ when 'append'; @environment.append( node.values[0], node.values[2] )
148
+ when 'prepend'; @environment.prepend( node.values[0], node.values[2] )
149
+ when 'set'; @environment.set( node.values[0], node.values[2] )
150
+ else raise StandardError, "Unexpected token #{node.values[1]}!"
151
+ end
152
+ end
153
+
154
+ end # class EnvironmentDeclarationNodeVisitor
155
+
156
+
157
+ class GitDeclarationNodeVisitor < ListVisitor
158
+
159
+ def initialize( configuration, vcs = BuildTool::VCS::GitConfiguration.new )
160
+ super( configuration )
161
+ @vcs = vcs
162
+ end
163
+
164
+ def visit_GitDeclarationNode( node )
165
+ visit_nodes( node.values )
166
+ return @vcs
167
+ end
168
+
169
+ def visit_GitRemoteNode( node )
170
+ visitor = GitRemoteNodeVisitor.new( configuration )
171
+ remote = node.accept(visitor)
172
+ @vcs.remote[remote.name] = remote
173
+ end
174
+
175
+ def visit_GitTrackBranchNode( node )
176
+ @vcs.track_branch = node.value
177
+ end
178
+
179
+ end # class GitDeclarationNodeVisitor
180
+
181
+
182
+ class GitSvnDeclarationNodeVisitor < GitDeclarationNodeVisitor
183
+
184
+ def initialize( configuration, vcs )
185
+ super( configuration, vcs )
186
+ end
187
+
188
+ def visit_GitSvnDeclarationNode( node )
189
+ visit_nodes( node.values )
190
+ return @vcs
191
+ end
192
+
193
+ def visit_GitSvnExternalNode( node )
194
+ ( name, value ) = node.value.split( '#' )
195
+ @vcs.add_external( name, value )
196
+ end
197
+
198
+ end # class GitSvnDeclarationNodeVisitor
199
+
200
+
201
+ class GitRemoteNodeVisitor < ListVisitor
202
+
203
+ def initialize( configuration )
204
+ super( configuration )
205
+ @remote = nil
206
+ end
207
+
208
+ def visit_GitRemoteNode( node )
209
+ name = node.values[0]
210
+ @remote = BuildTool::VCS::GitRemote.new( name ) if @remote.nil?
211
+ node = node.values[1]
212
+ self.visit_nodes(node.values)
213
+ return @remote
214
+ end
215
+
216
+ def visit_GitRemotePathNode( node )
217
+ @remote.path = node.value
218
+ end
219
+
220
+ def visit_GitRemoteValueList( node )
221
+ self.visit(node)
222
+ end
223
+
224
+ def visit_ServerDeclarationNode( node )
225
+ visitor = ServerDeclarationNodeVisitor.new( configuration )
226
+ @remote.server = node.accept(visitor)
227
+ end
228
+
229
+ def visit_UseServerNode( node )
230
+ @remote.server = configuration.server( node.value )
231
+ if @remote.server.nil?
232
+ raise ConfigurationError, "Unknown server #{node.value} configured for remote #{@remote.name}!"
233
+ end
234
+ end
235
+
236
+ end # class GitRemoteNodeVisitor
237
+
238
+
239
+ class ModuleDeclarationNodeVisitor < ListVisitor
240
+
241
+ def initialize( configuration )
242
+ super
243
+ @module = nil
244
+ end
245
+
246
+ def visit_BuildSystemDeclarationNode( node )
247
+ raise ArgumentsError if node.values.length != 2
248
+ name = node.values[0]
249
+ if @module.build_system and @module.build_system.name == name
250
+ build_system = @module.build_system.dup
251
+ else
252
+ build_system = nil
253
+ end
254
+ visitor = BuildSystemDeclarationNodeVisitor.new( configuration, build_system )
255
+ @module.build_system = node.accept( visitor )
256
+ @module.build_system.module = @module
257
+ end
258
+
259
+ def visit_EnvironmentDeclarationNode( node )
260
+ visitor = EnvironmentDeclarationNodeVisitor.new( configuration )
261
+ @module.environment = node.accept( visitor )
262
+ end
263
+
264
+ def visit_GitDeclarationNode( node )
265
+ name = node.values[0]
266
+ if @module.vcs_configuration and @module.vcs_configuration.name == name
267
+ vcs = @module.vcs_configuration.dup
268
+ else
269
+ vcs = BuildTool::VCS::GitConfiguration.new
270
+ end
271
+ @module.vcs_configuration = vcs
272
+ begin
273
+ visitor = GitDeclarationNodeVisitor.new( configuration, vcs )
274
+ node.accept( visitor )
275
+ rescue ConfigurationError => e
276
+ raise ConfigurationError, "Module #{@module.name}: #{e.to_s}"
277
+ end
278
+ end
279
+
280
+ def visit_GitSvnDeclarationNode( node )
281
+ name = node.values[0]
282
+ if @module.vcs_configuration and @module.vcs_configuration.name == name
283
+ vcs = @module.vcs_configuration.dup
284
+ else
285
+ vcs = BuildTool::VCS::GitSvnConfiguration.new
286
+ end
287
+ @module.vcs_configuration = vcs
288
+ visitor = GitSvnDeclarationNodeVisitor.new( configuration, vcs )
289
+ node.accept( visitor )
290
+ end
291
+
292
+ def visit_ModuleBuildPrefixNode( node )
293
+ @module.build_prefix = node.value
294
+ end
295
+
296
+ def visit_ModuleDeclarationNode( node )
297
+ name = node.values[0]
298
+ inheritance = node.values[1] == :INHERITANCE
299
+ if inheritance
300
+ stmts = node.values[3]
301
+ else
302
+ stmts = node.values[1]
303
+ end
304
+ # Check if the module is alread defined. If yes we reopen it.
305
+ @module = configuration.module( name )
306
+ if @module
307
+ if inheritance
308
+ raise ConfigurationError, "Attempt change existing module #{name} with inheritance!"
309
+ end
310
+ elsif inheritance
311
+ @module = BuildTool::Module.new( name, configuration.module(node.values[2]) )
312
+ configuration.add_module( @module )
313
+ else
314
+ @module = BuildTool::Module.new( name )
315
+ configuration.add_module( @module )
316
+ end
317
+ self.visit_nodes( stmts )
318
+ end
319
+
320
+ def visit_ModuleInstallPrefixNode( node )
321
+ @module.install_prefix = node.value
322
+ end
323
+
324
+ def visit_ModuleLocalPathNode( node )
325
+ @module.local_path = node.value
326
+ end
327
+
328
+ def visit_ModuleRemotePathNode( node )
329
+ @module.remote_path = node.value
330
+ end
331
+
332
+ def visit_ModuleTemplateNode( node )
333
+ @module.is_template = true
334
+ end
335
+
336
+ def visit_RepositoryDeclarationNode( node )
337
+ visitor = RepositoryDeclarationNodeVisitor.new( configuration )
338
+ @module.repository = node.accept( visitor )
339
+ end
340
+
341
+ def visit_UseBuildSystemNode( node )
342
+ @module.build_system = configuration.build_system( node.value ).dup
343
+ @module.build_system.module = @module
344
+ end
345
+
346
+ def visit_UseEnvironmentNode( node )
347
+ @module.environment = configuration.environment( node.value )
348
+ if @module.environment.nil?
349
+ raise ConfigurationError, "Unknown environment #{node.value} configured for module #{@module.name}!"
350
+ end
351
+ end
352
+
353
+ def visit_UseRepositoryNode( node )
354
+ @module.repository = configuration.repository( node.value )
355
+ if @module.repository.nil?
356
+ raise ConfigurationError, "Unknown repository #{node.value} configured for module #{@module.name}!"
357
+ end
358
+ end
359
+
360
+ def visit_UseVcsNode( node )
361
+ @module.vcs_configuration = configuration.vcs(node.value)
362
+ end
363
+
364
+ end # class ModuleDeclarationNodeVisitor
365
+
366
+
367
+ class RepositoryDeclarationNodeVisitor < ListVisitor
368
+
369
+ def visit_RepositoryDeclarationNode( node )
370
+ name = node.values[0]
371
+ @repository = configuration.repository(name)
372
+ if @repository.nil?
373
+ @repository = BuildTool::Repository.new( name )
374
+ configuration.add_repository( @repository )
375
+ end
376
+ stmts = node.values[1]
377
+ visit_nodes( stmts )
378
+ return @repository
379
+ end
380
+
381
+ def visit_RepositoryPathNode( node )
382
+ @repository.path = node.value
383
+ end
384
+
385
+ def visit_RepositoryServerNode( node )
386
+ @repository.server = configuration.server( node.value )
387
+ if @repository.server.nil?
388
+ raise ConfigurationError, "Unknown server #{node.value} configured for repository #{@repository.name}!"
389
+ end
390
+ end
391
+
392
+ def visit_RepositoryUserNode( node )
393
+ @repository.user = node.value
394
+ end
395
+
396
+ def visit_SshKeyDeclarationNode( node )
397
+ @repository.sshkey = node.value
398
+ end
399
+
400
+ def visit_UseSshKeyNode( node )
401
+ name = node.value
402
+ @repository.sshkey = configuration.sshkey(name)
403
+ raise ConfigurationError, "Unknown ssh-key #{name} configured for repository #{@repository.name}!" if @repository.sshkey.nil?
404
+ end
405
+
406
+ end # class RepositoryDeclarationNodeVisitor
407
+
408
+
409
+ class ServerDeclarationNodeVisitor < ListVisitor
410
+
411
+ def initialize( configuration )
412
+ super( configuration )
413
+ @server = nil
414
+ end
415
+
416
+ def visit_ServerDeclarationNode( node )
417
+ name = node.values[0]
418
+ # Check if a server with that name already exists
419
+ @server = configuration.server(name)
420
+ # Create a new one if not
421
+ @server = Server.new( name ) if @server.nil?
422
+ statements = node.values[1]
423
+ self.visit_nodes(statements.values)
424
+ configuration.add_server( @server )
425
+ return @server
426
+ end
427
+
428
+ def visit_ServerHostNode( node )
429
+ @server.host = node.value
430
+ end
431
+
432
+ def visit_ServerPathNode( node )
433
+ @server.path = node.value
434
+ end
435
+
436
+ def visit_ServerProtocolNode( node )
437
+ @server.protocol = node.value
438
+ end
439
+
440
+ def visit_ServerStatementList( node )
441
+ self.visit( node )
442
+ end
443
+
444
+ end # class ServerDeclarationNodeVisitor
445
+
446
+
447
+ class SshKeyDeclarationNodeVisitor < ListVisitor
448
+
449
+ def initialize( configuration )
450
+ super
451
+ @sshkey = nil
452
+ end
453
+
454
+ def visit_SshKeyDeclarationNode( node )
455
+ name = node.values[0]
456
+ stmts = node.values[1]
457
+ @sshkey = BuildTool::SshKey.new( name )
458
+ configuration.add_sshkey( @sshkey )
459
+ visit_nodes( stmts )
460
+ return @sshkey
461
+ end
462
+
463
+ def visit_SshKeyFileNode( node )
464
+ @sshkey.file = File.expand_path( node.value )
465
+ end
466
+
467
+ end
468
+
469
+ end; end
470
+
471
+