Browse Source

update cppfront (#2533)

* update cppfront

* format code

* improve to find cppfront

* use toolchain
ruki 2 năm trước cách đây
mục cha
commit
478d44de35
1 tập tin đã thay đổi với 18 bổ sung4 xóa
  1. 18 4
      packages/c/cppfront/xmake.lua

+ 18 - 4
packages/c/cppfront/xmake.lua

@@ -1,10 +1,16 @@
 package("cppfront")
 package("cppfront")
-    set_kind("binary")
+    set_kind("toolchain")
     set_homepage("https://github.com/hsutter/cppfront")
     set_homepage("https://github.com/hsutter/cppfront")
     set_description("A personal experimental C++ Syntax 2 -> Syntax 1 compiler")
     set_description("A personal experimental C++ Syntax 2 -> Syntax 1 compiler")
 
 
     add_urls("https://github.com/hsutter/cppfront.git")
     add_urls("https://github.com/hsutter/cppfront.git")
-    add_versions("2022.09.23", "fa65d346996ec472e16c61838fbc7a47736d7872")
+    add_versions("2023.08.29", "b757afd9b0051a40278706cdfc57971e371e4e32")
+
+    on_fetch(function (package, opt)
+        if opt.system then
+            return package:find_tool("cppfront", {check = "-h"})
+        end
+    end)
 
 
     on_install("windows", "linux", function (package)
     on_install("windows", "linux", function (package)
         local configs = {}
         local configs = {}
@@ -17,9 +23,17 @@ package("cppfront")
                set_languages("c++20")
                set_languages("c++20")
         ]])
         ]])
         import("package.tools.xmake").install(package, configs)
         import("package.tools.xmake").install(package, configs)
+        os.cp("include", package:installdir())
     end)
     end)
 
 
     on_test(function (package)
     on_test(function (package)
-        os.touch("test.cpp2")
-        os.vrun("cppfront test.cpp2")
+        io.writefile("main.cpp2", [[
+        main: () -> int =
+            println("Hello world!\n");
+
+        println: (msg: _) -> int = {
+            std::cout << "msg: " << msg;
+            return 0;
+        }]])
+        os.vrun("cppfront -o main.cpp main.cpp2")
     end)
     end)