Class: Comet::Makefile
- Inherits:
-
Object
- Object
- Comet::Makefile
- Defined in:
- lib/comet/makefile.rb
Class Method Summary collapse
- .command(command, args) ⇒ Object
- .fingerprint(dependencies, extension:) ⇒ Object
- .select_command(preferred, alternate, args) ⇒ Object
Instance Method Summary collapse
- #alias(name, rules) ⇒ Object
- #build(firmware, device) ⇒ Object
- #clean ⇒ Object
- #contents ⇒ Object
- #error(message) ⇒ Object
- #execute(*args) ⇒ Object
-
#initialize ⇒ Makefile
constructor
A new instance of Makefile.
Constructor Details
#initialize ⇒ Makefile
Returns a new instance of Makefile.
6 7 8 |
# File 'lib/comet/makefile.rb', line 6 def initialize @rules = [tmpdir_rule] end |
Class Method Details
.command(command, args) ⇒ Object
98 99 100 |
# File 'lib/comet/makefile.rb', line 98 def command(command, args) [command, *args].join ' ' end |
.fingerprint(dependencies, extension:) ⇒ Object
102 103 104 |
# File 'lib/comet/makefile.rb', line 102 def fingerprint(dependencies, extension:) File.join Comet::TMPDIR, "#{hash dependencies}.#{extension}" end |
.select_command(preferred, alternate, args) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/comet/makefile.rb', line 88 def select_command(preferred, alternate, args) return command(alternate, args) if preferred == alternate check_command = "(command -v #{preferred} > /dev/null)" preferred_cmd = command preferred, args alternate_cmd = command alternate, args "#{check_command} && #{preferred_cmd} || #{alternate_cmd}" end |
Instance Method Details
#alias(name, rules) ⇒ Object
21 22 23 |
# File 'lib/comet/makefile.rb', line 21 def alias(name, rules) insert Rules::Alias.new(name, rules) end |
#build(firmware, device) ⇒ Object
25 26 27 |
# File 'lib/comet/makefile.rb', line 25 def build(firmware, device) append Rules::Build.new(firmware, device) end |
#clean ⇒ Object
33 34 35 |
# File 'lib/comet/makefile.rb', line 33 def clean append Rules::Clean.new(Comet::TMPDIR) end |
#contents ⇒ Object
10 11 12 13 |
# File 'lib/comet/makefile.rb', line 10 def contents output = (commands + @rules.map(&:contents)) output.flatten.map(&:rstrip).join("\n") + "\n" end |
#error(message) ⇒ Object
29 30 31 |
# File 'lib/comet/makefile.rb', line 29 def error() insert Rules::Error.new() end |
#execute(*args) ⇒ Object
15 16 17 18 19 |
# File 'lib/comet/makefile.rb', line 15 def execute(*args) process_spawn make_command(*args) do |stdin| stdin.write contents end end |