xmake.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_urls("https://github.com/D7EAD/liboai/archive/refs/tags/v$(version).tar.gz",
  5. "https://github.com/D7EAD/liboai.git")
  6. add_versions("3.2.1", "9058bcc1485967061c9c33b2e7a109a254cdf71638b1448f21cfefd7ffd9c4fa")
  7. add_versions("3.1.0", "4b3564740f7dbf099c785d5720327a4e7acaca2535d329f487d877ce17524a73")
  8. add_deps("nlohmann_json")
  9. add_deps("libcurl", {configs = {openssl = true, zlib = true}})
  10. on_install("windows", "linux", "macosx", function (package)
  11. local configs = {}
  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. if package:config("shared") then
  28. configs.kind = "shared"
  29. end
  30. import("package.tools.xmake").install(package, configs)
  31. end)
  32. on_test(function (package)
  33. assert(package:check_cxxsnippets({test = [[
  34. #include <liboai.h>
  35. using namespace liboai;
  36. void test() {
  37. OpenAI oai;
  38. oai.auth.SetKeyEnv("OPENAI_API_KEY");
  39. Response res = oai.Image->create(
  40. "A snake in the grass!",
  41. 1,
  42. "256x256"
  43. );
  44. }
  45. ]]}, {configs = {languages = "c++17"}}))
  46. end)