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