Skip to content

Commit c9125e6

Browse files
authored
flatc.md Add more documentation (#8467)
* CNAME: add custom domain * `flatc.md`: Add more documentation
1 parent 28ddfae commit c9125e6

File tree

2 files changed

+90
-3
lines changed

2 files changed

+90
-3
lines changed

docs/source/building.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Once the project files are generated, build as normal for your platform.
4141
=== "Unix"
4242

4343
```sh
44-
make flatc
44+
make -j
4545
```
4646

4747
=== "Windows"
@@ -50,6 +50,12 @@ Once the project files are generated, build as normal for your platform.
5050
msbuild.exe FlatBuffers.sln
5151
```
5252

53+
=== "MacOS"
54+
55+
```sh
56+
xcodebuild -toolchain clang -configuration Release
57+
```
58+
5359
## Building with Bazel
5460

5561
## Building with VCPKG

docs/source/flatc.md

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,88 @@
11
# FlatBuffers Compiler (`flatc`)
22

3-
The main compiler for FlatBuffers is called `flatc` and is used as follows:
3+
The main compiler for FlatBuffers is called `flatc` and is used to convert
4+
schema definitions into generated code files for a variety of languages.
5+
6+
After [building](building.md) `flatc`, it is used as follows:
47

58
```sh
6-
flatc [ GENERATOR_OPTIONS ] [ -o PATH ] [- I PATH ] FILES... [ -- BINARY_FILES... ]
9+
flatc [ GENERATOR_OPTIONS ] [ -o PATH ] [- I PATH ]
10+
FILES...
11+
[ -- BINARY_FILES... ]
712
```
13+
14+
* The `GENERATOR_OPTIONS` specify the language(s) to compile code for as well as
15+
various features to enable/disable.
16+
17+
* The `-o PATH` specifies the path where the generated files are placed. It
18+
defaults to the current path if not specified.
19+
20+
* The `-I PATH` specifies the paths where included schema files are located. It
21+
defaults to the current path if not specified.
22+
23+
## Input Files
24+
25+
`FILES...` specifies one or more schema or data files to process. They are
26+
processed in the order provided.
27+
28+
### Schema Files
29+
30+
For schema files, language specifiers indicate what languages to generate code
31+
for.
32+
33+
* `--cpp`: C++
34+
* `--java`: Java
35+
* `--kotlin`: Kotlin
36+
* `--csharp`: C#
37+
* `--go`: Golang
38+
* `--python`: Python
39+
* `--js`: JavaScript
40+
* `--ts`: TypeScript
41+
* `--php`: PHP
42+
* `--dart`: Dart
43+
* `--lua`: Lua
44+
* `--lobster`: Lobster
45+
* `--rust`: Rust
46+
* `--swift`: Swift
47+
* `--nim`: Nim
48+
49+
Additionally, adding:
50+
51+
* `--grpc` Will generate RPC stub code for gRPC (not available in all
52+
languages)
53+
54+
### Data Files
55+
56+
If `FILES...` contain data files, they can be exported to either a binary or
57+
JSON representation.
58+
59+
* `--binary`, `-b`: Generate a binary file containing a serialized flatbuffer.
60+
* `--json`, `-j`: Generate JSON file from a serialized flatbuffer.
61+
62+
Both options require the corresponding schema file to be included first in the
63+
list of `FILES...`.
64+
65+
=== "To Binary"
66+
67+
To serialize the JSON data in `mydata.json` using the schema `myschema.fbs`:
68+
69+
```sh
70+
flatc --binary myschema.fbs mydata.json
71+
```
72+
73+
This will generate a `mydata_wire.bin` file containing the serialized
74+
flatbuffer data.
75+
76+
=== "To JSON"
77+
78+
To convert the serialized binary flatbuffer `mydata.bin` using the schema
79+
`myschema.fbs` to JSON:
80+
81+
```sh
82+
flatc --json myschema.fbs mydata.bin
83+
```
84+
85+
This will generate a `mydata.json` file.
86+
87+
88+

0 commit comments

Comments
 (0)