feat: DSL parser, eval system, and project structure
- Hand-written lexer + recursive-descent parser for .kap package definitions
- Package constructs: const, license, provides, outputs, patches, depends
(version-constrained, feature-gated, output-targeted), features (enabled/
forced/flag), config files (default/replace/merge with cfg interpolation),
env (?= soft-set), prepare/build/check/install phases
- Evaluator: recursive resolver for prefix, jobopts, destdir, userargs,
cfg.*, feature.*, package vars
- Comments: // single-line, /* */ multi-line
- /kappa/{bin,temp,db,system,system/builds} path layout
- Clang 22, C++23, CMake + vcpkg (tomlplusplus)
- .clangd + .clang-tidy configured
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* foo — a web server with optional SSL and GUI support.
|
||||
* Demonstrates the full kappa DSL surface.
|
||||
*/
|
||||
package "foo" {
|
||||
const version = "1.2.3"
|
||||
const source = "https://example.com/foo-${version}.tar.gz"
|
||||
license = "MIT"
|
||||
|
||||
provides = ["libfoo.so.1", "foo"]
|
||||
|
||||
patches = [
|
||||
{
|
||||
url = "https://example.com/fix-build.patch"
|
||||
sha256 = "abc123def456"
|
||||
level = 1
|
||||
},
|
||||
"local-fix.patch" // local shorthand, no hash
|
||||
]
|
||||
outputs = ["bin", "lib", "dev"]
|
||||
|
||||
depends = [
|
||||
{ name = "zlib", version = ">=1.2,<2.0" },
|
||||
{ name = "openssl", feature = "ssl" },
|
||||
{ name = "gtk", feature = "gui", version = ">=3" },
|
||||
"gettext:lib" // name:output shorthand
|
||||
]
|
||||
|
||||
features {
|
||||
ssl = { enabled = true, flag = "--with-ssl-dir=${cfg.ssl_dir}" }
|
||||
gui = { enabled = false, flag = "--enable-gui" }
|
||||
drivers = { enabled = true, force = true }
|
||||
debug = false
|
||||
}
|
||||
|
||||
config {
|
||||
// Written once, left alone on rebuild if the user edits it.
|
||||
file "etc/foo.conf" mode = "default" {
|
||||
hostname = ${cfg.hostname !} // required — user must set
|
||||
listen_port = ${cfg.port ? 8080} // optional, default 8080
|
||||
ssl_enabled = ${cfg.ssl ? true} // optional, default true
|
||||
}
|
||||
|
||||
// Always overwritten on rebuild.
|
||||
file "etc/log.conf" mode = "replace" {
|
||||
log_level = ${cfg.log_level ? info}
|
||||
log_path = ${cfg.log_path ? /var/log/foo}
|
||||
}
|
||||
|
||||
// Three-way diff on rebuild.
|
||||
file "etc/limits.conf" mode = "merge" {
|
||||
max_connections = ${cfg.max_conn ? 1024}
|
||||
}
|
||||
}
|
||||
|
||||
env {
|
||||
CFLAGS = "-O2 -march=native"
|
||||
LDFLAGS = "-Wl,--as-needed"
|
||||
CFLAGS ?= "-g"
|
||||
}
|
||||
|
||||
prepare {
|
||||
patch "fix-build.patch"
|
||||
}
|
||||
|
||||
build {
|
||||
./configure --prefix=${prefix} ${feature.ssl} ${feature.gui}
|
||||
make -j${jobs}
|
||||
}
|
||||
|
||||
check {
|
||||
make check
|
||||
}
|
||||
|
||||
install {
|
||||
make DESTDIR=${destdir} install
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user