makeconf 0.1.0

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.
@@ -0,0 +1,73 @@
1
+ # A target is a section in a Makefile
2
+ class Target
3
+
4
+ attr_reader :objs
5
+ attr_accessor :deps, :rules
6
+
7
+ def initialize(objs, deps = [], rules = [])
8
+ deps = [ deps ] if deps.kind_of?(String)
9
+ rules = [ rules ] if rules.kind_of?(String)
10
+ raise ArgumentError.new('Bad objs') unless objs.kind_of?(String)
11
+ raise ArgumentError.new('Bad deps') unless deps.kind_of?(Array)
12
+ raise ArgumentError.new('Bad rules') unless rules.kind_of?(Array)
13
+
14
+ @objs = objs
15
+ @deps = deps
16
+ @rules = rules
17
+ @dirs_to_create = [] # directories to create
18
+ @files_to_copy = {} # files to be copied
19
+ end
20
+
21
+ # Merge one target with another
22
+ def merge!(src)
23
+ raise ArgumentError.new('Mismatched object') \
24
+ unless src.objs == @objs
25
+ @deps.push(src.deps).uniq!
26
+ @rules.push(src.rules).flatten!
27
+ @dirs_to_create.push(src.dirs_to_create).flatten!.uniq!
28
+ @files_to_copy.merge!(src.files_to_copy)
29
+ end
30
+
31
+ # Ensure that a directory is created before any rules are evaluated
32
+ def mkdir(path)
33
+ @dirs_to_create.push(path) unless @dirs_to_create.include?(path)
34
+ end
35
+
36
+ # Copy a file to a directory. This is more efficient than calling cp(1)
37
+ # for each file.
38
+ def cp(src,dst)
39
+ @files_to_copy[dst] ||= []
40
+ @files_to_copy[dst].push(src)
41
+ end
42
+
43
+ def add_dependency(depends)
44
+ @deps.push(depends).uniq!
45
+ end
46
+
47
+ def add_rule(rule)
48
+ @rules.push(rule)
49
+ end
50
+
51
+ def prepend_rule(target,rule)
52
+ @rules.unshift(rule)
53
+ end
54
+
55
+ # Return the string representation of the target
56
+ def to_s
57
+ res = "\n" + @objs + ':'
58
+ res += ' ' + @deps.join(' ') if @deps
59
+ res += "\n"
60
+ @dirs_to_create.each do |dir|
61
+ res += "\t" + Platform.mkdir(dir) + "\n"
62
+ end
63
+ @files_to_copy.each do |k,v|
64
+ res += "\t" + Platform.cp(v, k) + "\n"
65
+ end
66
+ @rules.each { |r| res += "\t" + r + "\n" }
67
+ res
68
+ end
69
+
70
+ protected
71
+
72
+ attr_reader :dirs_to_create, :files_to_copy
73
+ end
@@ -0,0 +1,28 @@
1
+ # An executable binary file used for testing
2
+ class Test < Binary
3
+
4
+ def initialize(options)
5
+ super(options)
6
+
7
+ @installable = false
8
+ @distributable = false
9
+
10
+ @ldflags = [ '-rpath .' ]
11
+
12
+ # Assume that unit tests should be debuggable
13
+ @cflags.push('-g', '-O0') unless Platform.is_windows?
14
+ end
15
+
16
+
17
+ def build
18
+ makefile = super()
19
+
20
+ unless SystemType.host =~ /-androideabi$/
21
+ makefile.add_dependency('check', @id)
22
+ makefile.add_rule('check', './' + @id)
23
+ end
24
+
25
+ return makefile
26
+ end
27
+
28
+ end
@@ -0,0 +1,22 @@
1
+ class Makeconf::WxApp < Wx::App
2
+
3
+ require 'rubygems'
4
+ require 'wx'
5
+
6
+ def on_init
7
+ @frame = Wx::Frame.new(nil, -1, 'Testing')
8
+ @wizard = Wx::Wizard.new(@frame)
9
+ pages = [
10
+ welcome
11
+ ]
12
+ @wizard.run_wizard(pages[0])
13
+ @wizard.Destroy()
14
+ end
15
+
16
+ def welcome
17
+ x = Wx::WizardPageSimple.new(@wizard)
18
+ Wx::StaticText.new(@wizard, :label => 'testing')
19
+ x
20
+ end
21
+
22
+ end
data/lib/makeconf.rb ADDED
@@ -0,0 +1,213 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (c) 2009-2011 Mark Heily <mark@heily.com>
4
+ #
5
+ # Permission to use, copy, modify, and distribute this software for any
6
+ # purpose with or without fee is hereby granted, provided that the above
7
+ # copyright notice and this permission notice appear in all copies.
8
+ #
9
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+ #
17
+
18
+ class Makeconf
19
+
20
+ Makeconf_Version = 0.1
21
+
22
+ require 'optparse'
23
+ require 'pp'
24
+ require 'logger'
25
+
26
+ require 'makeconf/buildable'
27
+ require 'makeconf/binary'
28
+ require 'makeconf/compiler'
29
+ require 'makeconf/externalproject'
30
+ require 'makeconf/gui'
31
+ require 'makeconf/header'
32
+ require 'makeconf/installer'
33
+ require 'makeconf/library'
34
+ require 'makeconf/linker'
35
+ require 'makeconf/makefile'
36
+ require 'makeconf/packager'
37
+ require 'makeconf/platform'
38
+ require 'makeconf/project'
39
+ require 'makeconf/systemtype'
40
+ require 'makeconf/target'
41
+ require 'makeconf/test'
42
+
43
+ @@installer = Installer.new
44
+ @@makefile = Makefile.new
45
+ @@original_argv = ARGV.clone # OptionParser seems to clobber this..
46
+
47
+ @@logger = Logger.new(STDOUT)
48
+ #TODO:@@logger = Logger.new('config.log')
49
+ @@logger.datetime_format = ''
50
+ if ENV['MAKECONF_DEBUG'] == 'yes'
51
+ @@logger.level = Logger::DEBUG
52
+ else
53
+ @@logger.level = Logger::WARN
54
+ end
55
+
56
+ def Makeconf.original_argv
57
+ @@original_argv.clone
58
+ end
59
+
60
+ def Makeconf.logger
61
+ @@logger
62
+ end
63
+
64
+ def Makeconf.parse_options(args = ARGV)
65
+ reject_unknown_options = true
66
+
67
+ x = OptionParser.new do |opts|
68
+ opts.banner = 'Usage: configure [options]'
69
+
70
+ @@installer.parse_options(opts)
71
+ @@project.parse_options(opts)
72
+
73
+ # Cross-compilation options
74
+ opts.separator ''
75
+ opts.separator 'System types:'
76
+
77
+ opts.on('--build BUILD', 'set the system type for building') do |arg|
78
+ @@build = arg
79
+ end
80
+ opts.on('--host HOST', 'cross-compile programs to run on a different system type') do |arg|
81
+ @@host = arg
82
+ end
83
+ opts.on('--target TARGET', 'build a compiler for cross-compiling') do |arg|
84
+ @@target = arg
85
+ end
86
+
87
+ opts.separator ''
88
+ opts.separator 'Common options:'
89
+
90
+ opts.on_tail('--disable-option-checking') {} # NOOP
91
+
92
+ opts.on_tail('-h', '--help', 'Show this message') do
93
+ puts opts
94
+ exit
95
+ end
96
+
97
+ opts.on_tail('-V', '--version', 'Display version information and exit') do
98
+ puts "Makeconf $Id: makeconf.rb 295 2012-11-10 17:55:29Z mheily $"
99
+ exit
100
+ end
101
+ end
102
+
103
+ # Special case: This must be processed prior to all other options
104
+ if args.include? '--disable-option-checking'
105
+ reject_unknown_options = false
106
+ end
107
+
108
+ # Parse all options, and gracefully resume when an invalid option
109
+ # is provided.
110
+ #
111
+ loop do
112
+ begin
113
+ x.parse!(args)
114
+ rescue OptionParser::InvalidOption => e
115
+ if reject_unknown_options
116
+ warn '*** ERROR *** ' + e.to_s
117
+ exit 1
118
+ else
119
+ warn 'WARNING: ' + e.to_s
120
+ next
121
+ end
122
+ end
123
+ break
124
+ end
125
+ end
126
+
127
+ # Examine the operating environment and set configuration options
128
+ def configure
129
+
130
+ @@logger.info 'Configuring the project'
131
+ # FIXME: once the GUI is finished, it should just be
132
+ # if Platform.is_graphical?
133
+ if ENV['MAKECONF_GUI'] == 'yes' and Platform.is_graphical?
134
+ ui = Makeconf::GUI.new(@project)
135
+ ui.main_loop
136
+ else
137
+ Makeconf.configure_project(@project)
138
+ end
139
+ end
140
+
141
+ def initialize(options)
142
+ raise ArgumentError unless options.kind_of?(Hash)
143
+ options.each do |k,v|
144
+ case k
145
+ when :minimum_version
146
+ send(k.to_s + '=',v)
147
+ else
148
+ raise ArgumentError, "Unknown argument #{k}"
149
+ end
150
+ end
151
+
152
+ @project = Project.new :id => 'default'
153
+ end
154
+
155
+ # Check if the current version is equal to or greater than the minimum required version
156
+ def minimum_version=(version)
157
+ if version > 0.1
158
+ throw "This version of Makeconf is too old. Please upgrade to version #{version} or newer"
159
+ end
160
+ end
161
+
162
+ # TODO: support multiple projects
163
+ def project(id = 'default')
164
+ @project
165
+ end
166
+
167
+ def project=(obj)
168
+ #raise ArgumentError unless options.kind_of?(Project)
169
+ @project = obj
170
+ end
171
+
172
+ private
173
+
174
+ # Examine the operating environment and set configuration options
175
+ def Makeconf.configure_project(project)
176
+ @@project = project
177
+ parse_options
178
+
179
+ makefile = Makefile.new
180
+ toplevel_init(makefile)
181
+
182
+ @@installer.configure(project)
183
+ project.makefile = @@makefile
184
+ project.installer = @@installer
185
+ project.configure
186
+ project.finalize
187
+ project.write_config_h
188
+ makefile.merge! project.to_make
189
+
190
+ puts 'creating Makefile'
191
+ makefile.write('Makefile')
192
+ end
193
+
194
+ # Add rules and targets used in the top-level Makefile
195
+ def Makeconf.toplevel_init(makefile)
196
+ makefile.add_target('dist', [], [])
197
+ makefile.add_dependency('distclean', 'clean')
198
+ makefile.add_rule('distclean', Platform.rm('Makefile'))
199
+
200
+ # Prepare the destination tree for 'make install'
201
+ makefile.add_rule('install', Platform.is_windows? ?
202
+ 'dir $(DESTDIR)' + Platform.dev_null :
203
+ '/usr/bin/test -e $(DESTDIR)')
204
+
205
+ # Distribute Makeconf with 'make distdir'
206
+ makefile.distribute([
207
+ 'configure',
208
+ 'makeconf/*.rb',
209
+ 'makeconf/makeconf/*.rb',
210
+ ])
211
+ end
212
+
213
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: makeconf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mark Heily
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-30 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: An alternative to GNU autoconf/automake/libtool/etc
15
+ email: mark@heily.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/makeconf.rb
21
+ - lib/makeconf/buildable.rb
22
+ - lib/makeconf/installer.rb
23
+ - lib/makeconf/makefile.rb
24
+ - lib/makeconf/packager.rb
25
+ - lib/makeconf/wxapp.rb
26
+ - lib/makeconf/library.rb
27
+ - lib/makeconf/binary.rb
28
+ - lib/makeconf/gui.rb
29
+ - lib/makeconf/project.rb
30
+ - lib/makeconf/linker.rb
31
+ - lib/makeconf/platform.rb
32
+ - lib/makeconf/test.rb
33
+ - lib/makeconf/target.rb
34
+ - lib/makeconf/compiler.rb
35
+ - lib/makeconf/header.rb
36
+ - lib/makeconf/baseproject.rb
37
+ - lib/makeconf/externalproject.rb
38
+ - lib/makeconf/systemtype.rb
39
+ - lib/makeconf/androidproject.rb
40
+ homepage: http://mark.heily.com/project/makeconf
41
+ licenses: []
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 1.8.23
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Generates configurable Makefiles
64
+ test_files: []