bake 0.1.2 → 0.2.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.
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,82 @@
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 'book'
22
+
23
+ module Bake
24
+ class Loader
25
+ def initialize(root, path = nil, name: nil)
26
+ @root = root
27
+ @path = path
28
+ @name = name
29
+ @cache = {}
30
+ end
31
+
32
+ def to_s
33
+ "#{self.class} #{@name || @root}"
34
+ end
35
+
36
+ attr :root
37
+
38
+ def each
39
+ return to_enum unless block_given?
40
+
41
+ Dir.glob("**/*.rb", base: @root) do |file_path|
42
+ path = file_path.sub(/\.rb$/, '').split(File::SEPARATOR)
43
+
44
+ if @path
45
+ yield(@path + path)
46
+ else
47
+ yield(path)
48
+ end
49
+ end
50
+ end
51
+
52
+ def recipe_for(path)
53
+ if book = lookup(path)
54
+ return book.lookup(path.last)
55
+ else
56
+ *path, name = *path
57
+
58
+ if book = lookup(path)
59
+ return book.lookup(name)
60
+ end
61
+ end
62
+ end
63
+
64
+ def lookup(path)
65
+ *directory, file = *path
66
+
67
+ file_path = File.join(@root, @path || [], directory, "#{file}.rb")
68
+
69
+ unless @cache.key?(path)
70
+ if File.exist?(file_path)
71
+ book = Book.load(file_path, path)
72
+
73
+ @cache[path] = book
74
+ else
75
+ @cache[path] = nil
76
+ end
77
+ end
78
+
79
+ return @cache[path]
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,110 @@
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 'console'
22
+
23
+ module Bake
24
+ class Loaders
25
+ include Enumerable
26
+
27
+ RECIPES_PATH = "recipes"
28
+
29
+ def initialize
30
+ @roots = {}
31
+ @ordered = Array.new
32
+ end
33
+
34
+ def empty?
35
+ @ordered.empty?
36
+ end
37
+
38
+ def append_defaults(working_directory)
39
+ # Load recipes from working directory:
40
+ self.append_path(working_directory)
41
+
42
+ # Load recipes from loaded gems:
43
+ self.append_from_gems
44
+ end
45
+
46
+ def each(&block)
47
+ return to_enum unless block_given?
48
+
49
+ @ordered.each(&block)
50
+ end
51
+
52
+ def append_path(current = Dir.pwd, recipes_path: RECIPES_PATH, path: nil, **options)
53
+ recipes_path = File.join(current, recipes_path)
54
+
55
+ if File.directory?(recipes_path)
56
+ insert(recipes_path, path, **options)
57
+ end
58
+ end
59
+
60
+ def append_from_root(current = Dir.pwd, **options)
61
+ while current
62
+ append_path(current, **options)
63
+
64
+ parent = File.dirname(current)
65
+
66
+ if current == parent
67
+ break
68
+ else
69
+ current = parent
70
+ end
71
+ end
72
+ end
73
+
74
+ def append_from_gems
75
+ Gem.loaded_specs.each do |name, spec|
76
+ if path = spec.full_gem_path and File.directory?(path)
77
+ append_path(path, path: name, name: spec.full_name)
78
+ end
79
+ end
80
+ end
81
+
82
+ def append_from_paths(paths, **options)
83
+ paths.each do |path|
84
+ append_path(path, **options)
85
+ end
86
+ end
87
+
88
+ protected
89
+
90
+ def insert(directory, path, **options)
91
+ unless @roots.key?(directory)
92
+ Console.logger.debug(self) do
93
+ if path
94
+ "Adding #{directory.inspect} for #{path.inspect}."
95
+ else
96
+ "Adding #{directory.inspect}"
97
+ end
98
+ end
99
+
100
+ loader = Loader.new(directory, path, **options)
101
+ @roots[directory] = loader
102
+ @ordered << loader
103
+
104
+ return true
105
+ end
106
+
107
+ return false
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,109 @@
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
+ module Bake
22
+ class Recipe
23
+ def initialize(book, name, description: nil, &block)
24
+ @book = book
25
+ @name = name
26
+ @description = description
27
+ @block = block
28
+ end
29
+
30
+ attr :book
31
+
32
+ def options?
33
+ type, name = @block.parameters.last
34
+
35
+ return type == :keyrest
36
+ end
37
+
38
+ def command
39
+ if @book.path.empty?
40
+ @name.to_s
41
+ elsif @book.path.last.to_sym == @name
42
+ @book.to_s
43
+ else
44
+ "#{@book}:#{@name}"
45
+ end
46
+ end
47
+
48
+ def parameters
49
+ parameters = @block.parameters
50
+
51
+ unless parameters.empty?
52
+ return parameters
53
+ end
54
+ end
55
+
56
+ def to_s
57
+ if @description
58
+ "#{self.command} #{@description}"
59
+ else
60
+ self.command
61
+ end
62
+ end
63
+
64
+ def arity
65
+ @block.arity
66
+ end
67
+
68
+ def prepare(arguments)
69
+ offset = 0
70
+ ordered = []
71
+ options = {}
72
+
73
+ while argument = arguments.first
74
+ name, value = argument.split('=', 2)
75
+
76
+ if name and value
77
+ # Consume it:
78
+ arguments.shift
79
+
80
+ options[name.to_sym] = value
81
+ elsif ordered.size < self.arity
82
+ # Consume it:
83
+ ordered << arguments.shift
84
+ else
85
+ break
86
+ end
87
+ end
88
+
89
+ return ordered, options
90
+ end
91
+
92
+ def call(context, *arguments, **options)
93
+ if options?
94
+ context.instance_exec(*arguments, **options, &@block)
95
+ else
96
+ # Ignore options...
97
+ context.instance_exec(*arguments, &@block)
98
+ end
99
+ end
100
+
101
+ def explain(context, *arguments, **options)
102
+ if options?
103
+ puts "#{self}(#{arguments.join(", ")}, #{options.inspect})"
104
+ else
105
+ puts "#{self}(#{arguments.join(", ")})"
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,23 @@
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
+ module Bake
22
+ VERSION = "0.2.0"
23
+ end
metadata CHANGED
@@ -1,91 +1,79 @@
1
- --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
3
- specification_version: 1
1
+ --- !ruby/object:Gem::Specification
4
2
  name: bake
5
- version: !ruby/object:Gem::Version
6
- version: 0.1.2
7
- date: 2007-05-17 00:00:00 -04:00
8
- summary: Project-based build utility
9
- require_paths:
10
- - lib
11
- email: dylan@dylantrotter.com
12
- homepage: http://dylantrotter.com/
13
- rubyforge_project:
14
- description:
15
- autorequire: bake
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- authors:
29
- - Dylan Trotter
30
- files:
6
+ authors:
7
+ - Samuel Williams
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: samovar
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.1'
27
+ description:
28
+ email:
29
+ - samuel.williams@oriontransfer.co.nz
30
+ executables:
31
+ - bake
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - ".rspec"
37
+ - ".travis.yml"
38
+ - Gemfile
39
+ - Gemfile.lock
40
+ - README.md
41
+ - Rakefile
42
+ - bake.gemspec
31
43
  - bin/bake
32
- - lib/bake
33
44
  - lib/bake.rb
34
- - lib/bake_version.rb
35
- - lib/bake/addon.rb
36
- - lib/bake/configuration.rb
45
+ - lib/bake/book.rb
46
+ - lib/bake/command.rb
47
+ - lib/bake/command/invoke.rb
48
+ - lib/bake/command/list.rb
49
+ - lib/bake/command/top.rb
37
50
  - lib/bake/context.rb
38
- - lib/bake/extensions
39
- - lib/bake/extensions.rb
40
- - lib/bake/file_target.rb
41
- - lib/bake/plugin.rb
42
- - lib/bake/plugins
43
- - lib/bake/project.rb
44
- - lib/bake/project_loader.rb
45
- - lib/bake/system_utils.rb
46
- - lib/bake/target.rb
47
- - lib/bake/toolset.rb
48
- - lib/bake/extensions/class.rb
49
- - lib/bake/extensions/object.rb
50
- - lib/bake/extensions/string.rb
51
- - lib/bake/plugins/cpp
52
- - lib/bake/plugins/cpp.rb
53
- - lib/bake/plugins/macro.rb
54
- - lib/bake/plugins/runner.rb
55
- - lib/bake/plugins/system.rb
56
- - lib/bake/plugins/cpp/darwin.rb
57
- - lib/bake/plugins/cpp/gcc.rb
58
- - lib/bake/plugins/cpp/gcc_toolset_base.rb
59
- - lib/bake/plugins/cpp/msvc.rb
60
- - lib/bake/plugins/cpp/qt.rb
61
- - lib/bake/plugins/cpp/toolset_base.rb
62
- - test/test_bake.rb
63
- - test/test_configuration.rb
64
- - README
65
- - MIT-LICENSE
66
- - TUTORIAL
67
- - CONCEPTS
68
- - REFERENCE
69
- - CHANGELOG
70
- test_files: []
71
-
72
- rdoc_options:
73
- - --title
74
- - Bake
75
- - --main
76
- - README
77
- extra_rdoc_files:
78
- - README
79
- - MIT-LICENSE
80
- - TUTORIAL
81
- - CONCEPTS
82
- - REFERENCE
83
- - CHANGELOG
84
- executables:
85
- - bake
86
- extensions: []
87
-
51
+ - lib/bake/loader.rb
52
+ - lib/bake/loaders.rb
53
+ - lib/bake/recipe.rb
54
+ - lib/bake/version.rb
55
+ homepage: https://github.com/ioquatix/bake
56
+ licenses:
57
+ - MIT
58
+ metadata:
59
+ donation_uri: https://github.com/sponsors/ioquatix
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.5.0
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
88
74
  requirements: []
89
-
90
- dependencies: []
91
-
75
+ rubygems_version: 3.1.2
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: A replacement for rake with a simpler syntax.
79
+ test_files: []