Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/cli.x
X2c command-line parsing and presentation.
Functions
| Function | Summary |
|---|---|
cli_dependency_pass_through | Returns whether argument contains a driver-owned dependency option. |
cli_package_options | Reads a package’s native response options, expanding literal {package} after tokenization. |
cli_parse | Expands response files and parses argv[1..] into one validated request. |
cli_response_arguments | Reads response-file tokens with ordinary quoting and UTF-8 checks. |
cli_version | Returns the version line --version prints, without a newline. |
CliRequest.inspects | Returns whether request selects a terminating inspection or dump mode. |
CliRequest.package_roots | Returns the package roots request searches: its explicit --package-dir and manifest directories in order, then the home’s packages/ directory when it exists. |
Functions
cli_dependency_pass_through
int cli_dependency_pass_through(String s)
Returns whether argument 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.x:806
cli_package_options
CliRequest cli_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.x:940
cli_parse
CliRequest cli_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.x:1099
cli_response_arguments
List cli_response_arguments(String path)
Reads response-file tokens with ordinary quoting and UTF-8 checks.
Returns canonical Strings without expanding @ references. Paths and
arguments retain the producing pool lifetime.
Source: src/cli.x:708
cli_version
String cli_version(void)
Returns the version line --version prints, without a newline.
Source: src/cli.x:1154
CliRequest
CliRequest.inspects
int CliRequest.inspects(CliRequest request)
Returns whether request selects a terminating inspection or dump mode.
Source: src/cli.x:1157
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.x:1165
Public types
| Type | Kind | Summary |
|---|---|---|
CliRequest | struct | Holds one compiler command and its command-specific inputs and options. |
CliRequest
typedef struct CliRequest { Symbol command, List inputs, run_args, include_dirs, package_dirs, cpp_args; List cc_args, ld_args, String out_dir, dep_file, dep_target, manifest; String target, profile, output, build_dir, temps_dir, label, state_seed; String prefix, 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, force, rebuild, clean; SourceView sources; } *CliRequest
Holds one compiler command and its command-specific inputs and options.
Lists produced by cli_parse preserve CLI order. Copies are shallow:
request storage and referenced canonical values keep their producing
Scope
and pool lifetimes.
Source: src/cli.x:18
Design notes
Response expansion, command selection, option validation, diagnostics, and help rendering all produce or read the typed CliRequest.