From f80fdc97ee6f25eb525f1105011e2d2fe2283d76 Mon Sep 17 00:00:00 2001 From: wsw0108 Date: Thu, 8 Jul 2021 21:02:09 +0800 Subject: add test project for rule 'capnproto.cpp' --- tests/projects/c++/capnproto/proto/message.capnp | 8 ++++++++ tests/projects/c++/capnproto/src/main.cc | 7 +++++++ tests/projects/c++/capnproto/xmake.lua | 9 +++++++++ xmake/rules/capnproto/capnp.lua | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/projects/c++/capnproto/proto/message.capnp create mode 100644 tests/projects/c++/capnproto/src/main.cc create mode 100644 tests/projects/c++/capnproto/xmake.lua diff --git a/tests/projects/c++/capnproto/proto/message.capnp b/tests/projects/c++/capnproto/proto/message.capnp new file mode 100644 index 000000000..7109294ed --- /dev/null +++ b/tests/projects/c++/capnproto/proto/message.capnp @@ -0,0 +1,8 @@ +@0xd30600b3651feef7; + +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("test::proto"); + +struct Message { + text @0 :Text; +} diff --git a/tests/projects/c++/capnproto/src/main.cc b/tests/projects/c++/capnproto/src/main.cc new file mode 100644 index 000000000..8145c6cba --- /dev/null +++ b/tests/projects/c++/capnproto/src/main.cc @@ -0,0 +1,7 @@ +#include +#include "message.capnp.h" + +int main() { + capnp::MallocMessageBuilder builder; + // test::proto::Message msg; +} diff --git a/tests/projects/c++/capnproto/xmake.lua b/tests/projects/c++/capnproto/xmake.lua new file mode 100644 index 000000000..d4859dabb --- /dev/null +++ b/tests/projects/c++/capnproto/xmake.lua @@ -0,0 +1,9 @@ +add_rules("mode.debug", "mode.release") +add_requires("capnproto") + +target("test") + set_kind("binary") + set_languages("c++14") + add_packages("capnproto") + add_files("src/**.cc") + add_files("proto/*.capnp", {rules = "capnproto.cpp", capnp_rootdir = "proto"}) diff --git a/xmake/rules/capnproto/capnp.lua b/xmake/rules/capnproto/capnp.lua index 0125a50f5..05114cced 100644 --- a/xmake/rules/capnproto/capnp.lua +++ b/xmake/rules/capnproto/capnp.lua @@ -78,7 +78,7 @@ function buildcmd(target, batchcmds, sourcefile_capnp, opt) table.insert(argv, sourcefile_capnp) batchcmds:vrunv(capnp, argv) local configs = {includedirs = sourcefile_dir, languages = "c++14"} - if is_plat("windows") then + if package:is_plat("windows") then configs.cxflags = "/TP" end batchcmds:compile(sourcefile_cx, objectfile, {sourcekind = "cxx", configs = configs}) -- cgit v1.3.1