build_driver.l0
Module: build_driver
Source: compiler/stage2_l0/src/build_driver.l0 Language: Dea/L0
Imports / Includes
codegen_optionscli_argstypessymbolssignaturesname_resolversem_contextbackendsys.rtstd.pathstd.hashmapdiag_printsource_pathscompiler_filesystemstd.stringutil.logstd.fsstd.systemstd.textanalysisstd.vectorutil.diagutil.strings
Symbols
- bd_prepared_input_free
- bd_prepared_input_free_opt
- bd_log_effective_roots
- bd_prepare_input
- bd_append_c_option_words
- bd_merge_c_option_words
- bd_format_word_list
- bd_collect_c_option_words
- bd_find_last_sep
- bd_with_c_suffix
- bd_is_windows
- bd_exe_suffix
- bd_default_exe_name
- bd_null_device
- bd_shell_quote_posix
- bd_shell_quote_windows
- bd_shell_quote
- bd_windows_token_is_plain
- bd_windows_exec_token
- bd_join_shell_words
- bd_join_display_words
- bd_compiler_flag_family
- bd_has_explicit_opt_flag
- bd_has_debug_flag
- bd_get_optimize_flag
- bd_find_c_compiler
- bd_runtime_include_dir
- bd_runtime_lib_dir
- bd_validate_runtime_lib
- bd_validate_entry_main
- bd_push_standard_flags
- bd_push_output_flags
- bd_push_c_compile_command_words
- bd_replay_compile_output
- bd_emit_write_error
- bd_prepare_build_result
- bd_build_to_exe
- bd_cmd_build
- bd_cmd_run
- BuildPreparedInput
Function bd_prepared_input_free
1
func bd_prepared_input_free(self: BuildPreparedInput*)
Free a prepared input bundle.
Parameters:
self: Prepared input to free.
Function bd_prepared_input_free_opt
1
func bd_prepared_input_free_opt(self: BuildPreparedInput*?)
Free an optional prepared input bundle.
Parameters:
self: Optional prepared input.
Function bd_log_effective_roots
1
func bd_log_effective_roots(cfg: LogConfig*, sys_roots: StringVector*, project_roots: StringVector*)
Log the effective system and project roots for build/run commands.
Parameters:
cfg: Logging configuration.sys_roots: Effective system-root vector.project_roots: Effective project-root vector.
Function bd_prepare_input
1
func bd_prepare_input(opts: CliOptions*, diags: DiagCollector*, cfg: LogConfig*) -> BuildPreparedInput*?
Normalize CLI target input into an entry module and source search paths.
Parameters:
opts: Parsed CLI options.diags: Diagnostic collector for normalization failures.cfg: Logging configuration.
Returns: Prepared input bundle, or null on failure.
Function bd_append_c_option_words
1
func bd_append_c_option_words(dst: StringVector*, raw: string?)
Append whitespace-delimited C option words from one source string.
Parameters:
dst: Destination vector for parsed option words.raw: Raw options string, ornull.
Function bd_merge_c_option_words
1
func bd_merge_c_option_words(env_opts: string?, cli_opts: string?) -> StringVector*
Merge C option words from environment and CLI with CLI-last precedence.
Parameters:
env_opts: Options fromL0_CFLAGS.cli_opts: Options from--c-options.
Returns: Parsed option words in final order.
Function bd_format_word_list
1
func bd_format_word_list(words: StringVector*) -> string
Format option words using the Stage 1 verbose display contract.
Parameters:
words: Option vector to format.
Returns: Python-list-style rendering for verbose logs.
Function bd_collect_c_option_words
1
func bd_collect_c_option_words(opts: CliOptions*) -> StringVector*
Resolve merged C option words from L0_CFLAGS and parsed CLI options.
Parameters:
opts: Parsed CLI options.
Returns: Parsed option words in final order.
Function bd_find_last_sep
1
func bd_find_last_sep(path: string) -> int
Replace or add a .c suffix on a path string.
Parameters:
path: Path to rewrite.
Returns: Path with .c suffix.
Function bd_with_c_suffix
1
func bd_with_c_suffix(path: string) -> string
Replace or add a .c suffix on a path string.
Parameters:
path: Path to rewrite.
Returns: Path with .c suffix.
Function bd_is_windows
1
func bd_is_windows() -> bool
Return whether the current host should use Windows command behavior.
Returns: true when Windows shell rules should apply.
Function bd_exe_suffix
1
func bd_exe_suffix() -> string
Return the executable suffix for the current host.
Returns: .exe on Windows, otherwise .out.
Function bd_default_exe_name
1
func bd_default_exe_name() -> string
Return the default build output name for the current host.
Returns: a.exe on Windows, otherwise a.out.
Function bd_null_device
1
func bd_null_device() -> string
Return the shell null device for the current host shell.
Returns: NUL on Windows, otherwise /dev/null.
Function bd_shell_quote_posix
1
func bd_shell_quote_posix(arg: string) -> string
Quote one shell token for POSIX system() execution.
Parameters:
arg: Raw token.
Returns: Safely single-quoted token.
Function bd_shell_quote_windows
1
func bd_shell_quote_windows(arg: string) -> string
Quote one shell token for Windows system() execution.
Parameters:
arg: Raw token.
Returns: Safely double-quoted token.
Function bd_shell_quote
1
func bd_shell_quote(arg: string) -> string
Quote one shell token for the active host shell.
Parameters:
arg: Raw token.
Returns: Safely quoted token.
Function bd_windows_token_is_plain
1
func bd_windows_token_is_plain(arg: string) -> bool
Return whether one Windows shell token can remain unquoted.
Parameters:
arg: Raw token.
Returns: true when cmd.exe-safe token text needs no surrounding quotes.
Function bd_windows_exec_token
1
func bd_windows_exec_token(arg: string) -> string
Normalize one Windows executable token for cmd.exe .
Relative ./… command paths are valid under POSIX shells but cmd.exe interprets the leading ./ as a command named . . Rewriting the slash separators to .... keeps caller-selected relative executables runnable.
Parameters:
arg: Raw executable token.
Returns: Command token with cmd.exe-safe relative separators.
Function bd_join_shell_words
1
func bd_join_shell_words(words: StringVector*) -> string
Join command words into one shell command line.
Parameters:
words: Command words to quote and join.
Returns: One shell command line.
Function bd_join_display_words
1
func bd_join_display_words(words: StringVector*) -> string
Join command words into the Stage 1 visible command-line form.
Parameters:
words: Command words to join.
Returns: Space-delimited command line without shell quoting.
Function bd_compiler_flag_family
1
func bd_compiler_flag_family(compiler: string) -> string
Return the compiler flag-family name used by Stage 1.
Parameters:
compiler: Compiler command string.
Returns: Flag-family tag.
Function bd_has_explicit_opt_flag
1
func bd_has_explicit_opt_flag(extra_opts: StringVector*) -> bool
Return whether the user already supplied an optimization flag.
Parameters:
extra_opts: Collected extra C compiler options.
Returns: true when an explicit optimization flag is present.
Function bd_has_debug_flag
1
func bd_has_debug_flag(extra_opts: StringVector*) -> bool
Return whether the user supplied a debug flag.
Parameters:
extra_opts: Collected extra C compiler options.
Returns: true when a debug flag is present.
Function bd_get_optimize_flag
1
func bd_get_optimize_flag(family: string, extra_opts: StringVector*) -> string?
Return the default optimization flag for a compiler family.
Parameters:
family: Compiler flag-family name.extra_opts: Collected extra C compiler options.
Returns: Optimization flag, or null.
Function bd_find_c_compiler
1
func bd_find_c_compiler() -> string?
Return the best available C compiler command or null .
Returns: Compiler command string, or null.
Function bd_runtime_include_dir
1
func bd_runtime_include_dir(opts: CliOptions*) -> string?
Resolve the runtime include directory for build/run.
Parameters:
opts: Parsed CLI options.
Returns: Runtime include directory, or null.
Function bd_runtime_lib_dir
1
func bd_runtime_lib_dir(opts: CliOptions*) -> string?
Resolve the runtime library directory for build/run.
Parameters:
opts: Parsed CLI options.
Returns: Runtime library directory, or null.
Function bd_validate_runtime_lib
1
func bd_validate_runtime_lib(runtime_lib_path: string, diags: DiagCollector*) -> bool
Validate that a runtime library directory exists.
Parameters:
runtime_lib_path: Path to validate.diags: Diagnostic collector for failures.
Returns: true on success.
Function bd_validate_entry_main
1
func bd_validate_entry_main(result: AnalysisResult*, entry_module: string, diags: DiagCollector*) -> bool
Validate the entry module main function for build/run.
Parameters:
result: Analysis result to inspect.entry_module: Entry module name.diags: Diagnostic collector for failures and warnings.
Returns: true when the entry main is acceptable.
Function bd_push_standard_flags
1
func bd_push_standard_flags(words: StringVector*, family: string)
Push compiler-family standard flags into a command-word vector.
Parameters:
words: Command words to extend.family: Compiler flag-family name.
Function bd_push_output_flags
1
func bd_push_output_flags(words: StringVector*, family: string, exe_path: string)
Push compiler-family output-path flags into a command-word vector.
Parameters:
words: Command words to extend.family: Compiler flag-family name.exe_path: Output executable path.
Function bd_push_c_compile_command_words
1
func bd_push_c_compile_command_words(words: StringVector*, compiler: string, family: string, extra_opts: StringVector*, optimize: string?, runtime_include: string?, c_path: string, c_sources: StringVector*, exe_path: string, runtime_lib: string?)
Push a C compiler invocation into a command-word vector.
Parameters:
words: Command words to extend.compiler: C compiler executable.family: Compiler flag-family name.extra_opts: User C compiler option words.optimize: Selected default optimization flag, ornull.runtime_include: Runtime header include path, ornull.c_path: Generated C input path.c_sources: Additional C source input paths.exe_path: Output executable path.runtime_lib: Runtime library search path, ornull.
Function bd_replay_compile_output
1
func bd_replay_compile_output(cfg: LogConfig*, stdout_path: string, stderr_path: string, failed: bool)
Replay compiler output captured into temp files.
Parameters:
cfg: Logging configuration.stdout_path: Captured stdout path.stderr_path: Captured stderr path.failed: Whether compilation failed.
Function bd_emit_write_error
1
func bd_emit_write_error(diags: DiagCollector*, path: string)
Emit one Stage 2-only write-file diagnostic.
Parameters:
diags: Diagnostic collector.path: Path that could not be written.
Function bd_prepare_build_result
1
func bd_prepare_build_result(opts: CliOptions*, cfg: LogConfig*) -> AnalysisResult*?
Analyze and validate one build/run entry before workspace creation.
Parameters:
opts: Parsed CLI options.cfg: Logging configuration.
Returns: Validated analysis result, or null on failure.
Function bd_build_to_exe
1
func bd_build_to_exe(opts: CliOptions*, cfg: LogConfig*, result: AnalysisResult*, workspace: CompilerWorkspace*, exe_path: string, keep_c_path: string?) -> int
Build an executable using one command-owned workspace.
The caller owns result and workspace , including the single cleanup epilogue. This helper only registers and uses its fixed scratch children.
Parameters:
opts: Parsed CLI options.cfg: Logging configuration.result: Validated analysis result.workspace: Command-owned workspace.exe_path: Output executable path.keep_c_path: Optional kept-C output path.
Returns: Process-style status code.
Function bd_cmd_build
1
func bd_cmd_build(opts: CliOptions*, cfg: LogConfig*) -> int
Execute Stage 2 –build .
Parameters:
opts: Parsed CLI options.cfg: Logging configuration.
Returns: Process-style status code.
Function bd_cmd_run
1
func bd_cmd_run(opts: CliOptions*, cfg: LogConfig*) -> int
Execute Stage 2 –run .
Parameters:
opts: Parsed CLI options.cfg: Logging configuration.
Returns: Process-style status code.
Struct BuildPreparedInput
Prepared input bundle for build/run commands.
BuildPreparedInput Field entry_module
1
entry_module: string
BuildPreparedInput Field search_paths
1
search_paths: SourceSearchPaths*