Configuration Reference

The replibuild.toml file is the central nervous system of your build process. It allows you to customize everything from the project name to the strictness of type mappings in the generated wrapper.

This reference documents all available sections and keys.

[project]

Basic project metadata.

KeyTypeDescriptionDefault
nameStringThe name of the project. Used for library naming.Folder name
rootStringThe root directory of the project..
uuidStringUnique identifier for the project.Auto-generated

[paths]

Locations for source code and build artifacts.

KeyTypeDescriptionDefault
sourceStringDirectory containing C++ source files."src"
includeStringDirectory containing C++ header files."include"
outputStringDirectory where generated Julia wrappers are saved."julia"
buildStringDirectory for intermediate build artifacts (IR, objects)."build"
cacheStringDirectory for caching build metadata.".replibuild_cache"

[discovery]

Settings for the automatic source file discovery process.

KeyTypeDescriptionDefault
enabledBoolWhether to run discovery automatically.true
walk_dependenciesBoolWhether to follow #include directives to find dependencies.true
max_depthIntMaximum recursion depth for directory scanning.10
ignore_patternsVector{String}Files/folders to ignore during scan.["build", ".git", ".cache"]
parse_astBoolWhether to use Clang AST for deeper dependency analysis.true

[compile]

Compiler settings for turning C++ into LLVM IR.

KeyTypeDescriptionDefault
flagsVector{String}Flags passed to clang++ (e.g., ["-O3", "-fPIC"]).["-std=c++17", "-fPIC"]
definesDict{String, String}Preprocessor definitions (macros).{}
parallelBoolEnable multi-threaded compilation.true
source_filesVector{String}Explicit list of source files (overrides discovery).[]
include_dirsVector{String}Explicit list of include directories.[]
aot_thunksBoolPre-compile MLIR virtual-dispatch thunks into a static _thunks.so at build time. Eliminates JIT startup cost for virtual methods; requires the JLCS dialect to be built.false

[link]

Settings for linking and optimizing the LLVM IR.

KeyTypeDescriptionDefault
optimization_levelStringOptimization level ("0", "1", "2", "3", "s", "z")."2"
enable_ltoBoolEnable Link-Time Optimization. When true, emits <name>_lto.bc (LLVM bitcode) alongside the shared library. The generated Julia wrapper loads this bitcode at parse time and routes eligible functions through Base.llvmcall so Julia's JIT can inline C++ code directly into hot loops. Falls back to ccall automatically if the .bc file is absent. Bitcode is assembled via Clang_unified_jll to guarantee LLVM version compatibility with Julia's internal LLVM.false
link_librariesVector{String}External libraries to link against (e.g., ["stdc++fs"]).[]

[binary]

Settings for the final binary artifact.

KeyTypeDescriptionDefault
typeStringOutput type: "shared", "static", or "executable"."shared"
output_nameStringCustom name for the output file.Auto-generated (e.g., libProject.so)
strip_symbolsBoolStrip debug symbols from the final binary (reduces size).false

[wrap]

Settings for the Julia wrapper generator.

KeyTypeDescriptionDefault
enabledBoolWhether to generate the Julia wrapper.true
styleStringWrapping style: "clang" (full), "basic" (simple ccall), "none"."clang"
module_nameStringName of the generated Julia module.Project Name (CamelCase)
use_clang_jlBoolUse Clang.jl for AST parsing during wrapping.true
languageStringExtensible dispatch key for the generator: "c" or "cpp"."cpp"
shim_headersVector{String}Headers #included in the auto-generated macro shim stub.[]

[wrap.varargs]

Overrides for C varargs functions (...). Since Julia cannot easily call C varargs functions natively via ccall without knowing the exact types, you can define type-specific overloads here. RepliBuild will generate concrete function bindings for each signature, bypassing the need for manual shims.

[wrap.varargs]
printf = [
    ["const char*", "int"],
    ["const char*", "double", "int"]
]

[wrap.macros]

Auto-generates typed C/C++ shims for preprocessor macros so they appear in DWARF metadata and can be safely wrapped as regular functions. This replaces the need to write your own wrapper functions for macros.

[wrap.macros.MY_MATH_MACRO]
ret = "int"
args = ["int", "float"]

[types]

Control how C++ types map to Julia types. This is critical for FFI safety.

KeyTypeDescriptionDefault
strictnessStringType checking mode: "strict", "warn", "permissive"."warn"
allow_unknown_structsBoolGenerate opaque pointers for unknown structs instead of failing.true
allow_unknown_enumsBoolMap unknown enums to Int32.false
allow_function_pointersBoolGenerate Ptr{Cvoid} for function pointers.true
customDictCustom type mappings (e.g., {"MyType" = "Int32"}).{}
templatesVector{String}C++ template instantiations to force-emit into DWARF (e.g., ["std::vector<int>"]). RepliBuild auto-generates a stub .cpp that instantiates these types so they appear in metadata.[]
template_headersVector{String}Headers #included in the auto-generated template stub (e.g., ["<vector>", "\"mylib.h\""]).[]

Strictness Modes

  • strict: Fails the build if any type cannot be perfectly mapped.
  • warn: Emits a warning for imperfect mappings but attempts to proceed (e.g., mapping void* for complex pointers).
  • permissive: Silently falls back to Ptr{Cvoid} or Any for unknown types.

[llvm]

LLVM toolchain selection.

KeyTypeDescriptionDefault
toolchainStringHow to find LLVM: "auto", "system", "jll"."auto"
versionStringSpecific LLVM version to use (if available).""

[workflow]

Customize the build pipeline stages.

KeyTypeDescriptionDefault
stagesVector{String}Order of operations.["discover", "compile", "link", "binary", "wrap"]

[cache]

Build caching settings.

KeyTypeDescriptionDefault
enabledBoolEnable build caching to skip unchanged files.true
directoryStringDirectory for cache files.".replibuild_cache"

[dependencies]

RepliBuild can automatically fetch, filter, and compile external C/C++ libraries from git repositories, local paths, or system packages — no BinaryBuilder or JLL packages required.

Each dependency is declared as a named sub-table:

[dependencies.cjson]
type    = "git"
url     = "https://github.com/DaveGamble/cJSON"
tag     = "v1.7.18"
exclude = ["test", "fuzzing", "CMakeLists.txt"]

[dependencies.mylocal]
type = "local"
path = "../vendor/mylib"
exclude = ["docs"]

[dependencies.zlib]
type = "system"
pkg_config = "zlib"

Dependency item fields

KeyTypeDescriptionDefault
typeStringSource kind: "git", "local", or "system".— (required)
urlStringGit clone URL. Required when type = "git".""
tagStringGit tag or branch to check out."" (uses default branch)
pathStringFilesystem path. Required when type = "local".""
pkg_configStringpkg-config package name. Used when type = "system" to resolve include/link flags.""
excludeVector{String}Files or subdirectories to skip during source injection (glob-matched against relative paths). Useful for silencing test files, build scripts, and unrelated C files in single-directory amalgamations.[]

How it works

  1. git dependencies are cloned into .replibuild_cache/deps/<name>/ on first use and updated to the requested tag on subsequent builds. The clone is shallow (--depth 1) when a tag is specified.
  2. local dependencies are scanned in-place. No copying is performed.
  3. system dependencies run pkg-config --cflags to inject include paths into the compile flags.

In all cases, resolved source files are merged into the compilation graph before the [compile] step runs. The exclude list is applied after scanning, so you can trim large repos down to just the files you need.

Example: wrapping cJSON from git

[project]
name = "my_cjson_wrapper"

[dependencies.cjson]
type    = "git"
url     = "https://github.com/DaveGamble/cJSON"
tag     = "v1.7.18"
exclude = ["test", "fuzzing"]

[types]
allow_unknown_structs = true

After RepliBuild.build() and RepliBuild.wrap(), the generated module exposes the full cJSON C API as type-safe Julia functions without any manual binding work.