teapot 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in teapot.gemspec
4
+ gemspec
@@ -0,0 +1,55 @@
1
+ # Teapot
2
+
3
+ Teapot is a tool for managing complex cross-platform builds. It provides
4
+ advanced dependency management via the Teapot file and is supported by
5
+ the infusions ecosystem of packages and platform tooling.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'teapot'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install teapot
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
32
+
33
+ ## License
34
+
35
+ Released under the MIT license.
36
+
37
+ Copyright, 2012, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining a copy
40
+ of this software and associated documentation files (the "Software"), to deal
41
+ in the Software without restriction, including without limitation the rights
42
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43
+ copies of the Software, and to permit persons to whom the Software is
44
+ furnished to do so, subject to the following conditions:
45
+
46
+ The above copyright notice and this permission notice shall be included in
47
+ all copies or substantial portions of the Software.
48
+
49
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
55
+ THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require 'teapot/config'
24
+
25
+ require 'uri'
26
+ require 'rake'
27
+ require 'rainbow'
28
+
29
+ $app = Rake.application = Rake::Application.new
30
+ $app.init('teapot')
31
+
32
+ task :fetch do
33
+ config = Teapot::Config.load
34
+ context = Teapot::Context.new(config)
35
+
36
+ base_uri = URI(config.options[:source].to_s + '/')
37
+
38
+ config.records.each do |record|
39
+ destination_path = record.destination_path
40
+
41
+ $stderr.puts "Fetching #{record}...".color(:blue)
42
+
43
+ unless File.exist? destination_path
44
+ $stderr.puts "Cloning package at path #{destination_path} ...".color(:green)
45
+
46
+ source_uri = URI(record.uri)
47
+
48
+ unless source_uri.absolute?
49
+ source_uri = base_uri + source_uri
50
+ end
51
+
52
+ if source_uri.scheme == "file"
53
+ source_uri = source_uri.path
54
+ end
55
+
56
+ sh("git", "clone", source_uri.to_s, destination_path.to_s)
57
+ else
58
+ $stderr.puts "Updating package at path #{destination_path} ...".color(:green)
59
+
60
+ Dir.chdir(destination_path) do
61
+ sh("git", "pull")
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ task :install => :fetch do
68
+ config = Teapot::Config.load
69
+ context = Teapot::Context.new(config)
70
+
71
+ config.records.each do |record|
72
+ $stderr.puts "Installing #{record.name}...".color(:blue)
73
+
74
+ record.load(context).each do |bundle|
75
+ if bundle.respond_to? :fetch_location
76
+ location = bundle.fetch_location
77
+
78
+ if !location
79
+ puts "Could not determine fetch location for #{name}!".color(:red)
80
+ elsif File.exist? bundle.source_path
81
+ puts "Source path #{bundle.source_path} already exists!".color(:red)
82
+ else
83
+ url = location[:url]
84
+ local_path = bundle.path + (location[:filename] || File.basename(url))
85
+
86
+ puts "Local path: #{local_path}"
87
+
88
+ unless bundle.source_path.exist?
89
+ unless local_path.exist?
90
+ puts "Downloading #{bundle.name} to #{local_path}..."
91
+ sh("curl", "-L", url, "-o", local_path.to_s)
92
+ end
93
+
94
+ puts "Extracting #{bundle.name}..."
95
+ sh("mkdir", bundle.source_path.to_s)
96
+ sh("tar", "-C", bundle.source_path.to_s, "--strip-components", "1", "-xvf", local_path.to_s)
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ task :help do
105
+ $stderr.puts "To create a new teapot, use the setup task:"
106
+ $stderr.puts "$ #{File.basename($0)} setup project-path"
107
+ end
108
+
109
+ task :default => :help
110
+
111
+ $app.top_level
@@ -0,0 +1,5 @@
1
+ require "teapot/version"
2
+
3
+ module Teapot
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,133 @@
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'pathname'
22
+
23
+ require 'teapot/context'
24
+
25
+ module Teapot
26
+ class Config
27
+ class Record
28
+ def initialize(config, klass, name, options = {})
29
+ @config = config
30
+ @klass = klass
31
+
32
+ if options[:name]
33
+ @name = options[:name]
34
+ end
35
+
36
+ if Symbol === name
37
+ @uri = name.to_s
38
+ @name ||= @uri
39
+ else
40
+ @name ||= File.basename(name)
41
+ @uri = name
42
+ end
43
+
44
+ @options = options
45
+ end
46
+
47
+ attr :klass
48
+ attr :name
49
+ attr :uri
50
+ attr :options
51
+
52
+ def load(context)
53
+ context.load(self)
54
+ end
55
+
56
+ def loader_path
57
+ if @klass == Package
58
+ "package.rb"
59
+ elsif @klass == Platform
60
+ "platform.rb"
61
+ end
62
+ end
63
+
64
+ def destination_path
65
+ @config.base_path_for_record(self) + @name
66
+ end
67
+
68
+ def to_s
69
+ "<#{@klass} #{@name}>"
70
+ end
71
+ end
72
+
73
+ def base_path_for_record(record)
74
+ if record.klass == Package
75
+ packages_path
76
+ elsif record.klass == Platform
77
+ platforms_path
78
+ end
79
+ end
80
+
81
+ def initialize(root, options = {})
82
+ @root = Pathname.new(root)
83
+ @options = options
84
+
85
+ @packages = []
86
+ @platforms = []
87
+ end
88
+
89
+ def packages_path
90
+ @root + (@options[:packages_path] || "packages")
91
+ end
92
+
93
+ def platforms_path
94
+ @root + (@options[:platforms_path] || "platforms")
95
+ end
96
+
97
+ def build_path
98
+ @root + (@options[:build_path] || "build")
99
+ end
100
+
101
+ attr :options
102
+ attr :packages
103
+ attr :platforms
104
+
105
+ def source(path)
106
+ @options[:source] = path
107
+ end
108
+
109
+ def records
110
+ @packages + @platforms
111
+ end
112
+
113
+ def package(name, options = {})
114
+ @packages << Record.new(self, Package, name, options)
115
+ end
116
+
117
+ def platform(name, options = {})
118
+ @platforms << Record.new(self, Platform, name, options)
119
+ end
120
+
121
+ def self.load(root = Dir.getwd, options = {})
122
+ config = new(root, options)
123
+
124
+ teapot_path = File.join(root, "Teapot")
125
+
126
+ if File.exist? teapot_path
127
+ config.instance_eval(File.read(teapot_path), teapot_path)
128
+ end
129
+
130
+ return config
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,74 @@
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'pathname'
22
+
23
+ require 'teapot/package'
24
+ require 'teapot/platform'
25
+
26
+ module Teapot
27
+ PACKAGE_FILE = "package.rb"
28
+
29
+ class Context
30
+ def initialize(config)
31
+ @config = config
32
+
33
+ @packages = {}
34
+ @platforms = {}
35
+
36
+ @defined = []
37
+ end
38
+
39
+ attr :config
40
+ attr :packages
41
+ attr :platforms
42
+
43
+ def load(record)
44
+ @defined = []
45
+
46
+ path = (record.destination_path + record.loader_path).to_s
47
+ self.instance_eval(File.read(path), path)
48
+
49
+ @defined
50
+ end
51
+
52
+ def define_package(name, &block)
53
+ package = Package.new(self, name)
54
+
55
+ yield(package)
56
+
57
+ @packages[package.name] = package
58
+
59
+ @defined << package
60
+ end
61
+
62
+ def define_platform(name, &block)
63
+ platform = Platform.new(self, name)
64
+
65
+ yield(platform)
66
+
67
+ if platform.available?
68
+ @platforms[platform.name] = platform
69
+ end
70
+
71
+ @defined << platform
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,106 @@
1
+
2
+ require 'pathname'
3
+
4
+ module Teapot
5
+ class Package
6
+ class BuildError < StandardError
7
+ end
8
+
9
+ class Task
10
+ def initialize
11
+ @callbacks = {}
12
+ end
13
+
14
+ def define(name, &callback)
15
+ @callbacks[name] = callback
16
+ end
17
+
18
+ def [](name)
19
+ @callbacks[name] || @callbacks[:all]
20
+ end
21
+ end
22
+
23
+ def self.build_order(available, packages)
24
+ ordered = []
25
+
26
+ expand = lambda do |name|
27
+ package = available[name]
28
+
29
+ unless package
30
+ puts "Couldn't resolve #{name}"
31
+ else
32
+ package.depends.each do |dependency|
33
+ expand.call(dependency)
34
+ end
35
+
36
+ unless ordered.include? package
37
+ ordered << package
38
+ end
39
+ end
40
+ end
41
+
42
+ packages.each do |package|
43
+ expand.call(package.name)
44
+ end
45
+
46
+ return ordered
47
+ end
48
+
49
+ def initialize(context, name, path = nil)
50
+ @context = context
51
+
52
+ parts = name.split('-')
53
+ @name = parts[0..-2].join('-')
54
+ @version = parts[-1]
55
+
56
+ @path = path || (context.config.packages_path + @name)
57
+
58
+ @build = Task.new
59
+
60
+ @depends = []
61
+
62
+ @source_path = @path + name
63
+ @fetch_location = nil
64
+ end
65
+
66
+ attr :name
67
+ attr :version
68
+ attr :path
69
+ attr :variants
70
+ attr :fetch_location
71
+
72
+ attr :depends, true
73
+ attr :source_path, true
74
+
75
+ def install!
76
+ if @fetch_location
77
+ end
78
+ end
79
+
80
+ def build(platform, &block)
81
+ @build.define(platform, &block)
82
+ end
83
+
84
+ def build!(platform = :all, config = {})
85
+ task = @build[platform.name]
86
+
87
+ puts "Building #{@name} for #{platform.name}"
88
+ if task
89
+ Dir.chdir(@path) do
90
+ puts "Entering #{@path}..."
91
+ task.call(platform, platform.config.merge(config))
92
+ end
93
+ else
94
+ raise BuildError.new("Could not find task #{task_name} for #{platform.name}!")
95
+ end
96
+ end
97
+
98
+ def fetch_from(location)
99
+ @fetch_location = location
100
+ end
101
+
102
+ def to_s
103
+ "<Package: #{@name}>"
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,80 @@
1
+
2
+ require 'fileutils'
3
+
4
+ module Teapot
5
+ class Platform
6
+ class Config
7
+ def initialize(values = {})
8
+ @values = values
9
+ end
10
+
11
+ attr :values
12
+
13
+ def method_missing(name, *args)
14
+ if name.to_s.match(/^(.*?)(\=)?$/)
15
+ if $2
16
+ return @values[$1.to_sym] = args[0]
17
+ else
18
+ return @values[$1.to_sym]
19
+ end
20
+ else
21
+ super(name, *args)
22
+ end
23
+ end
24
+
25
+ def merge(config)
26
+ Config.new(@values.merge(config))
27
+ end
28
+ end
29
+
30
+ def prefix
31
+ @context.config.build_path + @name.to_s
32
+ end
33
+
34
+ def cmake_modules_path
35
+ prefix + "share/cmake/modules"
36
+ end
37
+
38
+ def initialize(context, name)
39
+ @context = context
40
+
41
+ @name = name
42
+ @config = nil
43
+ @available = false
44
+ end
45
+
46
+ attr :name
47
+
48
+ def configure(&block)
49
+ @configuration = Proc.new &block
50
+ end
51
+
52
+ def config
53
+ if available?
54
+ config = Config.new
55
+
56
+ @configuration.call(config)
57
+
58
+ return config
59
+ else
60
+ return nil
61
+ end
62
+ end
63
+
64
+ def make_available!
65
+ @available = true
66
+ end
67
+
68
+ def available?
69
+ @available
70
+ end
71
+
72
+ def to_s
73
+ "<Platform #{@name}: #{@availble ? 'available' : 'inactive'}>"
74
+ end
75
+
76
+ def prepare!
77
+ FileUtils.mkdir_p cmake_modules_path
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,3 @@
1
+ module Teapot
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'teapot/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "teapot"
8
+ gem.version = Teapot::VERSION
9
+ gem.authors = ["Samuel Williams"]
10
+ gem.email = ["samuel.williams@oriontransfer.co.nz"]
11
+ gem.description = <<-EOF
12
+ Teapot is a tool for managing complex cross-platform builds. It provides
13
+ advanced dependency management via the Teapot file and is supported by
14
+ the infusions ecosystem of packages and platform tooling.
15
+ EOF
16
+ gem.summary = %q{Teapot is a tool for managing complex cross-platform builds.}
17
+ gem.homepage = ""
18
+
19
+ gem.files = `git ls-files`.split($/)
20
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
21
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
+ gem.require_paths = ["lib"]
23
+
24
+ gem.add_dependency "rake"
25
+ gem.add_dependency "rainbow"
26
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: teapot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Samuel Williams
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rainbow
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! "\tTeapot is a tool for managing complex cross-platform builds. It
47
+ provides\n\tadvanced dependency management via the Teapot file and is supported
48
+ by\n\tthe infusions ecosystem of packages and platform tooling.\n"
49
+ email:
50
+ - samuel.williams@oriontransfer.co.nz
51
+ executables:
52
+ - teapot
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - .gitignore
57
+ - Gemfile
58
+ - README.md
59
+ - Rakefile
60
+ - bin/teapot
61
+ - lib/teapot.rb
62
+ - lib/teapot/config.rb
63
+ - lib/teapot/context.rb
64
+ - lib/teapot/package.rb
65
+ - lib/teapot/platform.rb
66
+ - lib/teapot/version.rb
67
+ - teapot.gemspec
68
+ homepage: ''
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ segments:
81
+ - 0
82
+ hash: -3245373006178987296
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ segments:
90
+ - 0
91
+ hash: -3245373006178987296
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 1.8.24
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Teapot is a tool for managing complex cross-platform builds.
98
+ test_files: []