java - Thrift 编译器——生成不同的语言到不同的输出路径

标签 java c# thrift

Thrift 编译器允许为生成的文件指定输出目录。

我正在编写 Java 客户端和 C# 服务器,我希望将 -gen java-gen csharp 生成的文件放在不同的目录中我的项目。

这可能吗?

最佳答案

1。默认

... 文件按照 gen-<lang> 模式生成到每种语言的一个文件夹中.

thrift -gen java -gen csharp myfile.thrift

在您的情况下,这将是 gen-csharpgen-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/

相关文章:

javascript Thrift 客户端挂起

使用 URLClassLoader 加载类时出现 java.lang.ClassNotFoundException

java - GoogleApiClient卡在连接状态,debug不报错

c# - <ImportWindowsDesktopTargets> 在 try-convert 生成的 *.csproj 中做什么?

c# - 为什么我的 try/catch block 没有捕获 System.AggregateException?

java - 使用 Thrift 进行离线序列化?

java - 为元素创建 XPATH - Selenium

java - 需要有关 ArrayList 和 Stack 的帮助

c# - 使用 let 变量和子查询重构 LINQ to Entities 查询

haskell - 使用 Haskell 和 Thrift 进行 Ping Pong 卡住