pub enum InputKind {
C,
CHeader,
PreprocessedC,
Assembler,
AssemblerWithCpp,
LinkerInput,
}Expand description
What an input file is, which decides where in the pipeline it enters.
Variants§
C
C source. Extension .c, or -x c.
CHeader
A header compiled on its own. Extension .h with -x c-header, or -x c-header.
PreprocessedC
Already preprocessed C. Extension .i, or -x cpp-output.
Assembler
Assembly. Extension .s, or -x assembler.
AssemblerWithCpp
Assembly that still needs the preprocessor. Extension .S or .sx, or
-x assembler-with-cpp.
LinkerInput
An object file, an archive or a shared library. Anything the linker takes directly.
Implementations§
Source§impl InputKind
impl InputKind
Sourcepub fn from_x_arg(name: &str) -> Result<InputKind, XError>
pub fn from_x_arg(name: &str) -> Result<InputKind, XError>
Parses the argument of -x.
§Errors
Returns the offending name when it is not one we accept. C++ gets its own message, because “unknown language c++” reads like an oversight and it is a decision.
Sourcepub fn from_path(path: &str) -> Result<InputKind, XError>
pub fn from_path(path: &str) -> Result<InputKind, XError>
Classifies an input by its extension, the way spec/04-driver-and-cli.md section 4.2
tabulates it.
An unrecognized extension is a linker input, which is GCC’s behavior and is what makes
rucc foo.o bar.builtin-suffix work. The exception is a C++ extension, which is a
hard error rather than a confusing link failure later.
§Errors
Returns the extension when it names a language that is permanently out of scope.