Thrift 编译器允许为生成的文件指定输出目录。
我正在编写 Java 客户端和 C# 服务器,我希望将 -gen java
和 -gen csharp
生成的文件放在不同的目录中我的项目。
这可能吗?
最佳答案
1。默认
... 文件按照 gen-<lang>
模式生成到每种语言的一个文件夹中.
thrift -gen java -gen csharp myfile.thrift
在您的情况下,这将是 gen-csharp
和 gen-java
.如果那不符合你的要求,试试
2。显式出路
通过 -out
参数,您可以告诉 Thrift 在您想要的任何文件夹中生成代码。唯一需要注意的是,必须事先创建这些目标文件夹。除了默认文件夹外,这些文件夹不会自动创建。
mkdir my/cool/javadir
mkdir my/cool/csdir
thrift -gen java -out my/cool/javadir myfile.thrift
thrift -gen csharp -out my/cool/csdir myfile.thrift
更多信息
输入 thrift -help
查看所有选项:
$ thrift -help
Usage: thrift [options] file
Options:
-version Print the compiler version
-o dir Set the output directory for gen-* packages
(default: current directory)
-out dir Set the ouput location for generated files.
(no gen-* folder will be created)
-I dir Add a directory to the list of directories
searched for include directives
-nowarn Suppress all compiler warnings (BAD!)
-strict Strict compiler warnings on
-v[erbose] Verbose mode
-r[ecurse] Also generate included files
-debug Parse debug trace to stdout
--allow-neg-keys Allow negative field keys (Used to preserve protocol
compatibility with older .thrift files)
--allow-64bit-consts Do not print warnings about using 64-bit constants
--gen STR Generate code with a dynamically-registered generator.
STR has the form language[:key1=val1[,key2[,key3=val3]]].
Keys and values are options passed to the generator.
Many options will not require values.
Available generators (and options):
(... more options ...)
长话短说
Is it possible?
是的,是的。
关于java - Thrift 编译器——生成不同的语言到不同的输出路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30177646/