require "mkmf" require "tsort" # TODO: options such as CoreML cmake = find_executable("cmake") || abort have_library("gomp") rescue nil prefix = File.join("build", "whisper.cpp.dot") system cmake, "-S", "sources", "-B", "build", "--graphviz", prefix, "-D", "BUILD_SHARED_LIBS=OFF", exception: true static_lib_shape = nil nodes = {} depends = {} class << depends include TSort alias tsort_each_node each_key def tsort_each_child(node, &block) fetch(node, []).each(&block) end end File.open(File.join("build", "whisper.cpp.dot")).each_line do |line| case line when /\[\s*label\s*=\s*"Static Library"\s*,\s*shape\s*=\s*(?\w+)\s*\]/ static_lib_shape = $~[:shape] when /\A\s*"(?\w+)"\s*\[\s*label\s*=\s*"(?