xmake.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package("cppfront")
  2. set_kind("toolchain")
  3. set_homepage("https://github.com/hsutter/cppfront")
  4. set_description("A personal experimental C++ Syntax 2 -> Syntax 1 compiler")
  5. add_urls("https://github.com/hsutter/cppfront/archive/refs/tags/$(version).tar.gz")
  6. add_urls("https://github.com/hsutter/cppfront.git")
  7. add_versions("v0.7.1", "57f839e8a0a63852941f898eb5d9db8c4fd6659b87cb68c4ec14ab9c069d1941")
  8. add_versions("v0.7.0", "d4ffb37d19a2b7c054d005cf4687439577ef2f3d93b340a342704e064cd1d047")
  9. on_fetch(function (package, opt)
  10. if opt.system then
  11. return package:find_tool("cppfront", {check = "-h"})
  12. end
  13. end)
  14. on_install("windows", "linux", "macosx|x86_64", function (package)
  15. local configs = {}
  16. io.writefile("xmake.lua", [[
  17. add_rules("mode.release", "mode.debug")
  18. target("cppfront")
  19. set_kind("binary")
  20. add_files("source/*.cpp")
  21. add_includedirs("include")
  22. set_languages("c++20")
  23. ]])
  24. import("package.tools.xmake").install(package, configs)
  25. os.cp("include", package:installdir())
  26. end)
  27. on_test(function (package)
  28. io.writefile("main.cpp2", [[
  29. main: () -> int =
  30. println("Hello world!\n");
  31. println: (msg: _) -> int = {
  32. std::cout << "msg: " << msg;
  33. return 0;
  34. }]])
  35. os.vrun("cppfront -o main.cpp main.cpp2")
  36. end)