xmake.lua 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package("whisper.cpp")
  2. set_homepage("https://github.com/ggerganov/whisper.cpp")
  3. set_description("Port of OpenAI's Whisper model in C/C++")
  4. set_urls("https://github.com/ggerganov/whisper.cpp/archive/refs/tags/v$(version).tar.gz",
  5. "https://github.com/ggerganov/whisper.cpp.git")
  6. add_versions("1.7.2", "d48e1b5b6ee18b931e98ac791eba838f83eb3b81bb8917db37fe9a79fa5e3ccb")
  7. add_versions("1.6.2", "da7988072022acc3cfa61b370b3c51baad017f1900c3dc4e68cb276499f66894")
  8. add_versions("1.6.0", "2729a83662edf909dad66115a3b616c27011cbe4c05335656034954c91ba0c92")
  9. add_versions("1.5.5", "27fa5c472657af2a6cee63de349a34b23d0f3781fa9b8ef301a940cf64964a79")
  10. add_versions("1.5.4", "06eed84de310fdf5408527e41e863ac3b80b8603576ba0521177464b1b341a3a")
  11. add_versions("1.4.2", "1b988dcc77fca55f188dbc4e472f971a80854c1d44309cf3eaab9d5677f175e1")
  12. add_patches("1.4.2", path.join(os.scriptdir(), "patches", "1.4.2", "fix.patch"), "1330bdbb769aad37f0de6998ac9b0107423ec62385bbfb0a89a98c226daace48")
  13. add_configs("avx", { description = "Enable AVX", default = true, type = "boolean"})
  14. add_configs("avx2", { description = "Enable AVX2", default = true, type = "boolean"})
  15. add_configs("fma", { description = "Enable FMA", default = true, type = "boolean"})
  16. add_configs("f16c", { description = "Enable F16c", default = true, type = "boolean"})
  17. if is_plat("macosx") then
  18. add_configs("accelerate", { description = "Enable Accelerate framework", default = true, type = "boolean"})
  19. add_configs("coreml", { description = "Enable Core ML framework", default = false, type = "boolean"})
  20. add_configs("coreml_allow_fallback", { description = "Allow non-CoreML fallback", default = false, type = "boolean"})
  21. else
  22. add_configs("openblas", { description = "Support for OpenBLAS", default = false, type = "boolean", readonly = true})
  23. add_configs("cublas", { description = "Support for cuBLAS", default = false, type = "boolean", readonly = true})
  24. add_configs("clblast", { description = "use CLBlast", default = false, type = "boolean", readonly = true})
  25. end
  26. add_configs("perf", { description = "Enable perf timings", default = false, type = "boolean"})
  27. add_deps("cmake")
  28. on_install("windows", "linux", "mingw", "msys", "android", "wasm", function (package)
  29. local configs = {"-DWHISPER_BUILD_TESTS=OFF", "-DWHISPER_BUILD_EXAMPLES=OFF"}
  30. table.insert(configs, "-DWHISPER_NO_AVX=" .. (package:config("avx") and "OFF" or "ON"))
  31. table.insert(configs, "-DWHISPER_NO_AVX2=" .. (package:config("avx2") and "OFF" or "ON"))
  32. table.insert(configs, "-DWHISPER_NO_FMA=" .. (package:config("fma") and "OFF" or "ON"))
  33. table.insert(configs, "-DWHISPER_NO_F16C=" .. (package:config("f16c") and "OFF" or "ON"))
  34. if package:is_plat("macosx") then
  35. table.insert(configs, "-DWHISPER_NO_ACCELERATE=" .. (package:config("accelerate") and "OFF" or "ON"))
  36. table.insert(configs, "-DWHISPER_COREML=" .. (package:config("coreml") and "ON" or "OFF"))
  37. table.insert(configs, "-DWHISPER_COREML_ALLOW_FALLBACK=" .. (package:config("coreml_allow_fallback") and "ON" or "OFF"))
  38. else
  39. table.insert(configs, "-DWHISPER_OPENBLAS=" .. (package:config("openblas") and "ON" or "OFF"))
  40. table.insert(configs, "-DWHISPER_CUBLAS=" .. (package:config("cublas") and "ON" or "OFF"))
  41. table.insert(configs, "-DWHISPER_CLBLAST=" .. (package:config("clblast") and "ON" or "OFF"))
  42. end
  43. table.insert(configs, "-DWHISPER_PERF=" .. (package:config("perf") and "ON" or "OFF"))
  44. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  45. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  46. if package:is_plat("mingw") then
  47. table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=" .. package:arch())
  48. end
  49. import("package.tools.cmake").install(package, configs)
  50. end)
  51. on_test(function (package)
  52. assert(package:check_cxxsnippets({test = [[
  53. void test() {
  54. whisper_context* ctx = whisper_init_from_file("ggml-base.en.bin");
  55. }
  56. ]]}, {includes = {"whisper.h"}}))
  57. end)