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,84 @@
1
+ require 'optparse'
2
+ require 'erb'
3
+ require 'yaml'
4
+
5
+ require 'build-tool/commands'
6
+ require 'build-tool/recipe'
7
+ require 'build-tool/singleton'
8
+ require 'build-tool/cfg/parser'
9
+
10
+ $noop = false
11
+
12
+ module BuildTool
13
+
14
+ #
15
+ # The application class
16
+ #
17
+ class Application < Singleton
18
+
19
+ attr_reader :name
20
+ attr_reader :application_root
21
+ attr_reader :cli
22
+
23
+ def recipe
24
+ return @recipe if @recipe
25
+ configuration
26
+ @recipe
27
+ end
28
+
29
+ def initialize( name, application_root )
30
+ super()
31
+ @application_root = Pathname.new( application_root ).expand_path
32
+ @recipe = nil
33
+
34
+ # Determine the recipe name
35
+ @name = File.basename( name )
36
+ @name.sub!( "-build", "" )
37
+
38
+ # Create the shell
39
+ @cli = Commands::Shell.new
40
+ @cli.load_commands( @application_root.join( "lib/build-tool/commands" ), "Commands" )
41
+ end
42
+
43
+ def configuration
44
+ return @configuration if @configuration
45
+ logger.debug "Loading configuration for #{name}"
46
+ load_settings
47
+ @recipe = BuildTool::Recipe.new( @settings['RECIPE'] || name )
48
+ @configuration = @recipe.load( name, @settings['SETTINGS'] )
49
+ end
50
+
51
+ def load_settings
52
+ file = local_settings_file_path
53
+ if file.exist?
54
+ @settings = YAML.load_file( file )
55
+ else
56
+ raise ConfigurationError, "Configuration File #{file} does not exists!"
57
+ end
58
+ @settings
59
+ end
60
+
61
+
62
+ def local_settings_file_path
63
+ local_configuration_dir.join("#{name}.yaml")
64
+ end
65
+
66
+ # Return the local configuration dir. Makes sure the directory exists
67
+ # before returning it
68
+ def local_configuration_dir
69
+ return @local_configuration_dir if @local_configuration_dir
70
+ @local_configuration_dir = Pathname.new( "~/.build-tool" ).expand_path
71
+ if !@local_configuration_dir.exist?
72
+ FileUtils.mkdir_p( @local_configuration_dir )
73
+ end
74
+ @local_configuration_dir
75
+ end
76
+
77
+ def execute( args )
78
+ @cli.execute( args )
79
+ end
80
+
81
+ end # class Application
82
+
83
+ end
84
+
@@ -0,0 +1,60 @@
1
+ module BuildTool; module BuildSystem
2
+
3
+
4
+ #
5
+ #
6
+ #
7
+ class Autoconf < Base
8
+
9
+ #
10
+ ### ATTRIBUTES
11
+ #
12
+ def intitialize( *args )
13
+ super( *args )
14
+ end
15
+
16
+ def name
17
+ "autoconf"
18
+ end
19
+
20
+ #
21
+ ### METHODS
22
+ #
23
+
24
+ def[]( var )
25
+ case var
26
+
27
+ when 'CMAKE_CXXFLAGS'
28
+ return @options[var]
29
+
30
+ else
31
+ # *TODO* raise correct exception
32
+ raise NotImplementedError
33
+ end
34
+ end
35
+
36
+ def[]=( var, val )
37
+ case var
38
+
39
+ when 'CXXFLAGS'
40
+ @options[var] = val
41
+
42
+ else
43
+ # *TODO* raise correct exception
44
+ raise NotImplementedError
45
+ end
46
+
47
+ end
48
+
49
+ def install( fast )
50
+ make( "install" )
51
+ end
52
+
53
+ def install_fast_supported?
54
+ false
55
+ end
56
+
57
+ end # class Autoconf
58
+
59
+ end; end # module BuildTool::BuildSystem
60
+
@@ -0,0 +1,142 @@
1
+ require 'build-tool/errors'
2
+
3
+ module BuildTool; module BuildSystem
4
+
5
+ #
6
+ # Base class for all build system implementations
7
+ #
8
+ class Base
9
+
10
+ def initialize
11
+ @module = nil
12
+ @options = Hash.new
13
+ @out_of_source = true
14
+ end
15
+
16
+ #
17
+ ### ATTRIBUTES
18
+ #
19
+ attr_accessor :module
20
+ attr_accessor :out_of_source
21
+
22
+ def build_directory
23
+ @module.build_directory
24
+ end
25
+
26
+ def dup
27
+ cp = self.clone
28
+ cp.instance_variable_set( "@options", Marshal.load( Marshal.dump( @options ) ) )
29
+ cp
30
+ end
31
+
32
+ def env
33
+ @module.environment.values
34
+ end
35
+
36
+ def merge( other )
37
+ if name == other.name
38
+ @options.merge!( other.option_hash )
39
+ @out_of_source = other.out_of_source
40
+ else
41
+ raise ConfigurationError, "Can't merge build system #{name} with #{other.name}"
42
+ end
43
+ end
44
+
45
+ def option_hash
46
+ @options
47
+ end
48
+
49
+ def options
50
+ @options.keys
51
+ end
52
+
53
+ def install_prefix
54
+ return @module.install_prefix_required if @module
55
+ raise ConfigurationError, "No module set for build-system"
56
+ end
57
+
58
+ def source_directory
59
+ return @module.source_directory_required if @module
60
+ raise ConfigurationError, "No module set for build-system"
61
+ end
62
+
63
+ #
64
+ ### METHODS
65
+ #
66
+ #
67
+ ### VIRTUAL FUNCTIONS
68
+ #
69
+ for method in [
70
+ :configure,
71
+ :configured?,
72
+ :make,
73
+ :name,
74
+ :reconfigure,
75
+ :install,
76
+ :install_fast,
77
+ :install_fast_supported?
78
+
79
+ ] do
80
+ class_eval <<-EOS
81
+ def #{method}
82
+ raise NotImplementedError, "Method #{method} is not implemented for class #{self}"
83
+ end
84
+ EOS
85
+ end
86
+
87
+ def check_build_directory( create = false )
88
+ if !out_of_source
89
+ if File.exist? build_directory
90
+ if !File.symlink?( build_directory )
91
+ logger.warn( "Could not link build directory to source directory for inplace build of #{@module.name}." )
92
+ end
93
+ else
94
+ FileUtils.mkdir_p( Pathname.new( build_directory ).parent )
95
+ File.symlink( source_directory, build_directory )
96
+ end
97
+ else
98
+ if File.exist? build_directory
99
+ if File.directory? build_directory
100
+ return true
101
+ else
102
+ raise ConfigurationError, "Build directory #{build_directory} exists and is no directory!"
103
+ end
104
+ elsif create
105
+ FileUtils.mkdir_p( build_directory )
106
+ return true
107
+ else
108
+ return false
109
+ end
110
+ end
111
+ end
112
+
113
+ def remove_build_directory
114
+ self.class.execute "rm -rf #{build_directory}"
115
+ end
116
+
117
+ end # class Base
118
+
119
+ require 'build-tool/build-system/cmake'
120
+ require 'build-tool/build-system/custom'
121
+ require 'build-tool/build-system/qt'
122
+
123
+
124
+ def self.create( name )
125
+ case name
126
+
127
+ when 'cmake'
128
+ return CMake.new
129
+
130
+ when 'qt'
131
+ return Qt.new
132
+
133
+ when 'custom'
134
+ return Custom.new
135
+
136
+ else
137
+ raise ConfigurationError, "Buildsystem #{name} is not supported!"
138
+ end
139
+ end
140
+
141
+
142
+ end; end # module BuildTool::BuildSystem
@@ -0,0 +1,119 @@
1
+ require 'mj/tools/subprocess'
2
+ require 'build-tool/build-system/base'
3
+
4
+ module BuildTool; module BuildSystem
5
+
6
+
7
+ #
8
+ #
9
+ #
10
+ class CMake < Base
11
+
12
+ include MJ::Tools::SubProcess
13
+
14
+ class MakeError < BuildTool::Error; end
15
+ class CMakeError < BuildTool::Error; end
16
+
17
+ def initialize( *args )
18
+ super( *args )
19
+ end
20
+
21
+ #
22
+ ### ATTRIBUTES
23
+ #
24
+
25
+ # Check if the module is configured
26
+ def configured?
27
+ Pathname.new( build_directory ).join( 'Makefile' ).exist?
28
+ end
29
+
30
+ def name
31
+ "cmake"
32
+ end
33
+
34
+ #
35
+ ### METHODS
36
+ #
37
+
38
+ def[]( var )
39
+ if @options.has_key? var
40
+ return @options[var]
41
+ end
42
+
43
+ case var
44
+
45
+ when 'CMAKE_BUILD_TYPE', 'CMAKE_CXXFLAGS', 'CMAKE_VERBOSE_MAKEFILE', 'LIB_SUFFIX'
46
+ return ""
47
+
48
+ else
49
+ # *TODO* raise correct exception
50
+ raise NotImplementedError
51
+
52
+ end
53
+ end
54
+
55
+ def[]=( var, val )
56
+ @options[var] = val
57
+ end
58
+
59
+ # Configure the module
60
+ def reconfigure()
61
+ if File.exist?( "#{build_directory}/CMakeCache.txt" )
62
+ return false if self.class.execute( "rm -f #{build_directory}/CMakeCache.txt" ) != 0
63
+ end
64
+ configure
65
+ end
66
+
67
+ # Execute a cmake command in the context of the build directory
68
+ def cmake( command, wd = build_directory )
69
+ rc = self.class.execute "cmake #{command}", wd, env
70
+ if rc != 0
71
+ raise CMakeError, "cmake failed with error #{rc}!"
72
+ end
73
+ rc
74
+ end
75
+
76
+ def configure
77
+ check_build_directory( true )
78
+ opt = option_string
79
+ opt += " -DCMAKE_INSTALL_PREFIX=#{install_prefix.to_s}" if install_prefix
80
+ rc = cmake "#{source_directory} #{opt}"
81
+ rc
82
+ end
83
+
84
+ def do_make( target = nil )
85
+ rc = self.class.execute( "make #{target ? target : "" }", build_directory, self.module.environment.values )
86
+ if rc != 0
87
+ raise MakeError, "make #{target || "" } failed with error code #{rc}";
88
+ end
89
+ rc
90
+ end
91
+
92
+ def install( fast )
93
+ if fast
94
+ make( "install/fast" )
95
+ else
96
+ make( "install" )
97
+ end
98
+ end
99
+
100
+ def install_fast_supported?
101
+ true
102
+ end
103
+
104
+ def make( target = nil )
105
+ do_make( target )
106
+ end
107
+
108
+ def option_string
109
+ arr = []
110
+ @options.each do |var, val|
111
+ arr << "-D#{var}='#{val}'"
112
+ end
113
+ arr.join(" ")
114
+ end
115
+
116
+ end # class CMake
117
+
118
+
119
+ end; end # module BuildTool::BuildSystem
@@ -0,0 +1,115 @@
1
+ require 'mj/tools/subprocess'
2
+ require 'build-tool/build-system/base'
3
+
4
+ module BuildTool; module BuildSystem
5
+
6
+
7
+ #
8
+ # Custom Build system.
9
+ #
10
+ # Uses scripts do to the actual work.
11
+ #
12
+ class Custom < Base
13
+
14
+ include MJ::Tools::SubProcess
15
+
16
+ class CustomError < BuildTool::Error; end
17
+
18
+ def initialize( *args )
19
+ super( *args )
20
+ end
21
+
22
+ #
23
+ ### ATTRIBUTES
24
+ #
25
+
26
+ # Check if the module is configured
27
+ def configured?
28
+ end
29
+
30
+ def name
31
+ "custom"
32
+ end
33
+
34
+ #
35
+ ### METHODS
36
+ #
37
+
38
+ def[]( var )
39
+ if @options.has_key? var
40
+ return @options[var]
41
+ end
42
+
43
+ # case var
44
+
45
+ # else
46
+ # *TODO* raise correct exception
47
+ raise NotImplementedError
48
+
49
+ # end
50
+ end
51
+
52
+ def[]=( var, val )
53
+ # case var
54
+
55
+ # else
56
+ # if var.start_with?( 'WITH_' )
57
+ # @options[var] = val
58
+ # else
59
+ # *TODO* raise correct exception
60
+ raise NotImplementedError
61
+ # end
62
+ # end
63
+ end
64
+
65
+ # Configure the module
66
+ def reconfigure()
67
+ raise NotImplementedError
68
+ end
69
+
70
+ def configure
71
+ check_build_directory( true )
72
+ execute( "configure.sh" )
73
+ end
74
+
75
+ def execute( script )
76
+ path = self.recipe.find_first_config_file( "custom/%s/%s" % [ self.module.name, script.to_s ] )
77
+ if path.nil?
78
+ raise CustomError, "Script configure.sh for %s not found!" % self.module.name
79
+ end
80
+ if !path.executable?
81
+ raise CustomError, "Script %s not executable!" % path.to_s
82
+ end
83
+ return self.module.environment.execute(
84
+ "%s %s" % [ path.to_s, source_directory ],
85
+ build_directory )
86
+ end
87
+
88
+ def install( fast )
89
+ execute( "install.sh" )
90
+ end
91
+
92
+ def install_fast_supported?
93
+ false
94
+ end
95
+
96
+ def make( target = nil )
97
+ execute( "compile.sh" )
98
+ end
99
+
100
+ def option_string
101
+ arr = []
102
+ @options.each do |var, val|
103
+ arr << "-D#{var}='#{val}'"
104
+ end
105
+ arr.join(" ")
106
+ end
107
+
108
+ def recipe
109
+ Application::instance.recipe
110
+ end
111
+
112
+ end # class Custom
113
+
114
+ end; end # module BuildTool::BuildSystem
115
+