Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f4c345c74
|
||
|
|
edad8ff5cd
|
||
|
|
1935be52ac
|
||
|
|
a9054b3be4
|
@@ -12,3 +12,5 @@ include/bindings/ruby_compiled.h
|
|||||||
p.vim
|
p.vim
|
||||||
|
|
||||||
.cache/
|
.cache/
|
||||||
|
|
||||||
|
result
|
||||||
|
|||||||
@@ -2,16 +2,16 @@ SRC_DIR := src
|
|||||||
BIN_DIR := bin
|
BIN_DIR := bin
|
||||||
OBJ_DIR := build
|
OBJ_DIR := build
|
||||||
INCLUDE_DIR := include
|
INCLUDE_DIR := include
|
||||||
|
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 ----------------
|
||||||
|
|
||||||
@@ -19,6 +19,11 @@ SDL_CFLAGS := $(shell pkg-config --cflags sdl3 sdl3-ttf sdl3-image)
|
|||||||
SDL_LIBS_DEBUG := $(shell pkg-config --libs sdl3 sdl3-ttf sdl3-image)
|
SDL_LIBS_DEBUG := $(shell pkg-config --libs sdl3 sdl3-ttf sdl3-image)
|
||||||
SDL_LIBS_RELEASE := $(shell pkg-config --libs sdl3 sdl3-ttf sdl3-image)
|
SDL_LIBS_RELEASE := $(shell pkg-config --libs sdl3 sdl3-ttf sdl3-image)
|
||||||
|
|
||||||
|
# ----------------- MRUBY --------------
|
||||||
|
|
||||||
|
MRUBY_CFLAGS := -I$(MRUBY_INCLUDE)
|
||||||
|
MRUBY_LIBS := $(MRUBY_LIB)
|
||||||
|
|
||||||
# ---------------- FLAGS ----------------
|
# ---------------- FLAGS ----------------
|
||||||
|
|
||||||
CFLAGS_DEBUG := \
|
CFLAGS_DEBUG := \
|
||||||
@@ -26,25 +31,18 @@ CFLAGS_DEBUG := \
|
|||||||
-Og -g -fno-omit-frame-pointer \
|
-Og -g -fno-omit-frame-pointer \
|
||||||
-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 \
|
||||||
$(SDL_CFLAGS)
|
$(SDL_CFLAGS) $(MRUBY_CFLAGS)
|
||||||
|
|
||||||
CFLAGS_RELEASE := \
|
CFLAGS_RELEASE := \
|
||||||
-std=c++20 -O3 -march=x86-64 -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 \
|
||||||
$(SDL_CFLAGS)
|
$(SDL_CFLAGS) $(MRUBY_CFLAGS)
|
||||||
|
|
||||||
PCH_CFLAGS_DEBUG := $(CFLAGS_DEBUG) -x c++-header
|
PCH_CFLAGS_DEBUG := $(CFLAGS_DEBUG) -x c++-header
|
||||||
PCH_CFLAGS_RELEASE := $(CFLAGS_RELEASE) -x c++-header
|
PCH_CFLAGS_RELEASE := $(CFLAGS_RELEASE) -x c++-header
|
||||||
|
|
||||||
# ---------------- LIBS ----------------
|
|
||||||
|
|
||||||
LIBS := ./libs/mruby/build/host/lib/libmruby.a
|
|
||||||
|
|
||||||
MGEM_DIR := ./libs/l_mgems
|
|
||||||
|
|
||||||
# ---------------- SOURCES ----------------
|
# ---------------- SOURCES ----------------
|
||||||
|
|
||||||
SRC := $(shell find $(SRC_DIR) -name "*.cc")
|
SRC := $(shell find $(SRC_DIR) -name "*.cc")
|
||||||
@@ -57,18 +55,18 @@ DEP_RELEASE := $(OBJ_RELEASE:.o=.d)
|
|||||||
|
|
||||||
# ---------------- TARGETS ----------------
|
# ---------------- TARGETS ----------------
|
||||||
|
|
||||||
.PHONY: all debug release clean mgems
|
.PHONY: all debug release clean scripts
|
||||||
|
|
||||||
all: debug
|
all: release
|
||||||
|
|
||||||
debug: mgems $(TARGET_DEBUG)
|
debug: scripts $(TARGET_DEBUG)
|
||||||
|
|
||||||
release: mgems $(TARGET_RELEASE)
|
release: scripts $(TARGET_RELEASE)
|
||||||
|
|
||||||
# ---------------- MRB_MGEMS ----------------
|
# ---------------- MRB_MGEMS ----------------
|
||||||
|
|
||||||
mgems:
|
scripts:
|
||||||
@$(MGEM_DIR)/compile.sh
|
bash $(SCRIPT_DIR)/compile.sh
|
||||||
|
|
||||||
# ---------------- PCH ----------------
|
# ---------------- PCH ----------------
|
||||||
|
|
||||||
@@ -86,12 +84,12 @@ $(PCH_RELEASE): $(INCLUDE_DIR)/pch.h
|
|||||||
|
|
||||||
$(TARGET_DEBUG): $(PCH_DEBUG) $(OBJ_DEBUG)
|
$(TARGET_DEBUG): $(PCH_DEBUG) $(OBJ_DEBUG)
|
||||||
@mkdir -p $(BIN_DIR)
|
@mkdir -p $(BIN_DIR)
|
||||||
@$(CXX) $(CFLAGS_DEBUG) -o $@ $(OBJ_DEBUG) $(SDL_LIBS_DEBUG) $(LIBS)
|
@$(CXX) $(CFLAGS_DEBUG) -o $@ $(OBJ_DEBUG) $(SDL_LIBS_DEBUG) $(MRUBY_LIBS)
|
||||||
@echo "Debug build complete: $@"
|
@echo "Debug build complete: $@"
|
||||||
|
|
||||||
$(TARGET_RELEASE): $(PCH_RELEASE) $(OBJ_RELEASE)
|
$(TARGET_RELEASE): $(PCH_RELEASE) $(OBJ_RELEASE)
|
||||||
@mkdir -p $(BIN_DIR)
|
@mkdir -p $(BIN_DIR)
|
||||||
@$(CXX) $(CFLAGS_RELEASE) -o $@ $(OBJ_RELEASE) $(SDL_LIBS_RELEASE) $(LIBS)
|
@$(CXX) $(CFLAGS_RELEASE) -o $@ $(OBJ_RELEASE) $(SDL_LIBS_RELEASE) $(MRUBY_LIBS)
|
||||||
@echo "Release build complete: $@"
|
@echo "Release build complete: $@"
|
||||||
|
|
||||||
# ---------------- COMPILE ----------------
|
# ---------------- COMPILE ----------------
|
||||||
@@ -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)
|
||||||
@$(MGEM_DIR)/compile.sh clean
|
bash $(SCRIPT_DIR)/compile.sh clean
|
||||||
@echo "Cleaned build artifacts."
|
@echo "Cleaned build artifacts."
|
||||||
|
|||||||
@@ -1,43 +1,119 @@
|
|||||||
{
|
{
|
||||||
description = "game";
|
description = "Project Misth";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
self.submodules = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs }:
|
outputs =
|
||||||
|
{ nixpkgs, ... }:
|
||||||
let
|
let
|
||||||
systems = [ "x86_64-linux" ];
|
system = "x86_64-linux";
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
|
||||||
forAllSystems = f:
|
mruby = pkgs.stdenv.mkDerivation {
|
||||||
nixpkgs.lib.genAttrs systems (system:
|
pname = "mruby";
|
||||||
f (import nixpkgs {
|
version = "0.0.1";
|
||||||
inherit system;
|
|
||||||
}));
|
|
||||||
in {
|
|
||||||
devShells = forAllSystems (pkgs: {
|
|
||||||
default = pkgs.mkShell {
|
|
||||||
packages = with pkgs; [
|
|
||||||
clang-tools
|
|
||||||
clang
|
|
||||||
ccache
|
|
||||||
pkg-config
|
|
||||||
gnumake
|
|
||||||
ruby
|
|
||||||
xxd
|
|
||||||
bear
|
|
||||||
|
|
||||||
sdl3
|
src = pkgs.lib.cleanSourceWith {
|
||||||
sdl3-ttf
|
src = ./libs;
|
||||||
sdl3-image
|
name = "mruby-src";
|
||||||
];
|
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
export CC=clang
|
|
||||||
export CXX=clang++
|
|
||||||
export LD=clang
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
patches = [
|
||||||
|
./libs/changes.patch
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
ruby
|
||||||
|
gnumake
|
||||||
|
];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
cd mruby
|
||||||
|
rake
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
|
||||||
|
cp -r build/host/lib $out/lib
|
||||||
|
cp -r build/host/include $out/include
|
||||||
|
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp build/host/bin/mrbc $out/bin/mrbc
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
misth = pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "misth";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
pkg-config
|
||||||
|
gnumake
|
||||||
|
bear
|
||||||
|
xxd
|
||||||
|
bash
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
sdl3
|
||||||
|
sdl3-ttf
|
||||||
|
sdl3-image
|
||||||
|
|
||||||
|
mruby
|
||||||
|
];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
make \
|
||||||
|
MRBC=${mruby}/bin/mrbc \
|
||||||
|
MRUBY_INCLUDE=${mruby}/include \
|
||||||
|
MRUBY_LIB=${mruby}/lib/libmruby.a
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp bin/misth $out/bin/misth
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages.${system} = {
|
||||||
|
default = misth;
|
||||||
|
misth = misth;
|
||||||
|
mruby = mruby;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.${system}.default = pkgs.mkShell {
|
||||||
|
inputsFrom = [ misth ];
|
||||||
|
|
||||||
|
packages = with pkgs; [
|
||||||
|
clang-tools
|
||||||
|
pkg-config
|
||||||
|
ccache
|
||||||
|
gnumake
|
||||||
|
bear
|
||||||
|
ruby
|
||||||
|
xxd
|
||||||
|
|
||||||
|
sdl3
|
||||||
|
sdl3-ttf
|
||||||
|
sdl3-image
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
export CC="ccache gcc"
|
||||||
|
export CXX="ccache g++"
|
||||||
|
|
||||||
|
export MRBC=${mruby}/bin/mrbc
|
||||||
|
export MRUBY_INCLUDE=${mruby}/include
|
||||||
|
export MRUBY_LIB=${mruby}/lib/libmruby.a
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ERect : Element {
|
struct ERect : Element {
|
||||||
Color color = {255, 255, 255};
|
|
||||||
Vec2<float> shape = {0, 0};
|
Vec2<float> shape = {0, 0};
|
||||||
|
Color color = {255, 255, 255};
|
||||||
|
|
||||||
Vec2<float> size() override;
|
Vec2<float> size() override;
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -3,8 +3,12 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
struct Entity;
|
struct Entity {};
|
||||||
struct Component;
|
struct Component;
|
||||||
struct System;
|
struct System;
|
||||||
|
|
||||||
|
struct EntityPool {
|
||||||
|
Entity entities[];
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
--- ./mruby/build_config/default.rb
|
||||||
|
+++ ./mruby/build_config/default.rb
|
||||||
|
@@ -1,6 +1,18 @@
|
||||||
|
MRuby::Build.new do |conf|
|
||||||
|
# load specific toolchain settings
|
||||||
|
- conf.toolchain
|
||||||
|
+ conf.toolchain :gcc
|
||||||
|
+
|
||||||
|
+ conf.cc do |cc|
|
||||||
|
+ cc.command = ENV['CC']
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ conf.cxx do |cxx|
|
||||||
|
+ cxx.command = ENV['CXX']
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ conf.linker do |linker|
|
||||||
|
+ linker.command = ENV['CXX']
|
||||||
|
+ end
|
||||||
|
|
||||||
|
# Use mrbgems
|
||||||
|
# conf.gem 'examples/mrbgems/ruby_extension_example'
|
||||||
|
@@ -79,5 +79,5 @@
|
||||||
|
# Turn on `enable_debug` for better debugging
|
||||||
|
# conf.enable_debug
|
||||||
|
- conf.enable_bintest
|
||||||
|
- conf.enable_test
|
||||||
|
+ # conf.enable_bintest
|
||||||
|
+ # conf.enable_test
|
||||||
|
end
|
||||||
@@ -58,12 +58,18 @@ rect.click do
|
|||||||
end
|
end
|
||||||
|
|
||||||
App.map_key :mouse_left, :action_name
|
App.map_key :mouse_left, :action_name
|
||||||
|
App.map_key :q, :quit
|
||||||
|
|
||||||
start = Time.now
|
start = Time.now
|
||||||
c_ = 0.0
|
c_ = 0.0
|
||||||
c_c = 0
|
c_c = 0
|
||||||
|
|
||||||
App.update do |delta_time|
|
App.update do |delta_time|
|
||||||
|
if App.pressed?(:quit)
|
||||||
|
App.exit!
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
c_ += delta_time
|
c_ += delta_time
|
||||||
c_c += 1
|
c_c += 1
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ set -e
|
|||||||
|
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
OUTPUT_TMP=$(mktemp)
|
OUTPUT_TMP=$(mktemp)
|
||||||
OUTPUT="$SCRIPT_DIR/../../include/bindings/ruby_compiled.h"
|
OUTPUT="$SCRIPT_DIR/../include/bindings/ruby_compiled.h"
|
||||||
|
|
||||||
if test "$1" = "clean"; then
|
if test "$1" = "clean"; then
|
||||||
rm -f "$OUTPUT"
|
rm -f "$OUTPUT"
|
||||||
@@ -28,7 +28,7 @@ fi
|
|||||||
|
|
||||||
echo "Compiling mgems..."
|
echo "Compiling mgems..."
|
||||||
|
|
||||||
"$SCRIPT_DIR/../mruby/bin/mrbc" -o "$OUTPUT_TMP" "${FILES[@]}"
|
"${MRBC:-mrbc}" -o "$OUTPUT_TMP" "${FILES[@]}"
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "#ifndef MGEMS_H"
|
echo "#ifndef MGEMS_H"
|
||||||
Reference in New Issue
Block a user