Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.

src/cli/cli.x

X2c command-line parsing and presentation.

Functions

FunctionSummary
CliRequest.command_argumentsCopies the driver’s already-read vector, or returns NULL for direct invocation.
CliRequest.dependency_optionReturns whether s contains a driver-owned dependency option.
CliRequest.inspectsReturns whether request selects a terminating inspection or dump mode.
CliRequest.is_builtinReports whether a raw command name belongs to the built-in parser.
CliRequest.newConstructs a request with the command’s ordinary CLI defaults.
CliRequest.package_optionsReads a package’s native response options, expanding literal {package} after tokenization.
CliRequest.package_rootsReturns the package roots request searches: its explicit --package-dir and manifest directories in order, then the home’s packages/ directory when it exists.
CliRequest.parseExpands response files and parses argv[1..] into one validated request.
CliRequest.parse_argumentsParses already-read arguments, preserving deferred script expansion.
CliRequest.read_argumentsReads initial arguments.
CliRequest.require_inputExits with a driver error unless input names a regular file.
Compiler.versionReturns the version line --version prints, without a newline.
TargetKind.namedReturns the target kind spelled spelling, or 0 when no kind has that spelling.
TargetKind.ofReturns the row of target kind kind; any other kind reads as an executable.

CliRequest

CliRequest.command_arguments

Array CliRequest.command_arguments(int argc, char **argv)

Copies the driver’s already-read vector, or returns NULL for direct invocation. The caller owns the Array; no word is expanded again.

Source: src/cli/responses.x:21

CliRequest.dependency_option

int CliRequest.dependency_option(String s)

Returns whether s contains a driver-owned dependency option. Recognizes -MMD, -MP, -MF, and -MT as leading spellings or in a comma-delimited pass-through argument; NULL returns zero.

Source: src/cli/parsing.x:553

CliRequest.inspects

int CliRequest.inspects(CliRequest request)

Returns whether request selects a terminating inspection or dump mode.

Source: src/cli/requests.x:65

CliRequest.is_builtin

int CliRequest.is_builtin(const char *word)

Reports whether a raw command name belongs to the built-in parser.

Source: src/cli/parsing.x:655

CliRequest.new

CliRequest CliRequest.new(Symbol command)

Constructs a request with the command’s ordinary CLI defaults.

Source: src/cli/requests.x:37

CliRequest.package_options

CliRequest CliRequest.package_options(String path, String package)

Reads a package’s native response options, expanding literal {package} after tokenization. Only native include/define/thread options, ordered archive/library/framework inputs, run-time library search directories, and the -Wl, and -Xlinker linker pass-throughs are admitted. cc_args and ld_args serve native actions; no source-preprocessing options are returned.

Source: src/cli/parsing.x:581

CliRequest.package_roots

List CliRequest.package_roots(CliRequest request)

Returns the package roots request searches: its explicit --package-dir and manifest directories in order, then the home’s packages/ directory when it exists. A root named twice is searched twice and resolves the same entries. Explicit directories are borrowed; the result is a fresh List only when the home directory is appended.

Source: src/cli/requests.x:73

CliRequest.parse

CliRequest CliRequest.parse(int argc, char **argv)

Expands response files and parses argv[1..] into one validated request. Help and version requests print and exit with status zero. An empty command line prints help and exits with status two; other invalid input reports an error and exits with status two. The result has the active Scope and canonical-pool lifetimes described by CliRequest.

Raises: <alloc-fail> or <size-limit> while expanding response files or constructing request values.

Source: src/cli/parsing.x:255

CliRequest.parse_arguments

CliRequest CliRequest.parse_arguments(Array args)

Parses already-read arguments, preserving deferred script expansion.

Source: src/cli/parsing.x:261

CliRequest.read_arguments

Array CliRequest.read_arguments(int argc, char **argv)

Reads initial arguments. Script options defer response-file expansion until parsing, so program arguments remain literal. The caller owns the returned Array.

Source: src/cli/responses.x:9

CliRequest.require_input

void CliRequest.require_input(String input)

Exits with a driver error unless input names a regular file. A wildcard or directory operand adds a note on what to pass instead.

Source: src/cli/requests.x:95

Compiler

Compiler.version

String Compiler.version(void)

Returns the version line --version prints, without a newline.

Source: src/cli/requests.x:62

TargetKind

TargetKind.named

Symbol TargetKind.named(String spelling, String &refusal)

Returns the target kind spelled spelling, or 0 when no kind has that spelling. refusal says why this compiler refuses a known spelling, and is NULL otherwise.

Source: src/cli/requests.x:18

TargetKind.of

TargetKind *TargetKind.of(Symbol kind)

Returns the row of target kind kind; any other kind reads as an executable.

Source: src/cli/requests.x:28

Public types

TypeKindSummary
CliRequeststructHolds one compiler command and its command-specific inputs and options.
TargetKindstructDescribes one target kind: its spelling on the command line and in a manifest, the noun a report uses, and the default output file name around the target’s name.

CliRequest

typedef struct CliRequest { Symbol command, List inputs, run_args, include_dirs, package_dirs, cpp_args; List cc_args, ld_args, native_modules, extensions; Map collection_packages; String out_dir, dep_file, dep_target, manifest; String target, profile, output, build_dir, temps_dir, label, state_seed; String cc, meta_cc, ar, compile_commands, sha256, index, Symbol kind; String diagnostics_file, Symbol color_mode; Symbol dump; int jobs, debugging, verbose, dry_run, quiet, plain, no_deps; int no_phony_deps, compile_only, kind_explicit, save_temps, no_cpp; int max_errors; int source_map, source_facts, live_symbols, cpp_symbols; int force, rebuild, clean; int fatal_warnings, no_interfaces; SourceView sources; } *CliRequest

Holds one compiler command and its command-specific inputs and options. Lists produced by CliRequest.parse preserve CLI order. Copies are shallow: request storage and referenced canonical values keep their producing Scope and pool lifetimes.

Source: src/cli/cli.x:18

TargetKind

typedef struct TargetKind { Symbol kind, String spelling, noun, prefix, suffix; } TargetKind

Describes one target kind: its spelling on the command line and in a manifest, the noun a report uses, and the default output file name around the target’s name.

Source: src/cli/cli.x:44

Design notes

Each option is one table row: the commands that accept it, its spellings, its help text, and the request field it sets. Parsing and help read the same rows.