build-tool 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. data.tar.gz.sig +3 -0
  2. data/History.txt +7 -0
  3. data/Manifest.txt +51 -0
  4. data/PostInstall.txt +3 -0
  5. data/README.rdoc +55 -0
  6. data/Rakefile +30 -0
  7. data/TODO +2 -0
  8. data/bin/kde-build.rb +21 -0
  9. data/config/website.yml +2 -0
  10. data/config/website.yml.sample +2 -0
  11. data/lib/kde-build.rb +18 -0
  12. data/lib/kde-build/application.rb +258 -0
  13. data/lib/kde-build/build_system.rb +26 -0
  14. data/lib/kde-build/build_system/autoconf.rb +109 -0
  15. data/lib/kde-build/build_system/base.rb +132 -0
  16. data/lib/kde-build/build_system/cmake.rb +82 -0
  17. data/lib/kde-build/build_system/qtcopy.rb +125 -0
  18. data/lib/kde-build/command.rb +30 -0
  19. data/lib/kde-build/command/build.rb +119 -0
  20. data/lib/kde-build/command/fetch.rb +28 -0
  21. data/lib/kde-build/command/help.rb +71 -0
  22. data/lib/kde-build/command/info.rb +42 -0
  23. data/lib/kde-build/command/version.rb +43 -0
  24. data/lib/kde-build/configuration.rb +186 -0
  25. data/lib/kde-build/exception.rb +6 -0
  26. data/lib/kde-build/metaaid.rb +18 -0
  27. data/lib/kde-build/module.rb +203 -0
  28. data/lib/kde-build/module_configuration.rb +107 -0
  29. data/lib/kde-build/moduleregistry.rb +85 -0
  30. data/lib/kde-build/subprocess.rb +82 -0
  31. data/lib/kde-build/tools/ctags.rb +34 -0
  32. data/lib/kde-build/tools/logging.rb +49 -0
  33. data/lib/kde-build/tools/make.rb +58 -0
  34. data/lib/kde-build/tools/ssh.rb +47 -0
  35. data/lib/kde-build/vcs.rb +26 -0
  36. data/lib/kde-build/vcs/base.rb +81 -0
  37. data/lib/kde-build/vcs/git-svn.rb +133 -0
  38. data/lib/kde-build/vcs/git.rb +96 -0
  39. data/lib/kde-build/vcs/svn.rb +105 -0
  40. data/script/console +10 -0
  41. data/script/destroy +14 -0
  42. data/script/generate +14 -0
  43. data/script/txt2html +71 -0
  44. data/test.yaml.tmpl +552 -0
  45. data/test/test_helper.rb +12 -0
  46. data/test/test_kde-build.rb +11 -0
  47. data/test/test_vcs_svn.rb +44 -0
  48. data/website/index.html +84 -0
  49. data/website/index.txt +59 -0
  50. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  51. data/website/stylesheets/screen.css +159 -0
  52. data/website/template.html.erb +50 -0
  53. metadata +171 -0
  54. metadata.gz.sig +0 -0
@@ -0,0 +1,26 @@
1
+ require 'kde-build/build_system/cmake'
2
+ require 'kde-build/build_system/qtcopy'
3
+ require 'kde-build/build_system/autoconf'
4
+
5
+ module BuildTool; module BuildSystem
6
+
7
+ @mapping = {
8
+ 'cmake' => CMake,
9
+ 'qtcopy' => QtCopy,
10
+ 'autoconf' => AutoConf
11
+ }
12
+
13
+ module_function
14
+
15
+ def available
16
+ @mapping.keys
17
+ end
18
+
19
+ def get( name )
20
+ if !available.include? name
21
+ throw :todo
22
+ end
23
+ @mapping[name]
24
+ end
25
+
26
+ end; end
@@ -0,0 +1,109 @@
1
+ require 'kde-build/build_system/base'
2
+
3
+ require 'kde-build/tools/make'
4
+
5
+ module BuildTool
6
+
7
+ module BuildSystem
8
+
9
+ class AutoConfError < Exception
10
+ end
11
+
12
+ class AutoConfConfiguration < BaseConfiguration
13
+
14
+ option( 'options', "Command line options for autoconf" )
15
+ option( 'autogen-options', "Command line options for autogen.sh." ).required
16
+
17
+ def initialize
18
+ super
19
+ self.name = "autoconf"
20
+ end
21
+
22
+ end
23
+
24
+ class AutoConf < Base
25
+
26
+ def initialize( mod )
27
+ super
28
+ end
29
+
30
+ def self.config
31
+ AutoConfConfiguration
32
+ end
33
+
34
+ def self.guess( path )
35
+ return File.exist? "#{path}/configure.in"
36
+ end
37
+
38
+
39
+ def bootstrap_with_autogen
40
+ # First check if autogen contains a configure call
41
+ puts configuration.class
42
+ puts configuration.methods(false).inspect
43
+ rc = self.class.execute( "#{source_directory}/autogen.sh #{configuration.autogen_options}", env )
44
+ end
45
+
46
+ def bootstrap_with_bootstrap
47
+ raise NotImplementedError, "#{self.class}.bootstrap_with_bootstrap"
48
+ end
49
+
50
+ def bootstrap_with_makefile
51
+ raise NotImplementedError, "#{self.class}.bootstrap_with_Makefile"
52
+ end
53
+
54
+ def bootstrap( force = false )
55
+ # Check if we need to bootstrap
56
+ if !force and File.exist? "#{source_directory}/configure"
57
+ return
58
+ end
59
+ if File.exist? "#{source_directory}/bootstrap"
60
+ return bootstrap_with_bootstrap
61
+ elsif File.exist? "#{source_directory}/autogen.sh"
62
+ return bootstrap_with_autogen
63
+ elsif File.exist? "#{source_directory}/Makefile.cvs"
64
+ return bootstrap_with_makefile
65
+ end
66
+
67
+ throw :AUTOCONF_FAILED_TO_BOOTSTRAP
68
+ end
69
+
70
+ def reconfigure
71
+ make "clean"
72
+ bootstrap true
73
+ configure
74
+ end
75
+
76
+ def configure
77
+ bootstrap
78
+ check_build_directory( true )
79
+ opt = options || ""
80
+ opt += " --prefix=#{prefix}" if prefix
81
+ rc = self.class.execute( "#{source_directory}/configure #{opt}", build_directory, env )
82
+ rc
83
+ end
84
+
85
+ def configured?
86
+ File.exist? "#{build_directory}/config.cache"
87
+ end
88
+
89
+ def make( command, wd = build_directory )
90
+ BuildTool::Make.new.make "#{command}", wd
91
+ end
92
+
93
+ def name
94
+ "AutoConf"
95
+ end
96
+
97
+ def options
98
+ configuration.options
99
+ end
100
+
101
+ Registry.register( 'AutoConf', AutoConf )
102
+
103
+ end
104
+
105
+ end
106
+
107
+ end
108
+
109
+
@@ -0,0 +1,132 @@
1
+ require 'kde-build/subprocess'
2
+ require 'kde-build/configuration'
3
+
4
+ require 'singleton'
5
+ require 'pathname'
6
+
7
+ module BuildTool
8
+
9
+ module BuildSystem
10
+
11
+ class Registry
12
+
13
+ include Singleton
14
+
15
+ @@tools = Hash.new
16
+
17
+ def self.register( name, klass )
18
+ @@tools[name] = klass
19
+ end
20
+
21
+
22
+ def self.guess( source_directory )
23
+ @@tools.each do |name, bt|
24
+ return bt if bt.guess( source_directory )
25
+ end
26
+ return nil
27
+ end
28
+
29
+ end
30
+
31
+ class BaseConfiguration
32
+
33
+ include MJ::Configuration::Configurable
34
+
35
+ option( 'name', "Name" )
36
+ option( 'inplace', 'Do not use out of source build' )
37
+
38
+ end
39
+
40
+
41
+ class Base
42
+
43
+ include MJ::Tools::SubProcess
44
+
45
+ attr_accessor :configuration
46
+
47
+ def initialize( mod )
48
+ @module = mod
49
+ end
50
+
51
+ def source_directory
52
+ @module.source_directory
53
+ end
54
+
55
+ def build_directory
56
+ if configuration.inplace
57
+ @module.source_directory
58
+ else
59
+ @module.build_directory
60
+ end
61
+ end
62
+
63
+ def inplace
64
+ configuration.inplace
65
+ end
66
+
67
+ def prefix
68
+ @module.prefix
69
+ end
70
+
71
+ def env
72
+ @module.env
73
+ end
74
+
75
+ def build
76
+ raise NotImplementedError, "#{self.class}::build in #{self.class}"
77
+ end
78
+
79
+ def self.config
80
+ raise NotImplementedError, "#{self.class}::name in #{self}"
81
+ end
82
+
83
+ def configure
84
+ raise NotImplementedError, "#{self.class}::configure in #{self.class}"
85
+ end
86
+
87
+ def configured?
88
+ raise NotImplementedError, "#{self.class}::configured? in #{self.class}"
89
+ end
90
+
91
+ def name
92
+ raise NotImplementedError, "#{self.class}::name in #{self.class}"
93
+ end
94
+
95
+ def remove_build_directory
96
+ self.class.execute "rm -rf #{build_directory}"
97
+ end
98
+
99
+ #########
100
+ protected
101
+ #########
102
+
103
+ def check_build_directory( create = false )
104
+ if inplace
105
+ if File.exist? @module.build_directory
106
+ if !File.symlink?( @module.build_directory )
107
+ $log.warn( "Could not link build directory to source directory for inplace build of #{@module.name}." )
108
+ end
109
+ else
110
+ FileUtils.mkdir_p( Pathname.new( @module.build_directory ).parent )
111
+ File.symlink( @module.source_directory, @module.build_directory )
112
+ end
113
+ else
114
+ if File.exist? build_directory
115
+ if File.directory? build_directory
116
+ return true
117
+ else
118
+ raise BuildError, "Build directory #{build_directory} exists and is no directory!"
119
+ end
120
+ elsif create
121
+ FileUtils.mkdir_p( build_directory )
122
+ return true
123
+ else
124
+ return false
125
+ end
126
+ end
127
+ end
128
+
129
+ end
130
+
131
+ end; end
132
+
@@ -0,0 +1,82 @@
1
+ require 'kde-build/build_system/base'
2
+
3
+ require 'kde-build/tools/make'
4
+
5
+ module BuildTool
6
+
7
+ module BuildSystem
8
+
9
+ class CMakeConfiguration < BaseConfiguration
10
+
11
+ option( 'options', "Command line options for cmake" )
12
+ option( 'cmake-prefix-path', "CMAKE_PREFIX_PATH environment variable" )
13
+
14
+ def initialize
15
+ super
16
+ self.name = "cmake"
17
+ end
18
+
19
+ end
20
+
21
+ class CMake < BuildSystem::Base
22
+
23
+ def initialize( mod )
24
+ super
25
+ end
26
+
27
+ def self.guess( path )
28
+ return File.exist? "#{path}/CMakeLists.txt"
29
+ end
30
+
31
+ def self.config
32
+ CMakeConfiguration
33
+ end
34
+
35
+ # Execute a cmake command in the context of the build directory
36
+ def cmake( command, wd = build_directory )
37
+ ENV['CMAKE_PREFIX_PATH'] = configuration.cmake_prefix_path
38
+ self.class.execute "cmake #{command}", wd, env
39
+ end
40
+
41
+ def make( command, wd = build_directory )
42
+ BuildTool::Make.new.make "#{command}", wd
43
+ end
44
+
45
+ def build( target )
46
+ check_build_directory( true )
47
+ make target
48
+ end
49
+
50
+ def reconfigure( clean )
51
+ make "clean" if clean
52
+ self.class.execute "rm #{build_directory}/CMakeCache.txt" if clean
53
+ configure
54
+ end
55
+
56
+ def configure
57
+ check_build_directory( true )
58
+ opt = options
59
+ opt += " -DCMAKE_INSTALL_PREFIX=#{prefix}" if prefix
60
+ rc = cmake "#{self.source_directory} #{opt}"
61
+ rc
62
+ end
63
+
64
+ def configured?
65
+ File.exist? "#{build_directory}/Makefile"
66
+ end
67
+
68
+ def name
69
+ "CMake"
70
+ end
71
+
72
+ def options
73
+ @configuration.options
74
+ end
75
+
76
+ Registry.register( 'CMake', CMake )
77
+
78
+ end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,125 @@
1
+ require 'kde-build/build_system/base'
2
+
3
+ require 'kde-build/tools/make'
4
+
5
+ module BuildTool
6
+
7
+ module BuildSystem
8
+
9
+ class QtCopyConfiguration < BaseConfiguration
10
+
11
+ option( 'options', "Command line options for qmake" )
12
+
13
+ def initialize
14
+ super
15
+ self.name = "qmake"
16
+ end
17
+
18
+ end
19
+
20
+ class QtCopyError < Exception
21
+ end
22
+
23
+
24
+ class QtCopy < BuildSystem::Base
25
+
26
+ def initialize( mod )
27
+ super
28
+ end
29
+
30
+ def self.guess( path )
31
+ return File.exist? "#{path}/qmake/qmake.pro"
32
+ end
33
+
34
+ def self.config
35
+ QtCopyConfiguration
36
+ end
37
+
38
+ # Execute a qmake command in the context of the build directory
39
+ def qmake( command, wd = build_directory )
40
+ execute "qmake #{command}", wd, env
41
+ end
42
+
43
+ def make( command, wd = build_directory )
44
+ BuildTool::Make.new.make "#{command}", wd
45
+ end
46
+
47
+ def build( target )
48
+ check_build_directory( true )
49
+ make target
50
+ end
51
+
52
+
53
+ def reconfigure( clean = false )
54
+ make "confclean" if clean
55
+ configure
56
+ end
57
+
58
+ def configure
59
+ check_build_directory( true )
60
+ create_configure_new_if_necessary
61
+ opt = options
62
+ opt += " --prefix=#{prefix}" if prefix
63
+ rc = self.class.execute( "sh #{self.source_directory}/configure.new #{opt}", wd = build_directory, env )
64
+ rc
65
+ end
66
+
67
+
68
+ def configured?
69
+ return File.exist? "#{build_directory}/bin/qmake"
70
+ end
71
+
72
+ def create_configure_new
73
+ if $noop
74
+ $log.info("Creating configure.new")
75
+ return
76
+ end
77
+ confnew = File.new( "#{source_directory}/configure.new", "w" )
78
+ conf = File.new( "#{source_directory}/configure", "r" )
79
+ conf.each do |line|
80
+ confnew.write(
81
+ line.
82
+ sub("read acceptance", "acceptance=yes").
83
+ sub("read commercial", "commercial=o") )
84
+ end
85
+ confnew.chmod( 0744 )
86
+ ensure
87
+ conf.close
88
+ confnew.close
89
+ end
90
+
91
+ def create_configure_new_if_necessary
92
+ confnew_name = "#{source_directory}/configure.new"
93
+
94
+ if File.exist? confnew_name
95
+ begin
96
+ confnew = File.new( "#{source_directory}/configure.new", "r" )
97
+ conf = File.new( "#{source_directory}/configure", "r" )
98
+ if ( confnew.mtime > conf.mtime )
99
+ return
100
+ end
101
+ ensure
102
+ confnew.close
103
+ conf.close
104
+ end
105
+ end
106
+ create_configure_new
107
+ end
108
+
109
+ def name
110
+ "QtCopy"
111
+ end
112
+
113
+ def options
114
+ @configuration.options
115
+ end
116
+
117
+ Registry.register( 'QtCopy', QtCopy )
118
+
119
+ end
120
+
121
+
122
+ end
123
+
124
+ end
125
+