Class: MilkTea::VendoredCLibrary::CMake
- Defined in:
- lib/milk_tea/bindings/vendored_c_library.rb
Instance Attribute Summary collapse
-
#archive_path ⇒ Object
readonly
Returns the value of attribute archive_path.
-
#build_root ⇒ Object
readonly
Returns the value of attribute build_root.
-
#install_root ⇒ Object
readonly
Returns the value of attribute install_root.
Attributes inherited from Base
#include_roots, #name, #source_root
Instance Method Summary collapse
- #build_flags(platform: nil) ⇒ Object
-
#initialize(name:, source_root:, build_root:, install_root:, archive_path:, include_roots: [], configure_args: [], build_target: "install", system_link_flags: [], pkg_config_name: nil, cc_env_var: nil, cmake_env_var: nil) ⇒ CMake
constructor
A new instance of CMake.
- #link_flags(platform: nil) ⇒ Object
- #prepare!(env: ENV, cc: ENV.fetch("CC", "cc"), platform: nil) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name:, source_root:, build_root:, install_root:, archive_path:, include_roots: [], configure_args: [], build_target: "install", system_link_flags: [], pkg_config_name: nil, cc_env_var: nil, cmake_env_var: nil) ⇒ CMake
Returns a new instance of CMake.
201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/milk_tea/bindings/vendored_c_library.rb', line 201 def initialize(name:, source_root:, build_root:, install_root:, archive_path:, include_roots: [], configure_args: [], build_target: "install", system_link_flags: [], pkg_config_name: nil, cc_env_var: nil, cmake_env_var: nil) super(name:, source_root:, include_roots:, cc_env_var:) @build_root = Pathname.new(File.(build_root.to_s)) @install_root = Pathname.new(File.(install_root.to_s)) @archive_path = Pathname.new(File.(archive_path.to_s)) @configure_args = configure_args.dup.freeze @build_target = build_target @system_link_flags = system_link_flags.dup.freeze @pkg_config_name = pkg_config_name @cmake_env_var = cmake_env_var end |
Instance Attribute Details
#archive_path ⇒ Object (readonly)
Returns the value of attribute archive_path.
199 200 201 |
# File 'lib/milk_tea/bindings/vendored_c_library.rb', line 199 def archive_path @archive_path end |
#build_root ⇒ Object (readonly)
Returns the value of attribute build_root.
199 200 201 |
# File 'lib/milk_tea/bindings/vendored_c_library.rb', line 199 def build_root @build_root end |
#install_root ⇒ Object (readonly)
Returns the value of attribute install_root.
199 200 201 |
# File 'lib/milk_tea/bindings/vendored_c_library.rb', line 199 def install_root @install_root end |
Instance Method Details
#build_flags(platform: nil) ⇒ Object
217 218 219 |
# File 'lib/milk_tea/bindings/vendored_c_library.rb', line 217 def build_flags(platform: nil) include_flags end |
#link_flags(platform: nil) ⇒ Object
213 214 215 |
# File 'lib/milk_tea/bindings/vendored_c_library.rb', line 213 def link_flags(platform: nil) ["-L#{archive_path.dirname}", *pkg_config_link_flags, *@system_link_flags].uniq end |
#prepare!(env: ENV, cc: ENV.fetch("CC", "cc"), platform: nil) ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/milk_tea/bindings/vendored_c_library.rb', line 221 def prepare!(env: ENV, cc: ENV.fetch("CC", "cc"), platform: nil) resolved_cc = resolved_cc(env, cc) resolved_cmake = env.fetch(@cmake_env_var || "CMAKE", "cmake") signature = configuration_signature(cc: resolved_cc, cmake: resolved_cmake) needs_configure = signature != read_signature(build_root) || !File.exist?(build_root.join("CMakeCache.txt")) needs_build = !archive_up_to_date? return archive_path.to_s unless needs_configure || needs_build FileUtils.mkdir_p(build_root) FileUtils.mkdir_p(install_root) configure(cmake: resolved_cmake, cc: resolved_cc) build(cmake: resolved_cmake) unless File.exist?(archive_path) raise Error, "failed to build vendored #{name}: missing #{archive_path}" end write_signature(build_root, signature) archive_path.to_s rescue Errno::ENOENT => e raise tool_not_found(e) end |