xmake.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package("datatype99")
  2. set_kind("library", { headeronly = true })
  3. set_homepage("https://github.com/Hirrolot/datatype99")
  4. set_description("Algebraic data types for C99")
  5. set_license("MIT")
  6. add_urls("https://github.com/Hirrolot/datatype99/archive/refs/tags/v$(version).tar.gz",
  7. "https://github.com/Hirrolot/datatype99.git")
  8. add_versions("1.6.3", "0ddc138eac8db19fa22c482d9a2ec107ff622fd7ce61bb0b1eefb4d8f522e01e")
  9. add_versions("1.6.4", "f8488decc7ab035e3af77ee62e64fc678d5cb57831457f7270efe003e63d6f09")
  10. add_deps("metalang99")
  11. on_install(function(package)
  12. os.cp("*.h", package:installdir("include"))
  13. end)
  14. on_test(function(package)
  15. assert(package:check_csnippets({test = [[
  16. #include <assert.h>
  17. datatype(
  18. BinaryTree,
  19. (Leaf, int),
  20. (Node, BinaryTree *, int, BinaryTree *)
  21. );
  22. int sum(const BinaryTree *tree) {
  23. match(*tree) {
  24. of(Leaf, x) return *x;
  25. of(Node, lhs, x, rhs) return sum(*lhs) + *x + sum(*rhs);
  26. }
  27. return -1;
  28. }
  29. void test() {
  30. BinaryTree leaf5 = Leaf(5);
  31. BinaryTree leaf7 = Leaf(7);
  32. BinaryTree node = Node(&leaf5, 123, &leaf7);
  33. assert(sum(&node) == 135);
  34. }
  35. ]]}, { configs = { languages = "c11" }, includes = "datatype99.h" }))
  36. end)