mirror of
https://github.com/ggml-org/whisper.cpp.git
synced 2026-07-23 11:10:57 -05:00
* Change MemoryView example using NDAV * Add note on audio attributes for #full and #full_parallel * Support more variants of MemoryView * Use IO.popen instead of Kernel.` for Windows compatibility * Use cmake's -C option instead of multiple -D options * Fix memsize calculation * Remove unused argument * Add is_interrupted field to abort callback container * Fix RBS syntax * Address document comment for RDoc * Add .document for RDoc * Add .rdoc_options * Run #full without GVL * Initialize callbacks with nil * Specify implicity Whisper::Params to distinguish from Whisper::Context::Params * Run callbacks without GVL * Call log callback with GVL * Run full_parallel without GVL * Run transcribe without GVL * Fix ruby_whisper_lock_gvl and ruby_whisper_unlock_gvl * Fix return value of encoder_begin_callback * Report GVL unlocking from transcribe * Remove unused interface * Restore overload of full_parallel * Close process * Fix struct name * Make is_without_gvl thread local * Use rb_thread_call_with_gvl instead of global variable * Retrieve instance variable in GVL * Narrow acceptable MemoryView format * Fix option cache path * Reduce files in package * Use append_cflags * Add ext/*.rb to task dependencies * Use copy instead of cp * Make TestPackage more portable * Patch for lower version Ruby * Make build scripts more portable * Add Windows support * Don't raise exceptions
80 lines
1.6 KiB
Ruby
80 lines
1.6 KiB
Ruby
require "tsort"
|
|
|
|
class Dependencies
|
|
include TSort
|
|
|
|
def initialize(cmake, options)
|
|
@cmake = cmake
|
|
@options = options
|
|
@static_lib_shape = nil
|
|
@nodes = {}
|
|
@graph = Hash.new {|h, k| h[k] = []}
|
|
|
|
generate_dot
|
|
parse_dot
|
|
end
|
|
|
|
def libs
|
|
tsort.filter_map {|node|
|
|
label, shape = @nodes[node]
|
|
if shape == @static_lib_shape
|
|
label.gsub(/\\n\([^)]+\)/, '')
|
|
else
|
|
nil
|
|
end
|
|
}.reverse.collect {|lib| "#{prefix(lib)}#{lib}.#{RbConfig::CONFIG['LIBEXT']}"}
|
|
end
|
|
|
|
def to_s
|
|
libs.join(" ")
|
|
end
|
|
|
|
def local_libs
|
|
to_s
|
|
end
|
|
|
|
private
|
|
|
|
def dot_path
|
|
File.join(__dir__, "build", "whisper.cpp.dot")
|
|
end
|
|
|
|
def generate_dot
|
|
system @cmake, "-S", "sources", "-B", "build", *@options.graphviz_cmake_args, "--graphviz", dot_path, *@options, exception: true
|
|
end
|
|
|
|
def parse_dot
|
|
File.open(dot_path).each_line do |line|
|
|
case line
|
|
when /\[\s*label\s*=\s*"Static Library"\s*,\s*shape\s*=\s*(?<shape>\w+)\s*\]/
|
|
@static_lib_shape = $~[:shape]
|
|
when /\A\s*"(?<node>\w+)"\s*\[\s*label\s*=\s*"(?<label>\S+)"\s*,\s*shape\s*=\s*(?<shape>\w+)\s*\]\s*;\s*\z/
|
|
node = $~[:node]
|
|
label = $~[:label]
|
|
shape = $~[:shape]
|
|
@nodes[node] = [label, shape]
|
|
when /\A\s*"(?<depender>\w+)"\s*->\s*"(?<dependee>\w+)"/
|
|
depender = $~[:depender]
|
|
dependee = $~[:dependee]
|
|
@graph[depender] << dependee
|
|
end
|
|
end
|
|
end
|
|
|
|
def prefix(lib)
|
|
"lib"
|
|
end
|
|
|
|
def tsort_each_node
|
|
@nodes.each_key do |node|
|
|
yield node
|
|
end
|
|
end
|
|
|
|
def tsort_each_child(node)
|
|
@graph[node].each do |child|
|
|
yield child
|
|
end
|
|
end
|
|
end
|