summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcarols <[email protected]>2024-04-07 19:44:02 +0800
committercarols <[email protected]>2024-04-07 19:44:02 +0800
commit014639a6dc483e72a9184504f466b9a464dc9748 (patch)
tree54c0c3fc6d07e384921c588cc26a6eac5fbdb1eb
parent99e57fc8e1ac160832860547e7d220254366a96a (diff)
Revert "Add cppfront's header(*.h2) support"
This reverts commit 99e57fc8e1ac160832860547e7d220254366a96a.
-rw-r--r--tests/projects/cppfront/console/src/main.cpp26
-rw-r--r--tests/projects/cppfront/console/src/println.h24
-rw-r--r--tests/projects/cppfront/console/xmake.lua1
-rw-r--r--xmake/rules/cppfront/xmake.lua63
4 files changed, 22 insertions, 52 deletions
diff --git a/tests/projects/cppfront/console/src/main.cpp2 b/tests/projects/cppfront/console/src/main.cpp2
index 4bf37d8c3..1ab54b94b 100644
--- a/tests/projects/cppfront/console/src/main.cpp2
+++ b/tests/projects/cppfront/console/src/main.cpp2
@@ -1,5 +1,7 @@
-#include "println.h2"
-
main: () -> int =
println("Hello world!\n");
+println: (msg: _) -> int = {
+ std::cout << msg;
+ return 0;
+}
diff --git a/tests/projects/cppfront/console/src/println.h2 b/tests/projects/cppfront/console/src/println.h2
deleted file mode 100644
index 24c244da4..000000000
--- a/tests/projects/cppfront/console/src/println.h2
+++ /dev/null
@@ -1,4 +0,0 @@
-println: (msg: _) -> int = {
- std::cout << msg;
- return 0;
-}
diff --git a/tests/projects/cppfront/console/xmake.lua b/tests/projects/cppfront/console/xmake.lua
index 4c99bfadb..65b68cd6e 100644
--- a/tests/projects/cppfront/console/xmake.lua
+++ b/tests/projects/cppfront/console/xmake.lua
@@ -6,6 +6,5 @@ target("test")
add_rules("cppfront")
set_kind("binary")
add_files("src/*.cpp2")
- add_files("src/*.h2")
add_packages("cppfront")
diff --git a/xmake/rules/cppfront/xmake.lua b/xmake/rules/cppfront/xmake.lua
index e0d535e7e..90153df85 100644
--- a/xmake/rules/cppfront/xmake.lua
+++ b/xmake/rules/cppfront/xmake.lua
@@ -20,7 +20,7 @@
-- define rule: cppfront.build
rule("cppfront.build")
- set_extensions(".cpp2", ".h2")
+ set_extensions(".cpp2")
on_load(function (target)
-- only cppfront source files? we need to patch cxx source kind for linker
local sourcekinds = target:sourcekinds()
@@ -35,58 +35,31 @@ rule("cppfront.build")
end
end
end)
- on_buildcmd_files(function (target, batchcmds, sourcebatch, opt)
- -- order files h2->cpp2
- cpp2_files = {}
- all_files = {}
- for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
- if string.endswith(sourcefile, ".h2") then
- table.insert(all_files, sourcefile)
- elseif string.endswith(sourcefile, ".cpp2") then
- table.insert(cpp2_files, sourcefile)
- end
- end
- table.join2(all_files, cpp2_files)
+ on_buildcmd_file(function (target, batchcmds, sourcefile_cpp2, opt)
-- get cppfront
import("lib.detect.find_tool")
local cppfront = assert(find_tool("cppfront", {check = "-h"}), "cppfront not found!")
- for _, sourcefile_cpp2 in ipairs(all_files) do -- get c++ source file for cpp2
- local sourcefile_cpp = ""
- local is_h2 = string.endswith(sourcefile_cpp2, ".h2")
- if is_h2 then
- sourcefile_cpp = target:autogenfile((sourcefile_cpp2:gsub(".h2$", ".h")))
- else
- sourcefile_cpp = target:autogenfile((sourcefile_cpp2:gsub(".cpp2$", ".cpp")))
- end
- local basedir = path.directory(sourcefile_cpp)
-
- -- add objectfile
- local objectfile = ""
- if not is_h2 then
- objectfile = target:objectfile(sourcefile_cpp)
- table.insert(target:objectfiles(), objectfile)
- end
+ -- get c++ source file for cpp2
+ local sourcefile_cpp = target:autogenfile((sourcefile_cpp2:gsub(".cpp2$", ".cpp")))
+ local basedir = path.directory(sourcefile_cpp)
- -- add commands
- local argv = {"-verb", "-e", "-o", path(sourcefile_cpp), path(sourcefile_cpp2)}
+ -- add objectfile
+ local objectfile = target:objectfile(sourcefile_cpp)
+ table.insert(target:objectfiles(), objectfile)
- batchcmds:show_progress(opt.progress, "${color.build.object}compiling.cpp2 %s", sourcefile_cpp2)
- batchcmds:mkdir(basedir)
- batchcmds:vrunv(cppfront.program, argv)
- if not is_h2 then
- batchcmds:compile(sourcefile_cpp, objectfile, {configs = {languages = "c++20"}})
- end
+ -- add commands
+ local argv = {"-o", path(sourcefile_cpp), path(sourcefile_cpp2)}
+ batchcmds:show_progress(opt.progress, "${color.build.object}compiling.cpp2 %s", sourcefile_cpp2)
+ batchcmds:mkdir(basedir)
+ batchcmds:vrunv(cppfront.program, argv)
+ batchcmds:compile(sourcefile_cpp, objectfile, {configs = {languages = "c++20"}})
- -- add deps
- batchcmds:add_depfiles(sourcefile_cpp2)
- if not is_h2 then
- batchcmds:set_depmtime(os.mtime(objectfile))
- batchcmds:set_depcache(target:dependfile(objectfile))
- end
- end
-
+ -- add deps
+ batchcmds:add_depfiles(sourcefile_cpp2)
+ batchcmds:set_depmtime(os.mtime(objectfile))
+ batchcmds:set_depcache(target:dependfile(objectfile))
end)