1234567891011121314151617181920212223242526272829303132333435363738394041424344 | // The compilation engine driving transpiling, object compilation, executable
// linking, and package builds (shared by the CLI commands, not itself a
// command)
#pragma once
#include "../environment.h"
#include "../stdlib/datatypes.h"
typedef enum { COMPILE_C_FILES, COMPILE_OBJ, COMPILE_EXE } compile_mode_t;
void compile_files(env_t *env, List_t to_compile, List_t *object_files, List_t *extra_ldlibs, compile_mode_t mode);
Path_t compile_executable(env_t *base_env, Path_t path, Path_t exe_path, List_t object_files, List_t extra_ldlibs,
bool embed_git_info, bool embed_source);
void compile_object_file(Path_t path);
// Build (or find) the cached precompiled header of <tomo.h> that object
// compiles preload. Callers that fork a worker per file should call this
// first, so the parent builds the one shared PCH instead of every child
// racing to build its own.
void warm_precompiled_header(void);
// Link a `tomo test` runner: `test_source` (the generated .test.c) plus the
// module's object files and archives, into an executable. Returns its path.
Path_t build_test_runner(Path_t path, List_t object_files, List_t extra_ldlibs, Text_t test_source);
void transpile_header(env_t *base_env, Path_t path);
void transpile_code(env_t *base_env, Path_t path);
void build_package(Path_t pkg_dir);
void build_package_archive(Path_t pkg_dir, List_t tm_files, Path_t archive);
void build_file_dependency_graph(Table_t *build_info, Path_t path, Table_t *to_compile, Table_t *to_link);
void write_source_blob(env_t *env, Path_t main_file, Path_t exe_path, Path_t blob_path);
void print_build_info(Path_t p);
// Whether `p` is a Tomo-produced artifact, either a compiled binary (build-info
// header) or a generated man page (TOMO_MANPAGE_MARKER). Used by `tomo
// uninstall` to avoid deleting files it didn't create.
bool is_tomo_binary(Path_t p);
bool is_tomo_manpage(Path_t p);
// Print the contents of the source archive embedded in a compiled program:
void list_embedded_source(Path_t binary);
// Unpack that archive into the `destination` directory:
void extract_embedded_source(Path_t binary, Path_t destination);
// Write that archive to `destination` as a zip file, without unpacking it:
void save_embedded_source_zip(Path_t binary, Path_t destination);
bool is_stale(Path_t path, Path_t relative_to, bool ignore_missing);
bool is_stale_for_any(Path_t path, List_t relative_to, bool ignore_missing);
bool is_config_outdated(Path_t path);
|