gpt4 book ai didi

java - 如何在单个命令中编译多个原型(prototype)文件?

转载 作者:搜寻专家 更新时间:2023-10-30 21:19:53 24 4
gpt4 key购买 nike

我在一个目录中有两个 proto 文件,我正在寻找一种在单个命令中从这些文件生成类的方法。这似乎可以通过 --proto_path 参数来完成。根据文档:

You must provide one or more .proto files as input. Multiple .proto files can be specified at once. Although the files are named relative to the current directory, each file must reside in one of the IMPORT_PATHs [specified by the --proto_path argument] so that the compiler can determine its canonical name.

C:\shekhar\proto_trial>dir
Volume in drive C is C

Directory of C:\shekhar\proto_trial

07/25/2014 12:16 PM <DIR> .
07/25/2014 12:16 PM <DIR> ..
07/25/2014 12:16 PM <DIR> java_op
07/25/2014 12:16 PM 230 map.proto
07/23/2014 04:24 PM 161 message.proto
07/25/2014 12:17 PM 1,228 response.proto
3 File(s) 1,619 bytes
3 Dir(s) 50,259,398,656 bytes free

我使用了 --proto_path 参数,如下所示

C:\shekhar\proto_trial>protoc 
--proto_path=C:\shekhar\proto_trial
--java_out=C:\shekhar\proto_trial\java_op
*.proto

但是我得到以下错误

message.proto: File does not reside within any path specified using --proto_path (or -I). 
You must specify a --proto_path which encompasses this file.
Note that the proto_path must be an exact prefix of the .proto file names -- protoc is unable to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).

请提出一些将所有原型(prototype)文件一次性编译在一起的方法。

最佳答案

问题是您将 --proto_path 指定为绝对路径,但将原型(prototype)文件指定为相对路径。您可以删除 --proto_path 参数(它默认为当前目录),或者您可以这样做:

protoc --proto_path=C:\shekhar\proto_trial
--java_out=C:\shekhar\proto_trial\java_op
C:\shekhar\proto_trial\*.proto

关于java - 如何在单个命令中编译多个原型(prototype)文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24949801/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com