From 0aca4b49ca5c82186f58a013f8b6fbade9775005 Mon Sep 17 00:00:00 2001 From: huntedbytheirs Date: Tue, 4 Aug 2026 12:19:52 -0400 Subject: [PATCH] qol: implement easier building and distribution --- .gitignore | 5 +++- Makefile | 55 +++++++++++++++++++++++++++++++++++ include/kappa/build/build.hpp | 23 +++++++++++++++ src/build/build.cpp | 18 ++++++++++++ 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 include/kappa/build/build.hpp create mode 100644 src/build/build.cpp diff --git a/.gitignore b/.gitignore index 443e28b..68774aa 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,10 @@ *.app # Build -build/ +/build/ +/build-debug/ +/build-release/ +/dist/ build-gcc/ compile_commands.json vcpkg_installed/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..72bb038 --- /dev/null +++ b/Makefile @@ -0,0 +1,55 @@ +# kappa — build convenience Makefile +# +# Targets: +# build — default build (build/) +# debug — Debug build (build-debug/) +# release - Release build (build-release/) +# dist - tar.zst tarball of the release build (requires zstd) +# dist-clean - remove everything under dist/ +# +# Overridable: make release CXX=g++ GENERATOR="Unix Makefiles" + +CC ?= clang +CXX ?= clang++ +GENERATOR ?= Ninja + +BUILD_DIR ?= build +DEBUG_DIR ?= build-debug +RELEASE_DIR ?= build-release +DIST_DIR ?= dist + +GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) +GIT_TAG := $(shell git describe --tags --abbrev=0 2>/dev/null || echo 0.1.0) +STAMP := $(shell date +%Y-%M) +DIST_NAME := kappa-$(GIT_COMMIT)-$(GIT_TAG)-$(STAMP) + +CMAKE := cmake + +.PHONY: build debug release dist dist-clean + +build: + $(CMAKE) -S . -B $(BUILD_DIR) -G $(GENERATOR) \ + -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) + $(CMAKE) --build $(BUILD_DIR) + +debug: + $(CMAKE) -S . -B $(DEBUG_DIR) -G $(GENERATOR) \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) + $(CMAKE) --build $(DEBUG_DIR) + +release: + $(CMAKE) -S . -B $(RELEASE_DIR) -G $(GENERATOR) \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) + $(CMAKE) --build $(RELEASE_DIR) + +dist: release + rm -rf $(DIST_DIR)/$(DIST_NAME) + $(CMAKE) --install $(RELEASE_DIR) --prefix $(DIST_DIR)/$(DIST_NAME) + tar --zstd -cf $(DIST_DIR)/$(DIST_NAME).tar.zst -C $(DIST_DIR) $(DIST_NAME) + rm -rf $(DIST_DIR)/$(DIST_NAME) + @echo "dist: $(DIST_DIR)/$(DIST_NAME).tar.zst" + +dist-clean: + rm -rf $(DIST_DIR) diff --git a/include/kappa/build/build.hpp b/include/kappa/build/build.hpp new file mode 100644 index 0000000..0de7824 --- /dev/null +++ b/include/kappa/build/build.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "kappa/resolve/plan.hpp" + +#include + +namespace kappa::build { + +struct BuildResult { + bool ok = false; + std::string phase; // phase that failed, e.g. "prepare" or "build" + std::string error; +}; + +// Build a single package step into work_dir. +// +// NOTE: compile-only stub — the real build backend was never committed. +// Always fails so the rebuild pipeline never records a fake install. +BuildResult build(const resolve::BuildStep& step, + const std::string& work_dir, + int jobs); + +} // namespace kappa::build diff --git a/src/build/build.cpp b/src/build/build.cpp new file mode 100644 index 0000000..0778bcc --- /dev/null +++ b/src/build/build.cpp @@ -0,0 +1,18 @@ +#include "kappa/build/build.hpp" + +#include + +namespace kappa::build { + +BuildResult build(const resolve::BuildStep& step, + const std::string& work_dir, + int jobs) { + BuildResult result; + result.phase = "build"; + result.error = std::format( + "build backend not implemented (stub): {} in {} (jobs={})", + step.name, work_dir, jobs); + return result; +} + +} // namespace kappa::build