Class RustCompileRule

    • Constructor Detail

      • RustCompileRule

        protected RustCompileRule​(BuildTarget buildTarget,
                                  ProjectFilesystem projectFilesystem,
                                  SourcePathRuleFinder ruleFinder,
                                  String filename,
                                  Tool compiler,
                                  Linker linker,
                        <Arg> args,
                        <Arg> depArgs,
                        <Arg> linkerArgs,
                        <String,​Arg> environment,
                        <SourcePath,​Optional<String>> mappedSources,
                                  String rootModule,
                                  com.facebook.buck.features.rust.RustBuckConfig.RemapSrcPaths remapSrcPaths,
                                  Optional<String> xcrunSdkPath)
        Work out how to invoke the Rust compiler, rustc.

        In Rust, a crate is the equivalent of a package in other languages. It's also the basic unit of compilation.

        A crate can either be a "binary crate" - which generates an executable - or a "library crate", which makes an .rlib file. .rlib files contain both interface details (function signatures, inline functions, macros, etc) and compiled object code, and so are equivalent to both header files and library archives. There are also dynamic crates which compile to .so files.

        All crates are compiled from at least one source file, which is its main (or top, or root) module. It may have references to other modules, which may be in other source files. Rustc only needs the main module filename and will find the rest of the source files from there (akin to #include in C/C++). If the crate also has dependencies on other crates, then those .rlib files must also be passed to rustc for the interface details, and to be linked if its a binary crate.