Class: MilkTea::VendoredTool
- Inherits:
-
Object
- Object
- MilkTea::VendoredTool
- Defined in:
- lib/milk_tea/bindings/vendored_tool.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#build_dir ⇒ Object
readonly
Returns the value of attribute build_dir.
-
#cmake_args ⇒ Object
readonly
Returns the value of attribute cmake_args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output_binary_name ⇒ Object
readonly
Returns the value of attribute output_binary_name.
-
#source_dir ⇒ Object
readonly
Returns the value of attribute source_dir.
Instance Method Summary collapse
- #binary_path ⇒ Object
- #build! ⇒ Object
- #built? ⇒ Boolean
-
#initialize(name:, source_dir:, build_dir:, output_binary_name:, cmake_args: []) ⇒ VendoredTool
constructor
A new instance of VendoredTool.
- #install_path(root: MilkTea.root) ⇒ Object
Constructor Details
#initialize(name:, source_dir:, build_dir:, output_binary_name:, cmake_args: []) ⇒ VendoredTool
Returns a new instance of VendoredTool.
9 10 11 12 13 14 15 |
# File 'lib/milk_tea/bindings/vendored_tool.rb', line 9 def initialize(name:, source_dir:, build_dir:, output_binary_name:, cmake_args: []) @name = name @source_dir = File.(source_dir) @build_dir = File.(build_dir) @output_binary_name = output_binary_name @cmake_args = cmake_args.dup.freeze end |
Instance Attribute Details
#build_dir ⇒ Object (readonly)
Returns the value of attribute build_dir.
7 8 9 |
# File 'lib/milk_tea/bindings/vendored_tool.rb', line 7 def build_dir @build_dir end |
#cmake_args ⇒ Object (readonly)
Returns the value of attribute cmake_args.
7 8 9 |
# File 'lib/milk_tea/bindings/vendored_tool.rb', line 7 def cmake_args @cmake_args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/milk_tea/bindings/vendored_tool.rb', line 7 def name @name end |
#output_binary_name ⇒ Object (readonly)
Returns the value of attribute output_binary_name.
7 8 9 |
# File 'lib/milk_tea/bindings/vendored_tool.rb', line 7 def output_binary_name @output_binary_name end |
#source_dir ⇒ Object (readonly)
Returns the value of attribute source_dir.
7 8 9 |
# File 'lib/milk_tea/bindings/vendored_tool.rb', line 7 def source_dir @source_dir end |
Instance Method Details
#binary_path ⇒ Object
17 18 19 |
# File 'lib/milk_tea/bindings/vendored_tool.rb', line 17 def binary_path File.join(@build_dir, @output_binary_name) end |
#build! ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/milk_tea/bindings/vendored_tool.rb', line 29 def build! return binary_path if built? FileUtils.mkdir_p(@build_dir) run_cmake! run_make! raise Error, "tool #{@name} built but binary not found at #{binary_path}" unless built? binary_path end |
#built? ⇒ Boolean
25 26 27 |
# File 'lib/milk_tea/bindings/vendored_tool.rb', line 25 def built? File.file?(binary_path) && File.executable?(binary_path) end |