build-tool 0.5.7 → 0.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/.gitignore +1 -0
  2. data/.rvmrc +1 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +5 -0
  5. data/Gemfile.lock +56 -0
  6. data/History.txt +64 -0
  7. data/README.txt +0 -7
  8. data/Rakefile +8 -56
  9. data/bin/build-tool +4 -1
  10. data/build-tool.gemspec +62 -0
  11. data/db/migrations/20110703074000_add_command_logs.rb +17 -0
  12. data/db/migrations/20110703075000_add_module_logs.rb +20 -0
  13. data/db/migrations/20110815170000_add_features.rb +17 -0
  14. data/db/migrations/20120103204700_add_modules.rb +17 -0
  15. data/db/migrations/20120106181200_add_settings.rb +18 -0
  16. data/lib/build-tool.rb +3 -4
  17. data/lib/build-tool/application.rb +127 -37
  18. data/lib/build-tool/build-system/autoconf.rb +2 -8
  19. data/lib/build-tool/build-system/base.rb +12 -4
  20. data/lib/build-tool/build-system/cmake.rb +2 -0
  21. data/lib/build-tool/build-system/custom.rb +2 -0
  22. data/lib/build-tool/build-system/kdel10n.rb +2 -0
  23. data/lib/build-tool/build-system/make.rb +2 -0
  24. data/lib/build-tool/build-system/none.rb +2 -0
  25. data/lib/build-tool/build-system/qmake.rb +2 -0
  26. data/lib/build-tool/build-system/qt.rb +4 -0
  27. data/lib/build-tool/cfg/lexer.rex +40 -8
  28. data/lib/build-tool/cfg/lexer_base.rb +3 -1
  29. data/lib/build-tool/cfg/node.rb +17 -1
  30. data/lib/build-tool/cfg/parser.y +92 -10
  31. data/lib/build-tool/cfg/visitor.rb +202 -78
  32. data/lib/build-tool/command_actions.rb +26 -10
  33. data/lib/build-tool/commands.rb +289 -197
  34. data/lib/build-tool/commands/build.rb +13 -9
  35. data/lib/build-tool/commands/configuration.rb +25 -0
  36. data/lib/build-tool/commands/configuration/edit.rb +42 -0
  37. data/lib/build-tool/commands/configuration/list.rb +48 -0
  38. data/lib/build-tool/commands/configure.rb +9 -5
  39. data/lib/build-tool/commands/ctags.rb +8 -3
  40. data/lib/build-tool/commands/environments.rb +2 -4
  41. data/lib/build-tool/commands/environments/list.rb +13 -10
  42. data/lib/build-tool/commands/environments/set.rb +5 -1
  43. data/lib/build-tool/commands/features.rb +24 -0
  44. data/lib/build-tool/commands/features/disable.rb +70 -0
  45. data/lib/build-tool/commands/features/enable.rb +66 -0
  46. data/lib/build-tool/commands/features/list.rb +92 -0
  47. data/lib/build-tool/commands/fetch.rb +9 -3
  48. data/lib/build-tool/commands/files.rb +9 -5
  49. data/lib/build-tool/commands/gc.rb +48 -15
  50. data/lib/build-tool/commands/history.rb +21 -16
  51. data/lib/build-tool/commands/info.rb +16 -13
  52. data/lib/build-tool/commands/install.rb +8 -4
  53. data/lib/build-tool/commands/modules.rb +2 -4
  54. data/lib/build-tool/commands/modules/cleanup.rb +52 -0
  55. data/lib/build-tool/commands/modules/disable.rb +95 -0
  56. data/lib/build-tool/commands/modules/enable.rb +52 -0
  57. data/lib/build-tool/commands/modules/info.rb +44 -35
  58. data/lib/build-tool/commands/modules/list.rb +67 -15
  59. data/lib/build-tool/commands/modules/shell.rb +8 -2
  60. data/lib/build-tool/commands/rebase.rb +15 -7
  61. data/lib/build-tool/commands/recipes.rb +2 -4
  62. data/lib/build-tool/commands/recipes/add.rb +16 -2
  63. data/lib/build-tool/commands/recipes/edit.rb +72 -0
  64. data/lib/build-tool/commands/recipes/incoming.rb +11 -7
  65. data/lib/build-tool/commands/recipes/info.rb +12 -8
  66. data/lib/build-tool/commands/recipes/install.rb +37 -42
  67. data/lib/build-tool/commands/recipes/list.rb +6 -2
  68. data/lib/build-tool/configuration.rb +88 -3
  69. data/lib/build-tool/environment.rb +2 -0
  70. data/lib/build-tool/errors.rb +5 -0
  71. data/lib/build-tool/history.rb +3 -181
  72. data/lib/build-tool/model/command_log.rb +93 -0
  73. data/lib/build-tool/model/feature.rb +80 -0
  74. data/lib/build-tool/{module.rb → model/module.rb} +110 -29
  75. data/lib/build-tool/model/module_log.rb +64 -0
  76. data/lib/build-tool/model/setting.rb +84 -0
  77. data/lib/build-tool/recipe.rb +40 -18
  78. data/lib/build-tool/repository.rb +39 -33
  79. data/lib/build-tool/server.rb +27 -3
  80. data/lib/build-tool/singleton.rb +2 -0
  81. data/lib/build-tool/sshkey.rb +2 -0
  82. data/lib/build-tool/state_helper.rb +64 -0
  83. data/lib/build-tool/vcs/archive.rb +3 -1
  84. data/lib/build-tool/vcs/base.rb +13 -0
  85. data/lib/build-tool/vcs/git-svn.rb +36 -14
  86. data/lib/build-tool/vcs/git.rb +180 -44
  87. data/lib/build-tool/vcs/mercurial.rb +25 -13
  88. data/lib/build-tool/vcs/svn.rb +20 -15
  89. data/lib/build-tool/version.rb +30 -0
  90. data/lib/mj/error.rb +2 -0
  91. data/lib/mj/logging.rb +2 -0
  92. data/lib/mj/mixins/inherited_attributes.rb +73 -0
  93. data/lib/mj/tools/editor.rb +34 -0
  94. data/lib/mj/tools/ssh.rb +2 -0
  95. data/lib/mj/tools/subprocess.rb +2 -1
  96. data/lib/mj/vcs/git.rb +14 -2
  97. data/lib/mj/visitor.rb +22 -0
  98. data/tasks/db.rake +36 -0
  99. data/tasks/racc.rake +14 -0
  100. data/tasks/rdoc.rake +8 -0
  101. data/tasks/rexical.rake +14 -0
  102. data/tasks/test.rake +21 -0
  103. data/test/integration/history_test.rb +88 -0
  104. data/test/integration/parser_configuration.rb +36 -0
  105. data/test/integration/parser_environment_parser.rb +156 -0
  106. data/test/integration/parser_feature_test.rb +75 -0
  107. data/test/integration/parser_git-svn_test.rb +92 -0
  108. data/test/integration/parser_git_test.rb +97 -0
  109. data/test/integration/parser_mercurial_test.rb +77 -0
  110. data/test/integration/parser_module_test.rb +103 -0
  111. data/test/integration/parser_svn_test.rb +92 -0
  112. data/test/integration/parser_test.rb +73 -0
  113. data/test/test_helper.rb +61 -0
  114. data/test/unit/configuration_test.rb +36 -0
  115. data/test/unit/git_configuration_test.rb +163 -0
  116. data/test/unit/git_svn_configuration_test.rb +240 -0
  117. data/test/unit/mercurial_configuration_test.rb +64 -0
  118. data/test/unit/model/command_log_test.rb +103 -0
  119. data/test/unit/model/feature_test.rb +29 -0
  120. data/test/unit/model/module_log_test.rb +70 -0
  121. data/test/unit/model/module_test.rb +32 -0
  122. data/test/unit/repository_test.rb +110 -0
  123. data/test/unit/server_test.rb +66 -0
  124. data/test/unit/svn_configuration_test.rb +90 -0
  125. metadata +134 -93
  126. data/Manifest.txt +0 -80
  127. data/db/migrations/001_command_histories.rb +0 -20
  128. data/db/migrations/002_module_events.rb +0 -24
  129. data/db/migrations/003_command_histories_add_logfile.rb +0 -19
  130. data/lib/build-tool/GUI.rb +0 -360
  131. data/lib/build-tool/commands/help.rb +0 -22
  132. data/lib/build-tool/commands/lsfeatures.rb +0 -76
  133. data/lib/build-tool/feature.rb +0 -47
@@ -1,5 +1,9 @@
1
+ # -*- coding: UTF-8 -*-
2
+
1
3
  require 'yaml'
2
4
 
5
+ require 'build-tool/cfg/parser'
6
+
3
7
  module BuildTool
4
8
 
5
9
  #
@@ -9,15 +13,16 @@ class Recipe
9
13
 
10
14
  attr_accessor :name
11
15
  attr_accessor :global_path
12
- attr_reader :settings
13
16
 
14
- def initialize( name )
17
+ def initialize( name, find = true )
15
18
  raise StandardError if name.nil?
16
19
  @name = name
17
20
  @metainfo_loaded = false
18
21
  @short_description = "no description"
19
22
  @long_description = "no description"
20
- @global_path = Recipe.find_recipe( @name )
23
+ if find
24
+ @global_path = Recipe.find_recipe( @name )
25
+ end
21
26
  end
22
27
 
23
28
  def browse_repository
@@ -53,7 +58,7 @@ def long_description
53
58
 
54
59
  def load_metainfo
55
60
  begin
56
- file = YAML.load_file( metainfo_file_path )
61
+ file = YAML.load( File.open( metainfo_file_path, 'r:UTF-8' ) )
57
62
  @long_description = file['LONG']
58
63
  @short_description = file['SHORT']
59
64
  @website = file['WEBSITE']
@@ -63,17 +68,14 @@ def load_metainfo
63
68
  logger.verbose "No description file found for recipe #{name}."
64
69
  @short_description = "No description file provided!"
65
70
  rescue ArgumentError => e
66
- logger.verbose "Invalid description file found for for recipe #{name}."
71
+ logger.verbose "Invalid description file found for recipe #{name}."
67
72
  @short_description = "Description File invalid!"
68
73
  end
69
74
  @metainfo_loaded = true
70
75
  end
71
76
 
72
- def load( local_config_name, settings )
77
+ def load( local_config_name, configuration )
73
78
  @local_config_name = local_config_name
74
- raise StandardError, "Usage: recipe.load( settings )" if settings.nil?
75
- @settings = settings
76
- configuration = Configuration.new( self )
77
79
 
78
80
  # Load the recipe
79
81
  logger.debug "Loading #{global_config_file_path( "recipe" )}"
@@ -83,29 +85,49 @@ def load( local_config_name, settings )
83
85
  local_config_file = local_config_file_path( "recipe" )
84
86
  if local_config_file.exist?
85
87
  logger.debug "Loading #{local_config_file}"
86
- load_from_file( local_config_file, configuration )
88
+ load_from_file( local_config_file, configuration, false )
87
89
  end
88
- configuration
90
+
91
+ return configuration
89
92
  end
90
93
 
91
- def load_from_file( file, configuration )
94
+ def load_from_file( file, configuration, global=true )
92
95
  # Get the file content
93
- recipe = File.read( file )
96
+ recipe = File.open( file, 'r:UTF-8' ).read()
97
+
94
98
  # Create the parser
95
- parser = Cfg::Parser.new( configuration )
99
+ parser = Cfg::Parser.new( configuration, global )
96
100
  # Create the ERB
97
101
  erb = ERB.new( recipe, nil, "%<>" )
98
102
  # Fill the env for ERB
103
+ settings = configuration.settings
99
104
  b = binding
100
- settings = @settings
101
105
  # Call the parser with the ERBed file content and return the
102
106
  # result
103
107
  conf = parser.parse_string( erb.result(b), file )
104
108
  end
105
109
 
106
- def local_config_file_path(name)
107
- Pathname.new( BuildTool::Application::instance.local_configuration_dir ).
108
- join( @local_config_name, name)
110
+ def load_from_string( recipe, configuration, global=true )
111
+ # Create the parser
112
+ parser = Cfg::Parser.new( configuration, global )
113
+ # Create the ERB
114
+ erb = ERB.new( recipe, nil, "%<>" )
115
+ # Fill the env for ERB
116
+ settings = configuration.settings
117
+ b = binding
118
+ # Call the parser with the ERBed file content and return the
119
+ # result
120
+ conf = parser.parse_string( erb.result(b), '<string>' )
121
+ end
122
+
123
+ def local_path()
124
+ Pathname.new(
125
+ BuildTool::Application::instance.local_configuration_dir ).
126
+ join( @local_config_name )
127
+ end
128
+
129
+ def local_config_file_path( name )
130
+ local_path().join( name )
109
131
  end
110
132
 
111
133
  def global_config_file_path( name )
@@ -1,65 +1,71 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'mj/mixins/inherited_attributes'
1
4
  require 'build-tool/errors'
2
5
 
6
+
7
+
3
8
  module BuildTool
4
9
 
5
10
  # Encapsulates a source code repository.
6
11
  class Repository
7
12
 
13
+ include MJ::Mixins::InheritedAttributes
14
+
8
15
  # Repository name
9
16
  attr_reader :name
10
17
 
11
- # The server this repository is hosted
12
- attr_accessor :server
18
+ # The server the repository is located on.
19
+ # @return [Server] the server.
20
+ # @macro [attach] inherited_attr_accessor
21
+ # @attribute [rw] $1
22
+ inherited_attr_accessor :server
13
23
 
14
- # The relative path on the server
15
- attr_accessor :path
24
+ # The path on the server.
25
+ # @return [String] the path.
26
+ inherited_attr_accessor :path
16
27
 
17
- # The relative path on the server
18
- attr_accessor :user
28
+ # The user required to connect to the repository.
29
+ # @return [String] the user name.
30
+ inherited_attr_accessor :user
19
31
 
20
- # The associated ssh-key
32
+ # Return the ssh key needed to access this repository. If the repository has no key we
33
+ # check the associated server. After that the parent.
34
+ def sshkey
35
+ # 1. Our SSH-Key
36
+ return @sshkey if @sshkey
37
+ # 2. Our Servers SSH-Key
38
+ return server.sshkey if @server
39
+ # 3. Our Parents SSH-Key
40
+ return parent.sshkey if @parent
41
+ # 4. Nothing
42
+ return nil
43
+ end
21
44
  attr_writer :sshkey
22
45
 
23
- # Create a repository
46
+ # Create a repository object
47
+ # @param [String] name The unique name to use for this repository.
24
48
  def initialize(name)
49
+ super
25
50
  if name.nil?
26
51
  raise StandardError, "The repository name has to be set"
27
52
  end
28
53
  @name = name
29
54
  @server = nil
30
55
  @sshkey = nil
56
+ @path = nil
57
+ @user = nil
31
58
  end
32
59
 
33
- # Return the ssh key needed to access this repository. If the repository has no key we
34
- # check the associated server.
35
- def sshkey
36
- return @sshkey if @sshkey
37
-
38
- if !server
39
- return nil
40
- end
41
-
42
- return server.sshkey
43
- end
44
-
60
+ # Returns the url for this repository.
61
+ # @return [String] the url
62
+ # @raise [ConfigurationError] if no server is set configured.
45
63
  def url
46
64
  if !server
47
65
  raise ConfigurationError, "No server specified for repository #{name}"
48
66
  end
49
- if !server.host
50
- raise ConfigurationError, "No host specified for server #{server.name}"
51
- end
52
67
 
53
- url = server.host
54
- if server.path
55
- url = "#{url}/#{server.path}"
56
- end
57
- if user
58
- url = "#{user}@#{url}"
59
- end
60
- if server.protocol
61
- url = "#{server.protocol}://#{url}"
62
- end
68
+ url = server.url( user )
63
69
  if path
64
70
  url = "#{url}/#{path}"
65
71
  end
@@ -1,3 +1,7 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'uri'
4
+
1
5
  module BuildTool
2
6
 
3
7
  class Server
@@ -18,24 +22,44 @@ class Server
18
22
  attr_accessor :sshkey
19
23
 
20
24
  # Create a repository
21
- def initialize(name)
25
+ def initialize( name, theurl = nil )
26
+ @host = nil
27
+ @name = nil
28
+ @path = nil
29
+ @protocol = nil
30
+ @sshkey = nil
22
31
  if name.nil?
23
32
  raise StandardError, "The server name has to be set"
24
33
  end
25
34
  @name = name
35
+ if theurl
36
+ uri = URI.parse( theurl )
37
+ @host = uri.host
38
+ @protocol = uri.scheme
39
+ if not uri.path.empty?
40
+ @path = uri.path
41
+ end
42
+ end
26
43
  end
27
44
 
28
- def url
45
+ def url( user = nil )
29
46
  if !host
30
47
  raise ConfigurationError, "No host specified for server #{name}"
31
48
  end
32
49
 
33
50
  url = host
51
+ if user
52
+ url = "#{user}@#{url}"
53
+ end
34
54
  if protocol
35
55
  url = "#{protocol}://#{url}"
36
56
  end
37
57
  if path
38
- url = "#{url}/#{path}"
58
+ if path[0] == '/'
59
+ url = "#{url}#{path}"
60
+ else
61
+ url = "#{url}/#{path}"
62
+ end
39
63
  end
40
64
  url
41
65
  end
@@ -1,3 +1,5 @@
1
+ # -*- coding: UTF-8 -*-
2
+
1
3
  module BuildTool
2
4
 
3
5
  class Singleton
@@ -1,3 +1,5 @@
1
+ # -*- coding: UTF-8 -*-
2
+
1
3
  module BuildTool
2
4
  #
3
5
  # Encapsulates a ssh key
@@ -0,0 +1,64 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'ansi'
4
+
5
+ module BuildTool
6
+
7
+ module StateHelper
8
+
9
+ # Needed for both Module and Command History
10
+ STARTED = 0
11
+ CANCELED_BY_USER = 1
12
+ FINISHED_SUCCESSFUL = 2
13
+ FINISHED_WITH_ERRORS = 3
14
+
15
+ def state_str
16
+ self.class.state_str( self.state )
17
+ end
18
+
19
+ def state_char
20
+ self.class.state_char( self.state )
21
+ end
22
+
23
+ module ClassMethods
24
+
25
+ def state_str( state )
26
+ case state
27
+ when STARTED
28
+ "STARTED"
29
+ when CANCELED_BY_USER
30
+ ANSI::Code.red { "CANCELED" }
31
+ when FINISHED_SUCCESSFUL
32
+ ANSI::Code.green { "SUCCESS" }
33
+ when FINISHED_WITH_ERRORS
34
+ ANSI::Code.red { "ERRORS" }
35
+ else
36
+ "#{state.to_s}?"
37
+ end
38
+ end
39
+
40
+ def state_char( state )
41
+ case state
42
+ when STARTED
43
+ "R"
44
+ when CANCELED_BY_USER
45
+ ANSI::Code.red { "C" }
46
+ when FINISHED_SUCCESSFUL
47
+ ANSI::Code.green { "S" }
48
+ when FINISHED_WITH_ERRORS
49
+ ANSI::Code.red { "E" }
50
+ else
51
+ "#{state.to_s}?"
52
+ end
53
+ end
54
+ end
55
+
56
+ def self.included( klass )
57
+ klass.extend ClassMethods
58
+ end
59
+
60
+ end
61
+
62
+
63
+ end # module BuildTool
64
+
@@ -1,3 +1,5 @@
1
+ # -*- coding: UTF-8 -*-
2
+
1
3
  require 'open-uri'
2
4
 
3
5
  require 'build-tool/vcs/base'
@@ -159,7 +161,7 @@ def guess_top_level_directory
159
161
  return topdir
160
162
  end
161
163
 
162
- def rebase
164
+ def rebase( verbose = false )
163
165
 
164
166
  # Check if the archive is already downloaded
165
167
  if !File.exist? archive_local_path
@@ -1,13 +1,26 @@
1
+ # -*- coding: UTF-8 -*-
2
+
1
3
  require 'mj/tools/subprocess.rb'
4
+ require 'mj/tools/ssh.rb'
2
5
 
3
6
  require 'build-tool/errors'
4
7
 
5
8
  module BuildTool; module VCS
6
9
 
10
+ # Base class for version control system configurations.
11
+ #
12
+ # @abstract
13
+ # @attr_reader [String] name returns the name of the vcs.
7
14
  class BaseConfiguration
8
15
 
16
+ # The associated module of this configuration object.
9
17
  attr_reader :module
10
18
 
19
+ # The name of the version control system
20
+ def name
21
+ raise StandardError, "#{self.class}: override name!"
22
+ end
23
+
11
24
  def initialize
12
25
  @module = nil
13
26
  end
@@ -1,3 +1,5 @@
1
+ # -*- coding: UTF-8 -*-
2
+
1
3
  require 'build-tool/vcs/svn'
2
4
  require 'build-tool/vcs/git'
3
5
 
@@ -15,6 +17,13 @@ def name
15
17
  def initialize
16
18
  super
17
19
  @externals = {}
20
+ @repository = nil
21
+ @remote_path = nil
22
+ end
23
+
24
+ def merged_externals
25
+ return parent.merged_externals.merge( @externals ) if @parent # We have a parent. Merge with it
26
+ return @externals # No parent, no global. Just us
18
27
  end
19
28
 
20
29
  def vcs( mod )
@@ -34,22 +43,22 @@ def copy_configuration( other )
34
43
 
35
44
  attr_writer :repository
36
45
  def repository
37
- if @repository.nil?
38
- raise ConfigurationError, "No repository configured for module #{self.module.name}."
39
- end
40
- @repository
46
+ return @repository if @repository # Our repository
47
+ return parent.repository if @parent # Our parents repository
48
+ raise ConfigurationError, "No repository configured for module #{self.module ? self.module.name : 'unknown' }."
41
49
  end
42
50
 
43
51
  attr_writer :remote_path
44
52
  def remote_path
45
- if @remote_path.nil?
46
- return @module.name
47
- end
48
- @remote_path
53
+ return @remote_path if @remote_path
54
+ return parent.remote_path if @parent
55
+ return @module.name
49
56
  end
50
57
 
51
- def track_branch
52
- "git-svn"
58
+ def track
59
+ return @track if @track # Our track
60
+ return parent.track if @parent # Out parents track
61
+ "remotes/git-svn"
53
62
  end
54
63
  end
55
64
 
@@ -111,6 +120,7 @@ def clone
111
120
  if 0 != ( git_svn "init #{config.repository.url}/#{remote_path}" )
112
121
  raise GitSvnError, "Error while initializing the repo `git svn init '#{config.repository}/#{remote_path}'`: #{$?}"
113
122
  end
123
+
114
124
  fetch( "HEAD" )
115
125
  end
116
126
 
@@ -124,6 +134,9 @@ def configure
124
134
  def fetch( revision = nil )
125
135
  if !checkedout? and !$noop # Beware of looping
126
136
  clone
137
+ else
138
+ # clone() calls those methods.
139
+ git.check_config
127
140
  end
128
141
  if revision
129
142
  cmd = "fetch -r#{revision}"
@@ -157,9 +170,18 @@ def prepare_for_fetch
157
170
  return check_for_sshkey( config.repository.sshkey )
158
171
  end
159
172
 
160
- def rebase
161
- if 0 != ( git.git "rebase #{config.track_branch}" )
162
- raise GitSvnError, "Error while rebasing the repo with `#{config.track_branch}': #{$?}"
173
+ def rebase( verbose = false )
174
+ git.check_config
175
+ remote_branch = "#{config.track_branch}"
176
+
177
+ if verbose
178
+ git.git('log --first-parent HEAD..%s' % remote_branch ) do |line|
179
+ logger.info( line )
180
+ end
181
+ end
182
+
183
+ if 0 != ( git.git "rebase #{remote_branch}" )
184
+ raise GitSvnError, "Error while rebasing the repo with `#{remote_branch}': #{$?}"
163
185
  end
164
186
  end
165
187
 
@@ -179,7 +201,7 @@ def remote_path
179
201
  end
180
202
 
181
203
  def update_externals
182
- config.externals.each do |local, remote|
204
+ config.merged_externals.each do |local, remote|
183
205
  VCS::Svn::svn( "checkout #{remote}@HEAD #{local}", wd = local_path )
184
206
  end
185
207
  end