xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package("liboai")
  2. set_homepage("https://github.com/D7EAD/liboai")
  3. set_description("A C++17 library to access the entire OpenAI API.")
  4. set_license("MIT")
  5. set_urls("https://github.com/D7EAD/liboai/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/D7EAD/liboai.git")
  7. add_versions("v4.0.1", "abe127ae1cd3049f19976e31d8414e8130a73d7978552e863b767fe04b20697f")
  8. add_versions("v3.2.1", "9058bcc1485967061c9c33b2e7a109a254cdf71638b1448f21cfefd7ffd9c4fa")
  9. add_deps("nlohmann_json")
  10. add_deps("libcurl", {configs = {openssl = true, zlib = true}})
  11. on_install("windows", "linux", "macosx", function (package)
  12. io.writefile("xmake.lua", [[
  13. add_rules("mode.debug", "mode.release")
  14. add_requires("nlohmann_json")
  15. add_requires("libcurl", {configs = {openssl = true, zlib = true}})
  16. target("oai")
  17. set_kind("$(kind)")
  18. set_languages("c++17")
  19. add_files("liboai/**.cpp")
  20. add_includedirs("liboai/include")
  21. add_headerfiles("liboai/include/(**.h)")
  22. if is_plat("windows") and is_kind("shared") then
  23. add_rules("utils.symbols.export_all", {export_classes = true})
  24. end
  25. add_packages("nlohmann_json", "libcurl")
  26. ]])
  27. import("package.tools.xmake").install(package)
  28. end)
  29. on_test(function (package)
  30. assert(package:check_cxxsnippets({test = [[
  31. #include <liboai.h>
  32. using namespace liboai;
  33. void test() {
  34. OpenAI oai;
  35. oai.auth.SetKeyEnv("OPENAI_API_KEY");
  36. Response res = oai.Image->create(
  37. "A snake in the grass!",
  38. 1,
  39. "256x256"
  40. );
  41. }
  42. ]]}, {configs = {languages = "c++17"}}))
  43. end)