xmake.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package("blah")
  2. set_homepage("https://github.com/NoelFB/blah")
  3. set_description("A small 2d c++ game framework")
  4. set_license("MIT")
  5. add_urls("https://github.com/NoelFB/blah.git")
  6. add_versions("2023.01.03", "a0cccca457cfb91213fae6e4e994d1c181c358fe")
  7. add_deps("cmake")
  8. add_deps("libsdl2 >=2.26")
  9. if is_plat("macosx") then
  10. add_frameworks("ForceFeedback", "CoreVideo", "CoreGraphics", "CoreFoundation", "Foundation", "AppKit", "IOKit")
  11. elseif is_plat("windows") then
  12. add_syslinks("d3d11", "d3dcompiler", "dxguid")
  13. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  14. end
  15. on_install("windows", "macosx", "linux", function (package)
  16. local configs = {}
  17. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  18. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  19. io.replace("CMakeLists.txt", "if (NOT DEFINED BLAH_SDL2_LIBS)", "IF(FALSE)", {plain = true})
  20. import("package.tools.cmake").build(package, configs, {buildir = "build", packagedeps = "libsdl2"})
  21. os.cp("include", package:installdir())
  22. os.trycp("build/*.a", package:installdir("lib"))
  23. os.trycp("build/*.so", package:installdir("lib"))
  24. os.trycp("build/*.dylib", package:installdir("lib"))
  25. os.trycp("build/**.lib", package:installdir("lib"))
  26. os.trycp("build/**.dll", package:installdir("bin"))
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. using namespace Blah;
  31. Batch batch;
  32. int test() {
  33. Config config;
  34. config.name = "blah app";
  35. config.on_render = []() {
  36. auto target = App::backbuffer();
  37. target->clear(Color::black);
  38. auto center = Vec2f(target->width(), target->height()) / 2;
  39. auto rotation = Time::seconds * Calc::TAU;
  40. auto transform = Mat3x2f::create_transform(center, Vec2f::zero, Vec2f::one, rotation);
  41. batch.push_matrix(transform);
  42. batch.rect(Rectf(-32, -32, 64, 64), Color::red);
  43. batch.pop_matrix();
  44. batch.render(target);
  45. batch.clear();
  46. };
  47. return App::run(&config);
  48. }
  49. ]]}, {configs = {languages = "c++17"}, includes = {"blah.h"}}))
  50. end)