This document describes the command-line interface to the FIDL compiler.
Information on the internals of that tool lives alongside the source of the tool.
See Overview for more information about FIDL's overall purpose, goals, and requirements, as well as links to related documents.
The FIDL compiler is split into a frontend and a number of backends. The compiler processes one library at a time. The frontend consumes the FIDL declarations for the library (as well as for all transitive dependencies), performs semantic analysis, and outputs an intermediate representation of the library. The backends consume the intermediate representation and generate language-specific bindings for the library.
The frontend is a command-line program named
fidlc compiler takes
a number of arguments:
--c-header HEADER_PATH. If present, this flag instructs
fidlcto output a C header at the given path. In principle, the C header generation could have been implemented as a C backend, but for some practical reasons, we integrated the C header generation directly into the frontend.
--tables TABLES_PATH. If present, this flag instructs
fidlcto output coding tables at the given path. The coding tables are required to encode and decode messages from the C and C++ bindings.
--json JSON_PATH. If present, this flag instructs
fidlcto output the library's intermediate representation at the given path. The intermediate representation is JSON that conforms to a particular schema. The intermediate representation is used as input to the various backends.
--name LIBRARY_NAME. If present, this flag instructs
fidlcto validate that the library being compiled has the given name. This flag is useful to cross-check between the library's declaration in a build system and the actual contents of the library.
--files [FIDL_FILE...].... Each
--file [FIDL_FILE...]chunk of arguments describes a library, all of which must share the same top-level library name declaration. Libraries must be presented in dependency order, with later libraries able to use declarations from preceding libraries but not vice versa. Output is only generated for the final library, not for each of its dependencies.
All of the arguments can also be provided via a response file, denoted as
@responsefile. The contents of the file at
responsefile will be interpreted
as a whitespace-delimited list of arguments. Response files cannot be nested,
and must be the only argument.
The backend is a command-line program named
takes a number of arguments:
--json(required). The path to the intermediate representation of the library. The intermediate representation is JSON that conforms to a particular schema.
--generators(required). A comma-separated list of generators to run on the given library. The following generators are currently supported:
--output-base(required). The base file name for files generated by this generator. The generator will create files by adding extensions to this file name. For example, the
cppbackend generates two files, one with the
.hextension and another with the
--include-base(required). The base directory relative to which C and C++
#includedirectives should be computed. For example, when the
cppbackend generates an
#includedirective to reference the
.hfile from the
.ccfile, the backend will create the
#includepath relative to this directory.
cpp backend, the generated
.h file must be includeable as
#include <fuchsia/cpp/$LIBRARY_NAME.h>, where
$LIBRARY_NAME is the name of
the corresponding FIDL library. Typically, that means that the
flag will have the value
$INCLUDE_BASE is the value of the
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.