(sigil build native)
Native Package Support
This module provides functions for detecting and building native packages (packages with C code) during the bundling process.
When an app depends on packages with native code (c-sources in their library definitions), we need to:
- Detect which packages have native code
- Generate an entrypoint that initializes all native modules
- Compile the native code
- Link a custom runtime
Exports
package-has-native-code?procedureCheck if a package has native code (C sources with native-init).
A package has native code if it has a libraries: field with at least one library that has c-sources and native-init.
find-native-packagesprocedureFind all native packages from a list of loaded packages.
Returns a list of packages that have native code.
collect-native-init-functionsprocedureCollect all native-init function names from packages.
Returns a list of strings (C function names) in dependency order.
collect-native-include-dirsprocedureCollect all C include directories from native packages.
Returns an alist of (package-path . include-dirs).
collect-native-sourcesprocedureCollect all C source files from native packages.
Returns an alist of (package-name . source-patterns).
generate-native-entrypointprocedureGenerate the C code for a custom runtime entrypoint.
This creates a main.c that:
- Includes sigil.h and necessary headers
- Declares extern for each native init function
- Creates the VM and calls native init functions
- Reads manifest from bundled archive (if available)
- For scripts: loads the script with (load)
- For programs: imports entry module and calls (main)
init-functions: list of C function name strings entry-module: string like "(my-app main)" - fallback if no manifest
Returns the generated C code as a string.
generate-dev-entrypointprocedureGenerate a dev build entrypoint with native module support.
This is similar to generate-native-entrypoint but includes DEV_BUILD features like boot-eval command and dev library path setup.
init-functions: list of C function name strings entry-module: string like "(sigil cli)"
Returns the generated C code as a string.