• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Using the schema compiler    {#flatbuffers_guide_using_schema_compiler}
2=========================
3
4Usage:
5
6    flatc [ GENERATOR OPTIONS ] [ -o PATH ] [ -I PATH ] [ -S ] FILES...
7          [ -- FILES...]
8
9The files are read and parsed in order, and can contain either schemas
10or data (see below). Data files are processed according to the definitions of
11the most recent schema specified.
12
13`--` indicates that the following files are binary files in
14FlatBuffer format conforming to the schema indicated before it.
15
16Depending on the flags passed, additional files may
17be generated for each file processed:
18
19For any schema input files, one or more generators can be specified:
20
21-   `--cpp`, `-c` : Generate a C++ header for all definitions in this file (as
22    `filename_generated.h`).
23
24-   `--java`, `-j` : Generate Java code.
25
26-   `--csharp`, `-n` : Generate C# code.
27
28-   `--go`, `-g` : Generate Go code.
29
30-   `--python`, `-p`: Generate Python code.
31
32-   `--javascript`, `-s`: Generate JavaScript code.
33
34-   `--php`: Generate PHP code.
35
36-   `--grpc`: Generate RPC stub code for GRPC.
37
38For any data input files:
39
40-   `--binary`, `-b` : If data is contained in this file, generate a
41    `filename.bin` containing the binary flatbuffer (or a different extension
42    if one is specified in the schema).
43
44-   `--json`, `-t` : If data is contained in this file, generate a
45    `filename.json` representing the data in the flatbuffer.
46
47Additional options:
48
49-   `-o PATH` : Output all generated files to PATH (either absolute, or
50    relative to the current directory). If omitted, PATH will be the
51    current directory. PATH should end in your systems path separator,
52    e.g. `/` or `\`.
53
54-   `-I PATH` : when encountering `include` statements, attempt to load the
55    files from this path. Paths will be tried in the order given, and if all
56    fail (or none are specified) it will try to load relative to the path of
57    the schema file being parsed.
58
59-   `-M` : Print make rules for generated files.
60
61-   `--strict-json` : Require & generate strict JSON (field names are enclosed
62    in quotes, no trailing commas in tables/vectors). By default, no quotes are
63    required/generated, and trailing commas are allowed.
64
65-   `--defaults-json` : Output fields whose value is equal to the default value
66    when writing JSON text.
67
68-   `--no-prefix` : Don't prefix enum values in generated C++ by their enum
69    type.
70
71-   `--scoped-enums` : Use C++11 style scoped and strongly typed enums in
72    generated C++. This also implies `--no-prefix`.
73
74-   `--gen-includes` : (deprecated), this is the default behavior.
75                       If the original behavior is required (no include
76	                   statements) use `--no-includes.`
77
78-   `--no-includes` : Don't generate include statements for included schemas the
79    generated file depends on (C++).
80
81-   `--gen-mutable` : Generate additional non-const accessors for mutating
82    FlatBuffers in-place.
83
84    `--gen-object-api` : Generate an additional object-based API. This API is
85    more convenient for object construction and mutation than the base API,
86    at the cost of efficiency (object allocation). Recommended only to be used
87    if other options are insufficient.
88
89-   `--gen-onefile` :  Generate single output file (useful for C#)
90
91-   `--gen-all`: Generate not just code for the current schema files, but
92    for all files it includes as well. If the language uses a single file for
93    output (by default the case for C++ and JS), all code will end up in
94    this one file.
95
96-   `--no-js-exports` :  Removes Node.js style export lines (useful for JS)
97
98-   `--goog-js-export` :  Uses goog.exportsSymbol and goog.exportsProperty
99    instead of Node.js style exporting.  Needed for compatibility with the
100    Google closure compiler (useful for JS).
101
102-   `--raw-binary` : Allow binaries without a file_indentifier to be read.
103    This may crash flatc given a mismatched schema.
104
105-   `--proto`: Expect input files to be .proto files (protocol buffers).
106    Output the corresponding .fbs file.
107    Currently supports: `package`, `message`, `enum`, nested declarations,
108    `import` (use `-I` for paths), `extend`, `oneof`, `group`.
109    Does not support, but will skip without error: `option`, `service`,
110    `extensions`, and most everything else.
111
112-   `--schema`: Serialize schemas instead of JSON (use with -b). This will
113    output a binary version of the specified schema that itself corresponds
114    to the reflection/reflection.fbs schema. Loading this binary file is the
115    basis for reflection functionality.
116
117-   `--bfbs-comments`: Add doc comments to the binary schema files.
118
119-   `--conform FILE` : Specify a schema the following schemas should be
120    an evolution of. Gives errors if not. Useful to check if schema
121    modifications don't break schema evolution rules.
122
123-   `--include-prefix PATH` : Prefix this path to any generated include
124    statements.
125
126NOTE: short-form options for generators are deprecated, use the long form
127whenever possible.
128