Fix nix flake and use gcc as compiler

This commit is contained in:
2026-07-26 19:04:49 +01:00
parent edad8ff5cd
commit 9f4c345c74
3 changed files with 36 additions and 45 deletions
+2
View File
@@ -12,3 +12,5 @@ include/bindings/ruby_compiled.h
p.vim
.cache/
result
+7 -9
View File
@@ -4,15 +4,14 @@ OBJ_DIR := build
INCLUDE_DIR := include
SCRIPT_DIR := scripts
TARGET_DEBUG := $(BIN_DIR)/game-dbg
TARGET_RELEASE := $(BIN_DIR)/game
TARGET_DEBUG := $(BIN_DIR)/misth-dbg
TARGET_RELEASE := $(BIN_DIR)/misth
PCH_DEBUG := $(OBJ_DIR)/debug/pch.h.gch
PCH_RELEASE := $(OBJ_DIR)/release/pch.h.gch
CCACHE := ccache
CXX := $(CCACHE) $(shell which clang++)
CC := $(CCACHE) $(shell which clang)
CC ?= gcc
CXX ?= g++
# ---------------- SDL3 ----------------
@@ -36,7 +35,6 @@ CFLAGS_DEBUG := \
CFLAGS_RELEASE := \
-std=c++20 -O3 -mtune=generic \
-flto=thin \
-fno-rtti -fomit-frame-pointer -DNDEBUG -s \
-Wno-unused-command-line-argument \
-I./include -I./libs/mruby/build/host/include \
@@ -59,7 +57,7 @@ DEP_RELEASE := $(OBJ_RELEASE:.o=.d)
.PHONY: all debug release clean scripts
all: debug
all: release
debug: scripts $(TARGET_DEBUG)
@@ -68,7 +66,7 @@ release: scripts $(TARGET_RELEASE)
# ---------------- MRB_MGEMS ----------------
scripts:
$(SCRIPT_DIR)/compile.sh
bash $(SCRIPT_DIR)/compile.sh
# ---------------- PCH ----------------
@@ -115,5 +113,5 @@ $(OBJ_DIR)/release/%.o: $(SRC_DIR)/%.cc $(PCH_RELEASE)
clean:
@rm -rf $(OBJ_DIR) $(BIN_DIR)
$(SCRIPT_DIR)/compile.sh clean
bash $(SCRIPT_DIR)/compile.sh clean
@echo "Cleaned build artifacts."
+27 -36
View File
@@ -1,5 +1,5 @@
{
description = "game engine";
description = "Project Misth";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@@ -10,15 +10,13 @@
{ nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
staticPkgs = pkgs.pkgsStatic;
mruby = staticPkgs.stdenv.mkDerivation {
mruby = pkgs.stdenv.mkDerivation {
pname = "mruby";
version = "0.0.1";
src = staticPkgs.lib.cleanSourceWith {
src = pkgs.lib.cleanSourceWith {
src = ./libs;
name = "mruby-src";
};
@@ -30,7 +28,6 @@
nativeBuildInputs = with pkgs; [
ruby
gnumake
clang
];
buildPhase = ''
@@ -49,25 +46,24 @@
'';
};
game-engine = staticPkgs.stdenv.mkDerivation {
pname = "game-engine";
misth = pkgs.stdenv.mkDerivation {
pname = "misth";
version = "0.1.0";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
pkg-config
gnumake
bear
ccache
xxd
bash
];
buildInputs = [
pkgs.sdl3
pkgs.sdl3-ttf
pkgs.sdl3-image
buildInputs = with pkgs; [
sdl3
sdl3-ttf
sdl3-image
mruby
];
@@ -81,43 +77,38 @@
installPhase = ''
mkdir -p $out/bin
cp game-engine $out/bin/game-engine
cp bin/misth $out/bin/misth
'';
CC = "${pkgs.clang}/bin/clang";
CXX = "${pkgs.clang}/bin/clang++";
};
in
{
packages.${system} = {
default = game-engine;
game-engine = game-engine;
default = misth;
misth = misth;
mruby = mruby;
};
devShells.${system}.default = pkgs.mkShell {
inputsFrom = [ game-engine ];
inputsFrom = [ misth ];
packages = [
pkgs.clang-tools
pkgs.clang
pkgs.ccache
pkgs.pkg-config
pkgs.gnumake
pkgs.bear
pkgs.ruby
pkgs.xxd
packages = with pkgs; [
clang-tools
pkg-config
ccache
gnumake
bear
ruby
xxd
pkgs.sdl3
pkgs.sdl3-ttf
pkgs.sdl3-image
sdl3
sdl3-ttf
sdl3-image
];
shellHook = ''
export CC=clang
export CXX=clang++
export LD=clang
export CC="ccache gcc"
export CXX="ccache g++"
export MRBC=${mruby}/bin/mrbc
export MRUBY_INCLUDE=${mruby}/include