From 1eef7dac208c82aaf2480cb20c4ff2359230c22a Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 24 Apr 2023 22:55:30 +0800 Subject: add proto_autogendir #3678 --- xmake/rules/protobuf/proto.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xmake/rules/protobuf/proto.lua b/xmake/rules/protobuf/proto.lua index 9c20857ff..c416e61a3 100644 --- a/xmake/rules/protobuf/proto.lua +++ b/xmake/rules/protobuf/proto.lua @@ -88,13 +88,17 @@ function buildcmd(target, batchcmds, sourcefile_proto, opt, sourcekind) -- get c/c++ source file for protobuf local prefixdir + local autogendir local public local fileconfig = target:fileconfig(sourcefile_proto) if fileconfig then public = fileconfig.proto_public prefixdir = fileconfig.proto_rootdir + -- custom autogen directory to access the generated header files + -- @see https://github.com/xmake-io/xmake/issues/3678 + autogendir = fileconfig.proto_autogendir end - local rootdir = path.join(target:autogendir(), "rules", "protobuf") + local rootdir = autogendir and autogendir or path.join(target:autogendir(), "rules", "protobuf") local filename = path.basename(sourcefile_proto) .. ".pb" .. (sourcekind == "cxx" and ".cc" or "-c.c") local sourcefile_cx = target:autogenfile(sourcefile_proto, {rootdir = rootdir, filename = filename}) local sourcefile_dir = prefixdir and path.join(rootdir, prefixdir) or path.directory(sourcefile_cx) -- cgit v1.3.1