mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-06-02 16:05:35 +02:00
* Don't pass empty string to cmake command * Refactor Dependencies * Use found cmake path for options * Maintain extsources.rb * List dependent files by directory separator agnostic way * Prepend whitespace before '=' * Handle build options on install * Remove useless test * Retrieve gem file name and version from spec file * Bump version to 1.3.3 * Update date * Add install option examples * [skip ci]Remove unused module
50 lines
1.1 KiB
Ruby
50 lines
1.1 KiB
Ruby
class Options
|
|
def initialize(cmake="cmake")
|
|
@cmake = cmake
|
|
@options = {}
|
|
|
|
configure
|
|
end
|
|
|
|
def to_s
|
|
@options
|
|
.reject {|name, (type, value)| value.nil?}
|
|
.collect {|name, (type, value)| "-D #{name}=#{value == true ? "ON" : value == false ? "OFF" : value.shellescape}"}
|
|
.join(" ")
|
|
end
|
|
|
|
def cmake_options
|
|
return @cmake_options if @cmake_options
|
|
|
|
output = nil
|
|
Dir.chdir __dir__ do
|
|
output = `#{@cmake.shellescape} -S sources -B build -L`
|
|
end
|
|
started = false
|
|
@cmake_options = output.lines.filter_map {|line|
|
|
if line.chomp == "-- Cache values"
|
|
started = true
|
|
next
|
|
end
|
|
next unless started
|
|
option, value = line.chomp.split("=", 2)
|
|
name, type = option.split(":", 2)
|
|
[name, type, value]
|
|
}
|
|
end
|
|
|
|
private
|
|
|
|
def configure
|
|
cmake_options.each do |name, type, default_value|
|
|
option = option_name(name)
|
|
value = type == "BOOL" ? enable_config(option) : arg_config("--#{option}")
|
|
@options[name] = [type, value]
|
|
end
|
|
end
|
|
|
|
def option_name(name)
|
|
name.downcase.gsub("_", "-")
|
|
end
|
|
end
|