xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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("4.0.1", "abe127ae1cd3049f19976e31d8414e8130a73d7978552e863b767fe04b20697f")
  7. add_versions("3.2.1", "9058bcc1485967061c9c33b2e7a109a254cdf71638b1448f21cfefd7ffd9c4fa")
  8. add_versions("3.1.0", "4b3564740f7dbf099c785d5720327a4e7acaca2535d329f487d877ce17524a73")
  9. add_deps("nlohmann_json")
  10. add_deps("libcurl", {configs = {openssl = true, zlib = true}})
  11. on_install("windows", "linux", "macosx", function (package)
  12. local configs = {}
  13. io.writefile("xmake.lua", [[
  14. add_rules("mode.debug", "mode.release")
  15. add_requires("nlohmann_json")
  16. add_requires("libcurl", {configs = {openssl = true, zlib = true}})
  17. target("oai")
  18. set_kind("$(kind)")
  19. set_languages("c++17")
  20. add_files("liboai/**.cpp")
  21. add_includedirs("liboai/include")
  22. add_headerfiles("liboai/include/(**.h)")
  23. if is_plat("windows") and is_kind("shared") then
  24. add_rules("utils.symbols.export_all", {export_classes = true})
  25. end
  26. add_packages("nlohmann_json", "libcurl")
  27. ]])
  28. if package:config("shared") then
  29. configs.kind = "shared"
  30. end
  31. import("package.tools.xmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. assert(package:check_cxxsnippets({test = [[
  35. #include <liboai.h>
  36. using namespace liboai;
  37. void test() {
  38. OpenAI oai;
  39. oai.auth.SetKeyEnv("OPENAI_API_KEY");
  40. Response res = oai.Image->create(
  41. "A snake in the grass!",
  42. 1,
  43. "256x256"
  44. );
  45. }
  46. ]]}, {configs = {languages = "c++17"}}))
  47. end)