qol: implement easier building and distribution
This commit is contained in:
+4
-1
@@ -33,7 +33,10 @@
|
|||||||
*.app
|
*.app
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
build/
|
/build/
|
||||||
|
/build-debug/
|
||||||
|
/build-release/
|
||||||
|
/dist/
|
||||||
build-gcc/
|
build-gcc/
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
vcpkg_installed/
|
vcpkg_installed/
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "kappa/resolve/plan.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
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
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#include "kappa/build/build.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
|
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
|
||||||
Reference in New Issue
Block a user