Build System
ELMOS uses Task for build automation and Go’s domain builders for kernel/module/app compilation.
Taskfile Overview
Section titled “Taskfile Overview”The Taskfile.yml provides development tasks:
| Task | Purpose |
|---|---|
task build |
Compile build/elmos with version ldflags |
task test |
Run tests with coverage |
task dev:check |
Format + lint |
task docs |
Build documentation site |
task release:all |
Cross-platform Darwin builds |
Kernel Build System
Section titled “Kernel Build System”KernelBuilder
Section titled “KernelBuilder”Located in core/domain/builder/kernel.go:
type KernelBuilder struct { exec executor.Executor fs filesystem.FileSystem cfg *config.Config ctx *elcontext.Context tm *toolchain.Manager}BuildOptions
Section titled “BuildOptions”type BuildOptions struct { Jobs int // Parallel jobs (-j) Targets []string // e.g., ["Image", "dtbs", "modules"]}Key Methods
Section titled “Key Methods”| Method | Description |
|---|---|
Build(ctx, opts) |
Execute make with targets |
Configure(ctx, configType) |
Run menuconfig, defconfig, etc. |
Clean(ctx) |
Run make distclean |
HasConfig() |
Check if .config exists |
HasKernelImage() |
Check if kernel image built |
Build Flow
Section titled “Build Flow”KernelBuilder.Build() ├── Validate targets against ValidBuildTargets ├── Get toolchain environment (getToolchainEnv) ├── Construct make arguments: │ - ARCH=arm64 │ - LLVM=1 │ - CROSS_COMPILE=<prefix> │ - -j<jobs> └── executor.RunWithEnv(make, args...)Module Build System
Section titled “Module Build System”ModuleBuilder
Section titled “ModuleBuilder”Located in core/domain/builder/module.go:
type ModuleBuilder struct { exec executor.Executor fs filesystem.FileSystem cfg *config.Config ctx *elcontext.Context tm *toolchain.Manager}Key Methods
Section titled “Key Methods”| Method | Description |
|---|---|
Build(ctx, modulePath) |
Build .ko from module source |
Clean(ctx, modulePath) |
Clean module build artifacts |
Create(name) |
Scaffold new module from template |
App Build System
Section titled “App Build System”AppBuilder
Section titled “AppBuilder”Located in core/domain/builder/app.go:
type AppBuilder struct { exec executor.Executor fs filesystem.FileSystem cfg *config.Config ctx *elcontext.Context tm *toolchain.Manager}Cross-compiles userspace applications for the target architecture.
Environment Setup
Section titled “Environment Setup”GetMakeEnv()
Section titled “GetMakeEnv()”The Context.GetMakeEnv() method constructs the build environment:
// Prepends to PATH:// - GNU sed (libexec/gnubin)// - GNU coreutils// - LLVM bin// - LLD bin// - e2fsprogs sbin
// Sets:// - ARCH=<target>// - LLVM=1// - CROSS_COMPILE=<prefix>// - HOSTCFLAGS=<macOS compatibility flags>HOSTCFLAGS
Section titled “HOSTCFLAGS”macOS-specific flags for host tools:
-I<assets/libraries> # Custom elf.h, byteswap.h-I<libelf include> # Homebrew libelf-D_UUID_T-D__GETHOSTUUID_H-D_DARWIN_C_SOURCE-D_FILE_OFFSET_BITS=64Valid Build Targets
Section titled “Valid Build Targets”Defined in core/config/defaults.go:
var ValidBuildTargets = map[string]bool{ "Image": true, "zImage": true, // ARM32 "dtbs": true, "modules": true, "modules_prepare": true, "all": true, "vmlinux": true,}Valid Config Types
Section titled “Valid Config Types”var KernelConfigTypes = []string{ "defconfig", "tinyconfig", "kvm_guest.config", "menuconfig", "xconfig", "nconfig", "oldconfig", "olddefconfig", // ...}CLI Integration
Section titled “CLI Integration”Build Command
Section titled “Build Command”elmos kernel build # Default targets for archelmos kernel build Image # Specific targetelmos kernel build -j 8 # Custom job countConfigure Command
Section titled “Configure Command”elmos kernel config defconfig # Default configelmos kernel config menuconfig # InteractiveDependencies
Section titled “Dependencies”- Go 1.21+ - Language runtime
- Task -
brew install go-task - LLVM - Cross-compiler (
brew install llvm) - GNU tools -
brew install gnu-sed coreutils