xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("s7")
  2. set_homepage("https://ccrma.stanford.edu/software/snd/snd/s7.html")
  3. set_description("s7 is a Scheme interpreter intended as an extension language for other applications.")
  4. add_urls("https://github.com/xmake-mirror/s7.git",
  5. "https://cm-gitlab.stanford.edu/bil/s7.git")
  6. add_versions("2023.04.13", "505f98d69be3d9c48e096d6787d2f85c27cb3924")
  7. add_configs("gmp", {description = "enable gmp support", default = false, type = "boolean"})
  8. on_load(function (package)
  9. package:addenv("PATH", "bin")
  10. if package:config("gmp") then
  11. package:add("deps", "gmp")
  12. end
  13. end)
  14. if is_plat("linux") then
  15. add_syslinks("pthread", "dl", "m")
  16. end
  17. on_install("bsd", "cross", "cygwin", "linux", "macosx", "mingw", "msys", "wasm", "windows", function (package)
  18. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  19. local configs = {}
  20. if package:config("shared") then
  21. configs.kind = "shared"
  22. end
  23. import("package.tools.xmake").install(package, configs)
  24. end)
  25. on_test(function(package)
  26. if not package:is_cross() then
  27. local file = os.tmpfile() .. ".scm"
  28. io.writefile(file, [[
  29. (display "Hello World!")
  30. ]])
  31. os.vrunv("s7", {file})
  32. end
  33. assert(package:check_csnippets([[
  34. static s7_pointer old_add; /* the original "+" function for non-string cases */
  35. static s7_pointer old_string_append; /* same, for "string-append" */
  36. static s7_pointer our_add(s7_scheme *sc, s7_pointer args)
  37. {
  38. /* this will replace the built-in "+" operator, extending it to include strings:
  39. * (+ "hi" "ho") -> "hiho" and (+ 3 4) -> 7
  40. */
  41. if ((s7_is_pair(args)) &&
  42. (s7_is_string(s7_car(args))))
  43. return(s7_apply_function(sc, old_string_append, args));
  44. return(s7_apply_function(sc, old_add, args));
  45. }
  46. ]], {includes = "s7.h"}))
  47. end)