2024-05-22 20:02:52 +00:00
|
|
|
require 'rake/clean'
|
2024-10-16 15:44:04 +00:00
|
|
|
require "bundler/gem_tasks"
|
|
|
|
require "pathname"
|
|
|
|
require "yaml"
|
|
|
|
require "rake/testtask"
|
|
|
|
|
|
|
|
extsources = YAML.load_file("extsources.yaml")
|
2024-10-28 13:43:27 +00:00
|
|
|
SOURCES = FileList[]
|
|
|
|
extsources.each do |src|
|
|
|
|
basename = src.pathmap("%f")
|
|
|
|
dest = basename == "LICENSE" ? basename : basename.pathmap("ext/%f")
|
|
|
|
file src
|
|
|
|
file dest => src do |t|
|
|
|
|
cp t.source, t.name
|
2024-10-16 15:44:04 +00:00
|
|
|
end
|
2024-10-28 13:43:27 +00:00
|
|
|
SOURCES.include dest
|
2024-10-16 15:44:04 +00:00
|
|
|
end
|
|
|
|
CLEAN.include SOURCES
|
2024-10-28 11:08:09 +00:00
|
|
|
CLEAN.include FileList[
|
|
|
|
"ext/*.o",
|
|
|
|
"ext/*.metal",
|
|
|
|
"ext/whisper.{so,bundle,dll}",
|
|
|
|
"ext/depend"
|
|
|
|
]
|
2024-10-16 15:44:04 +00:00
|
|
|
|
|
|
|
task build: SOURCES + FileList[
|
|
|
|
"ext/extconf.rb",
|
|
|
|
"ext/ruby_whisper.h",
|
|
|
|
"ext/ruby_whisper.cpp",
|
|
|
|
"whispercpp.gemspec",
|
|
|
|
]
|
|
|
|
|
|
|
|
directory "pkg"
|
|
|
|
CLOBBER.include "pkg"
|
|
|
|
|
|
|
|
TEST_MODEL = "../../models/ggml-base.en.bin"
|
|
|
|
LIB_NAME = "whisper".ext(RbConfig::CONFIG["DLEXT"])
|
|
|
|
LIB_FILE = File.join("lib", LIB_NAME)
|
|
|
|
|
|
|
|
directory "lib"
|
|
|
|
task LIB_FILE => SOURCES + ["lib"] do |t|
|
|
|
|
Dir.chdir "ext" do
|
|
|
|
sh "ruby extconf.rb"
|
|
|
|
sh "make"
|
|
|
|
end
|
|
|
|
mv "ext/#{LIB_NAME}", t.name
|
|
|
|
end
|
|
|
|
CLEAN.include LIB_FILE
|
|
|
|
|
|
|
|
Rake::TestTask.new do |t|
|
|
|
|
t.test_files = FileList["tests/test_*.rb"]
|
|
|
|
end
|
|
|
|
task test: [TEST_MODEL, LIB_FILE]
|
|
|
|
|
|
|
|
file TEST_MODEL do
|
|
|
|
Dir.chdir "../.." do
|
|
|
|
sh "./models/download-ggml-model.sh base.en"
|
|
|
|
end
|
2024-05-22 20:02:52 +00:00
|
|
|
end
|