thrift
TLDR
Generate code for a specific language from a Thrift file
SYNOPSIS
thrift [-o dir] [-out dir] [-I dir] [-nowarn] [-strict] [-v] [-r] [-debug] --gen lang[:options] file.thrift
DESCRIPTION
thrift is the compiler for Apache Thrift, a framework for scalable cross-language services development. It combines a software stack with a code generation engine to build efficient and seamless services between languages like C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, JavaScript, Node.js, and more.
The compiler reads a Thrift Interface Definition Language (IDL) file containing struct and service definitions, then generates language-specific implementation code. This enables developers to define data types and service interfaces once and generate the boilerplate code for multiple programming languages.
Common generators include: cpp, java, py, rb, php, js, go, rs (Rust), swift, and many others. Run thrift without arguments to see all available generators for your installation.
PARAMETERS
--gen lang[:key=val,...]
Generate code with the specified generator. Language options can be passed as comma-separated key=value pairs.-o dir
Set the output directory for gen-* packages. Default is the current directory.-out dir
Set the output location directly without creating a gen-* folder.-I dir
Add a directory to search for include directives. Can be specified multiple times.-r, --recurse
Also generate code for included Thrift files recursively.-nowarn
Suppress all compiler warnings.-strict
Enable strict compiler warnings.-v, --verbose
Enable verbose output mode.-debug
Print parse debug trace to stdout.-version
Print the compiler version and exit.
CAVEATS
Generated code structure and options vary significantly between language generators. Some generators may require additional runtime libraries to be installed. The -nowarn flag is generally discouraged as it can hide important compatibility issues.
HISTORY
Apache Thrift was originally developed at Facebook in 2007 and was open-sourced in April 2008. It became an Apache Incubator project in May 2008 and graduated to a top-level Apache project in October 2010. The framework was designed to enable efficient and reliable communication across programming languages at scale.


