bake 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +7 -0
  6. data/Gemfile.lock +40 -0
  7. data/README.md +99 -0
  8. data/Rakefile +6 -0
  9. data/bake.gemspec +25 -0
  10. data/bin/bake +25 -10
  11. data/lib/bake.rb +21 -140
  12. data/lib/bake/book.rb +79 -0
  13. data/lib/bake/command.rb +29 -0
  14. data/lib/bake/command/invoke.rb +67 -0
  15. data/lib/bake/command/list.rb +76 -0
  16. data/lib/bake/command/top.rb +111 -0
  17. data/lib/bake/context.rb +103 -110
  18. data/lib/bake/loader.rb +82 -0
  19. data/lib/bake/loaders.rb +110 -0
  20. data/lib/bake/recipe.rb +109 -0
  21. data/lib/bake/version.rb +23 -0
  22. metadata +73 -85
  23. data/CHANGELOG +0 -38
  24. data/CONCEPTS +0 -54
  25. data/MIT-LICENSE +0 -21
  26. data/README +0 -38
  27. data/REFERENCE +0 -2
  28. data/TUTORIAL +0 -128
  29. data/lib/bake/addon.rb +0 -20
  30. data/lib/bake/configuration.rb +0 -126
  31. data/lib/bake/extensions.rb +0 -3
  32. data/lib/bake/extensions/class.rb +0 -11
  33. data/lib/bake/extensions/object.rb +0 -22
  34. data/lib/bake/extensions/string.rb +0 -22
  35. data/lib/bake/file_target.rb +0 -19
  36. data/lib/bake/plugin.rb +0 -49
  37. data/lib/bake/plugins/cpp.rb +0 -188
  38. data/lib/bake/plugins/cpp/darwin.rb +0 -26
  39. data/lib/bake/plugins/cpp/gcc.rb +0 -14
  40. data/lib/bake/plugins/cpp/gcc_toolset_base.rb +0 -101
  41. data/lib/bake/plugins/cpp/msvc.rb +0 -118
  42. data/lib/bake/plugins/cpp/qt.rb +0 -53
  43. data/lib/bake/plugins/cpp/toolset_base.rb +0 -56
  44. data/lib/bake/plugins/macro.rb +0 -18
  45. data/lib/bake/plugins/runner.rb +0 -40
  46. data/lib/bake/plugins/system.rb +0 -30
  47. data/lib/bake/project.rb +0 -91
  48. data/lib/bake/project_loader.rb +0 -116
  49. data/lib/bake/system_utils.rb +0 -42
  50. data/lib/bake/target.rb +0 -155
  51. data/lib/bake/toolset.rb +0 -25
  52. data/lib/bake_version.rb +0 -5
  53. data/test/test_bake.rb +0 -2
  54. data/test/test_configuration.rb +0 -58
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f5064c2fb5970db1bfd61752e337a35cb1130655d2aa712cac405c4ef9b5ac99
4
+ data.tar.gz: 34c28cb42f472d9cdb02bcde6576a784d7b9a1beeda8ffde67ddd1a16e7b2cdd
5
+ SHA512:
6
+ metadata.gz: 2aba107faf34db34af932925c0c6ba34fb906a7bd68a10c5ae286f537ba2ad1b085e01a3d7390f88225809fdf0570edb81522e8df98ff7f476b2b22613de5e98
7
+ data.tar.gz: 5e75149322e7668879aaee32eea149dfdcbb98540f60bb29695fd4e5651a917b04f75d957a4710f77d5067e43e4eeb855d010ff31e85daa27ad3e700073fdacd
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bake.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bake (0.2.0)
5
+ samovar (~> 2.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ console (1.8.0)
11
+ diff-lcs (1.3)
12
+ mapping (1.1.1)
13
+ rake (12.3.3)
14
+ rspec (3.9.0)
15
+ rspec-core (~> 3.9.0)
16
+ rspec-expectations (~> 3.9.0)
17
+ rspec-mocks (~> 3.9.0)
18
+ rspec-core (3.9.1)
19
+ rspec-support (~> 3.9.1)
20
+ rspec-expectations (3.9.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.9.0)
23
+ rspec-mocks (3.9.1)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.9.0)
26
+ rspec-support (3.9.2)
27
+ samovar (2.1.4)
28
+ console (~> 1.0)
29
+ mapping (~> 1.0)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ bake!
36
+ rake (~> 12.0)
37
+ rspec (~> 3.0)
38
+
39
+ BUNDLED WITH
40
+ 2.1.2
@@ -0,0 +1,99 @@
1
+ # Bake
2
+
3
+ Bake is a task execution tool, inspired by Rake, but codifying many of the typical use cases which are typically implemented in an ad-hoc manner.
4
+
5
+ ## Motivation
6
+
7
+ Rake is an awesome tool and loved by the community. So, why reinvent it? Bake provides the following features that Rake does not:
8
+
9
+ - On demand loading of files following a standard convention. This avoid loading all your rake tasks just to execute a single command.
10
+ - Better argument handling including support for positional and optional arguments.
11
+ - Focused on task execution not dependency resolution. Implementation is simpler and a bit more predictable.
12
+ - Canonical structure for integration with gems.
13
+
14
+ That being said, Rake and Bake can exist side by side in the same project.
15
+
16
+ ## Installation
17
+
18
+ Execute the following in your project:
19
+
20
+ bundle add bake
21
+
22
+ ## Usage
23
+
24
+ Bake follows similar patterns to Rake.
25
+
26
+ ## Bakefile
27
+
28
+ There is a root level `bake.rb` which contains project-specific configuration and recipes, e.g.:
29
+
30
+ ```ruby
31
+ recipe :deploy do
32
+ call 'activerecord:migrations:deploy'
33
+ call 'falcon:server:restart'
34
+ end
35
+ ```
36
+
37
+ This file is project specific and is the only file which can expose top level tasks (i.e. without a defined namespace).
38
+
39
+ ## Recipes
40
+
41
+ Alongside the `bake.rb`, there is a `recipes/` directory which contains files like `icons.rb`. These files contain recipes, e.g.:
42
+
43
+ ```ruby
44
+ recipe :generate do |name|
45
+ MyProject::Icons::Generate.call(name)
46
+ end
47
+ ```
48
+
49
+ ## Gems
50
+
51
+ Adding a `recipes/` directory to your gem, will expose those tasks to any project that depends on your gem. In order to prevent collisions, imported commands are prefixed with the name of the gem. If you want to provide top level commands, you may do so by naming a recipe the same as the namespace which encloses it, e.g. in `mygem/recipes/setup.rb`:
52
+
53
+ ```ruby
54
+ recipe :setup do
55
+ # ...
56
+ end
57
+ ```
58
+
59
+ Then, in your project `myproject` which depends on `mygem`:
60
+
61
+ ```
62
+ bake mygem:setup
63
+ ```
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create new Pull Request
72
+
73
+ ## See Also
74
+
75
+ - [Utopia](https://github.com/socketry/utopia) — A website framework which uses bake for maintenance tasks.
76
+
77
+ ## License
78
+
79
+ Released under the MIT license.
80
+
81
+ Copyright, 2020, by [Samuel G. D. Williams](http://www.codeotaku.com).
82
+
83
+ Permission is hereby granted, free of charge, to any person obtaining a copy
84
+ of this software and associated documentation files (the "Software"), to deal
85
+ in the Software without restriction, including without limitation the rights
86
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
87
+ copies of the Software, and to permit persons to whom the Software is
88
+ furnished to do so, subject to the following conditions:
89
+
90
+ The above copyright notice and this permission notice shall be included in
91
+ all copies or substantial portions of the Software.
92
+
93
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
94
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
95
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
96
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
97
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
98
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
99
+ THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ require_relative 'lib/bake/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "bake"
5
+ spec.version = Bake::VERSION
6
+ spec.authors = ["Samuel Williams"]
7
+ spec.email = ["samuel.williams@oriontransfer.co.nz"]
8
+
9
+ spec.summary = "A replacement for rake with a simpler syntax."
10
+ spec.homepage = "https://github.com/ioquatix/bake"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
13
+
14
+ spec.metadata["donation_uri"] = "https://github.com/sponsors/ioquatix"
15
+
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+
20
+ spec.bindir = "bin"
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency 'samovar', '~> 2.1'
25
+ end
data/bin/bake CHANGED
@@ -1,10 +1,25 @@
1
- #!/usr/bin/env ruby
2
-
3
- begin
4
- require 'rubygems'
5
- rescue LoadError
6
- # no rubygems to load, so we fail silently
7
- end
8
-
9
- require 'bake'
10
-
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright, 2020, 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_relative '../lib/bake/command'
24
+
25
+ Bake::Command.call
@@ -1,140 +1,21 @@
1
- require 'bake/extensions'
2
- require 'bake/context'
3
- require 'bake/project_loader'
4
- require 'bake/plugin'
5
- require 'bake/system_utils'
6
- require 'bake_version'
7
- require 'optparse'
8
-
9
- module Bake
10
- class CommandLineParseError < RuntimeError
11
- end
12
-
13
- class ProgramInfoRequested < RuntimeError
14
- end
15
-
16
- class App
17
- @@instance = nil
18
-
19
- def self.instance
20
- return @@instance
21
- end
22
-
23
- def initialize
24
- raise "App instance already created" if @@instance
25
- @@instance = self
26
- end
27
-
28
- def run(*args)
29
- options, args = parse_command_line(*args)
30
- props, targets = process_excess_args(*args)
31
- props[:platform] = determine_platform
32
-
33
- sys = SystemUtils.new(:verbose => options[:verbose],
34
- :dry_run => options[:dry_run])
35
- @context = Context.new(sys)
36
- # must execute this in context so that plugins are loaded properly
37
- @context.context_eval(nil, 'import System, Macro')
38
- @project_loader = ProjectLoader.new(@context, Dir.pwd, props)
39
- targets = targets.collect do |name|
40
- target = @project_loader.invok_project.resolve(name)
41
- if !target
42
- raise CommandLineParseError,
43
- "could not find target '#{name}'"
44
- end
45
- target
46
- end
47
-
48
- method = options[:clean] ? :clean_r : :build_r
49
- if targets.empty?
50
- @project_loader.invok_project.send(method)
51
- else
52
- targets.each { |target| target.send(method) }
53
- end
54
- end
55
-
56
- private
57
- def determine_platform
58
- if RUBY_PLATFORM =~ /darwin/i
59
- return 'osx'
60
- elsif RUBY_PLATFORM =~ /linux/i
61
- return 'linux'
62
- elsif RUBY_PLATFORM =~ /mswin/i
63
- return 'win32'
64
- end
65
- return 'other'
66
- end
67
-
68
- def parse_command_line(*args)
69
- options = {}
70
- opts = OptionParser.new do |opts|
71
- opts.banner = "Usage: bake [options] [target ...]"
72
- opts.on('--clean', 'Clean the given targets') do |clean|
73
- options[:clean] = clean
74
- end
75
- opts.on('-n', '--dry-run', 'Do not update targets') do |dr|
76
- options[:dry_run] = dr
77
- end
78
- opts.on('--verbose', 'Verbose output') do |verbose|
79
- options[:verbose] = verbose
80
- end
81
- opts.on_tail('-h', '--help', 'Display usage message') do
82
- raise ProgramInfoRequested, opts
83
- end
84
- opts.on_tail('--version', 'Show version information') do
85
- raise ProgramInfoRequested, 'bake ' + VERSION_STRING
86
- end
87
- end
88
-
89
- begin
90
- opts.parse!(args)
91
- rescue ProgramInfoRequested
92
- raise
93
- rescue Exception => e
94
- raise CommandLineParseError,
95
- "#{e.message} (use --help for usage information)"
96
- end
97
- return options, args
98
- end
99
-
100
- def process_excess_args(*args)
101
- props = {}
102
- targets = []
103
- args.each do |name|
104
- if name.count('=') == 1
105
- key, val = name.split('=')
106
- props[key.to_sym] = val
107
- else
108
- targets << name
109
- end
110
- end
111
- return props, targets
112
- end
113
- end
114
- end
115
-
116
- def parse_backtrace(backtrace)
117
- if backtrace.find { |entry| entry =~ /^.*?(config|root|sub)\.bake:\d+/ }
118
- return $&
119
- end
120
- return backtrace.join("\n")
121
- end
122
-
123
- exit_code = 1
124
- begin
125
- app = Bake::App.new
126
- app.run(*ARGV)
127
- puts 'build successful'
128
- exit_code = 0
129
- rescue Bake::ProgramInfoRequested => e
130
- puts e.message
131
- exit_code = 0
132
- rescue Bake::CommandLineParseError => e
133
- puts e.message
134
- rescue Exception => e
135
- puts parse_backtrace(e.backtrace) + ': ' + e.message
136
- puts 'build failed'
137
- end
138
-
139
- exit(exit_code)
140
-
1
+ # Copyright, 2020, 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 "bake/version"
@@ -0,0 +1,79 @@
1
+ # Copyright, 2020, 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_relative 'recipe'
22
+
23
+ module Bake
24
+ class Book
25
+ def self.load(file_path, *arguments, **options)
26
+ instance = self.new(*arguments, **options)
27
+
28
+ instance.freeze
29
+
30
+ instance.instance_eval(File.read(file_path), file_path)
31
+
32
+ return instance
33
+ end
34
+
35
+ def initialize(path = [], **options)
36
+ @path = path
37
+ @recipes = {}
38
+ end
39
+
40
+ def empty?
41
+ @recipes.empty?
42
+ end
43
+
44
+ def each(&block)
45
+ @recipes.each_value(&block)
46
+ end
47
+
48
+ attr :path
49
+ attr :recipes
50
+
51
+ def to_s
52
+ @path.join(':')
53
+ end
54
+
55
+ def lookup(name)
56
+ @recipes[name.to_sym]
57
+ end
58
+
59
+ def recipe_for(path)
60
+ if path.size == 1
61
+ lookup(path.first)
62
+ end
63
+ end
64
+
65
+ def recipe(name, **options, &block)
66
+ unless block_given?
67
+ block = self.method(name)
68
+ end
69
+
70
+ @recipes[name] = Recipe.new(self, name, **options, &block)
71
+ end
72
+
73
+ def attach(name, callable, **options)
74
+ @recipes[name] = Recipe.new(self, name, **options) do |*arguments, **options|
75
+ callable.call(*arguments, **options)
76
+ end
77
+ end
78
+ end
79
+ end