Skip to content

Commit 8fc9a1d

Browse files
committed
Add task to make Makefile
1 parent 99b7303 commit 8fc9a1d

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

bindings/ruby/Rakefile

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,39 @@ CLEAN.include FileList[
2323
"ext/depend"
2424
]
2525

26-
task build: SOURCES + FileList[
27-
"ext/extconf.rb",
28-
"ext/ruby_whisper.h",
29-
"ext/ruby_whisper.cpp",
30-
"whispercpp.gemspec",
31-
]
26+
task build: FileList[
27+
"ext/Makefile",
28+
"ext/ruby_whisper.h",
29+
"ext/ruby_whisper.cpp",
30+
"whispercpp.gemspec",
31+
]
3232

3333
directory "pkg"
3434
CLOBBER.include "pkg"
3535

3636
TEST_MODEL = "../../models/ggml-base.en.bin"
3737
LIB_NAME = "whisper".ext(RbConfig::CONFIG["DLEXT"])
38+
SO_FILE = File.join("ext", LIB_NAME)
3839
LIB_FILE = File.join("lib", LIB_NAME)
3940

40-
directory "lib"
41-
task LIB_FILE => SOURCES + ["lib"] do |t|
41+
file "ext/Makefile" => ["ext/extconf.rb"] + SOURCES do |t|
42+
Dir.chdir "ext" do
43+
ruby "extconf.rb"
44+
end
45+
end
46+
47+
file SO_FILE => "ext/Makefile" do |t|
4248
Dir.chdir "ext" do
43-
sh "ruby extconf.rb"
4449
sh "make"
4550
end
46-
mv "ext/#{LIB_NAME}", t.name
4751
end
4852
CLEAN.include LIB_FILE
4953

54+
directory "lib"
55+
file LIB_FILE => [SO_FILE, "lib"] do |t|
56+
copy t.source, t.name
57+
end
58+
5059
Rake::TestTask.new do |t|
5160
t.test_files = FileList["tests/test_*.rb"]
5261
end

0 commit comments

Comments
 (0)