Browse Source
- Move renderer.h/cpp and ui_renderer.h/cpp to example/src/ - Move main.cpp to example/src/ - Move raylib and raygui submodules to example/ext/ - Keep tomlc17 submodule at root (library-only dependency) - Root Makefile builds liborbit.a static library + tests - example/Makefile builds orbit_sim, links liborbit.a - All build artifacts go to ./build/ via recursive BUILD_DIR - Remove example/tests/ (sim configs run from project root)main
12 changed files with 74 additions and 62 deletions
@ -1,9 +1,9 @@ |
|||||||
[submodule "ext/raylib"] |
|
||||||
path = ext/raylib |
|
||||||
url = https://github.com/raysan5/raylib.git |
|
||||||
[submodule "ext/tomlc17"] |
[submodule "ext/tomlc17"] |
||||||
path = ext/tomlc17 |
path = ext/tomlc17 |
||||||
url = https://github.com/cktan/tomlc17 |
url = https://github.com/cktan/tomlc17 |
||||||
[submodule "ext/raygui"] |
[submodule "example/ext/raylib"] |
||||||
path = ext/raygui |
path = example/ext/raylib |
||||||
|
url = https://github.com/raysan5/raylib.git |
||||||
|
[submodule "example/ext/raygui"] |
||||||
|
path = example/ext/raygui |
||||||
url = https://github.com/raysan5/raygui.git |
url = https://github.com/raysan5/raygui.git |
||||||
|
|||||||
@ -1,87 +1,57 @@ |
|||||||
# Compiler and flags
|
|
||||||
CXX = g++
|
CXX = g++
|
||||||
CXXFLAGS = -Wall -Wextra -g -ggdb3 -std=c++14 \
|
CXXFLAGS = -Wall -Wextra -g -ggdb3 -std=c++14 \
|
||||||
-I./src \
|
-I./src \
|
||||||
-isystem./ext/tomlc17/src \
|
-isystem./ext/tomlc17/src
|
||||||
-isystem./ext/raylib/src \
|
LDFLAGS = -lm
|
||||||
-isystem./ext/raygui/src \
|
|
||||||
-isystem./ext/raygui/styles
|
|
||||||
LDFLAGS = -L./ext/raylib/src -lraylib -lm -lpthread -ldl -lrt -lX11
|
|
||||||
|
|
||||||
# Directories
|
|
||||||
SRC_DIR = src
|
SRC_DIR = src
|
||||||
BUILD_DIR ?= build
|
BUILD_DIR ?= build
|
||||||
RAYLIB_DIR = ext/raylib/src
|
|
||||||
TARGET = ${BUILD_DIR}/orbit_sim
|
|
||||||
TEST_DIR = tests
|
TEST_DIR = tests
|
||||||
TEST_TARGET = ${BUILD_DIR}/orbit_test
|
|
||||||
|
|
||||||
# Source files (exclude old mission planning files)
|
|
||||||
CPP_SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
|
CPP_SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
|
||||||
C_SOURCES = ext/tomlc17/src/tomlc17.c
|
C_SOURCES = ext/tomlc17/src/tomlc17.c
|
||||||
TEST_SOURCES := $(wildcard $(TEST_DIR)/*.cpp)
|
TEST_SOURCES := $(wildcard $(TEST_DIR)/*.cpp)
|
||||||
|
|
||||||
# Object files
|
|
||||||
CPP_OBJECTS = $(CPP_SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
|
CPP_OBJECTS = $(CPP_SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
|
||||||
C_OBJECTS = $(BUILD_DIR)/tomlc17.o
|
C_OBJECTS = $(BUILD_DIR)/tomlc17.o
|
||||||
TEST_OBJECTS := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(TEST_SOURCES))
|
TEST_OBJECTS := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(TEST_SOURCES))
|
||||||
|
|
||||||
# Default target (updates ctags if available)
|
LIBRARY = $(BUILD_DIR)/liborbit.a
|
||||||
all: raylib $(BUILD_DIR) $(TARGET) |
|
||||||
@command -v ctags >/dev/null 2>&1 && ctags -R tests/ src/ || true
|
|
||||||
|
|
||||||
# Build raylib
|
all: lib test-build example |
||||||
raylib: |
|
||||||
@if [ ! -f $(RAYLIB_DIR)/libraylib.a ]; then \
|
|
||||||
echo "Building raylib..."; \
|
|
||||||
cd $(RAYLIB_DIR) && $(MAKE) PLATFORM=PLATFORM_DESKTOP; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create build directory
|
|
||||||
$(BUILD_DIR): |
$(BUILD_DIR): |
||||||
mkdir -p $(BUILD_DIR)
|
mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
# Link the executable
|
|
||||||
$(TARGET): $(C_OBJECTS) $(CPP_OBJECTS) raylib |
|
||||||
$(CXX) $(C_OBJECTS) $(CPP_OBJECTS) -o $(TARGET) $(LDFLAGS)
|
|
||||||
|
|
||||||
# Compile C++ source files
|
|
||||||
$(CPP_OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp |
$(CPP_OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp |
||||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
# Compile C source files
|
|
||||||
$(C_OBJECTS): $(BUILD_DIR)/%.o : $(C_SOURCES) |
$(C_OBJECTS): $(BUILD_DIR)/%.o : $(C_SOURCES) |
||||||
$(CC) -Wall -Wextra -g -ggdb3 -std=c99 -I./src -I./ext/tomlc17/src -c $< -o $@
|
$(CC) -Wall -Wextra -g -ggdb3 -std=c99 -I./src -I./ext/tomlc17/src -c $< -o $@
|
||||||
|
|
||||||
# Clean build files
|
lib: $(BUILD_DIR) $(C_OBJECTS) $(CPP_OBJECTS) |
||||||
clean: |
ar rcs $(LIBRARY) $(C_OBJECTS) $(CPP_OBJECTS)
|
||||||
rm -rf $(BUILD_DIR) $(TARGET) $(TEST_TARGET)
|
@echo "Built $(LIBRARY)"
|
||||||
|
|
||||||
# Clean everything including raylib
|
|
||||||
clean-all: clean |
|
||||||
cd $(RAYLIB_DIR) && $(MAKE) clean
|
|
||||||
|
|
||||||
# Rebuild
|
|
||||||
rebuild: clean all |
|
||||||
|
|
||||||
$(TEST_OBJECTS): $(BUILD_DIR)/%.o : $(TEST_DIR)/%.cpp |
$(TEST_OBJECTS): $(BUILD_DIR)/%.o : $(TEST_DIR)/%.cpp |
||||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
# Build automated test suite
|
test-build: lib $(BUILD_DIR) $(TEST_OBJECTS) |
||||||
test-build: $(BUILD_DIR) $(C_OBJECTS) $(CPP_OBJECTS) $(TEST_OBJECTS) |
$(CXX) $(TEST_OBJECTS) -o $(BUILD_DIR)/orbit_test -L$(BUILD_DIR) -lorbit -lCatch2Main -lCatch2 -lm
|
||||||
$(CXX) $(C_OBJECTS) $(TEST_OBJECTS) \
|
|
||||||
build/test_utilities.o \
|
|
||||||
build/physics.o \
|
|
||||||
build/orbital_mechanics.o \
|
|
||||||
build/simulation.o \
|
|
||||||
build/config_loader.o \
|
|
||||||
build/config_validator.o \
|
|
||||||
build/maneuver.o \
|
|
||||||
build/rendezvous.o \
|
|
||||||
-o $(TEST_TARGET) -lCatch2Main -lCatch2 -lm
|
|
||||||
|
|
||||||
# Run automated test suite
|
|
||||||
test: test-build |
test: test-build |
||||||
./$(TEST_TARGET)
|
./$(BUILD_DIR)/orbit_test
|
||||||
|
|
||||||
|
example: lib |
||||||
|
$(MAKE) -C example all BUILD_DIR=../$(BUILD_DIR)
|
||||||
|
|
||||||
|
clean: |
||||||
|
rm -rf $(BUILD_DIR) $(LIBRARY)
|
||||||
|
$(MAKE) -C example clean
|
||||||
|
|
||||||
|
clean-all: clean |
||||||
|
$(MAKE) -C example clean-all
|
||||||
|
|
||||||
|
rebuild: clean all |
||||||
|
|
||||||
.PHONY: all clean clean-all rebuild test test-build raylib ctags |
.PHONY: all lib test-build test example clean clean-all rebuild |
||||||
|
|||||||
@ -0,0 +1,42 @@ |
|||||||
|
CXX = g++
|
||||||
|
CXXFLAGS = -Wall -Wextra -g -ggdb3 -std=c++14 \
|
||||||
|
-I./src \
|
||||||
|
-I../src \
|
||||||
|
-isystem./ext/raylib/src \
|
||||||
|
-isystem./ext/raygui/src \
|
||||||
|
-isystem./ext/raygui/styles
|
||||||
|
LDFLAGS = -L./ext/raylib/src -lraylib -lm -lpthread -ldl -lrt -lX11
|
||||||
|
|
||||||
|
SRC_DIR = src
|
||||||
|
BUILD_DIR ?= build
|
||||||
|
RAYLIB_DIR = ext/raylib/src
|
||||||
|
|
||||||
|
CPP_SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
|
||||||
|
|
||||||
|
CPP_OBJECTS = $(CPP_SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
|
||||||
|
|
||||||
|
TARGET = ${BUILD_DIR}/orbit_sim
|
||||||
|
|
||||||
|
raylib: |
||||||
|
@if [ ! -f $(RAYLIB_DIR)/libraylib.a ]; then \
|
||||||
|
cd $(RAYLIB_DIR) && $(MAKE) PLATFORM=PLATFORM_DESKTOP; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
$(BUILD_DIR): |
||||||
|
mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
|
$(TARGET): $(CPP_OBJECTS) raylib |
||||||
|
$(CXX) $(CPP_OBJECTS) -o $(TARGET) -L$(BUILD_DIR) -lorbit $(LDFLAGS)
|
||||||
|
|
||||||
|
$(CPP_OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp |
||||||
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
clean: |
||||||
|
rm -f $(TARGET)
|
||||||
|
@for f in $(CPP_SOURCES); do rm -f $(BUILD_DIR)/$$(basename $${f%.cpp}.o); done
|
||||||
|
|
||||||
|
rebuild: clean all |
||||||
|
|
||||||
|
all: raylib $(BUILD_DIR) $(TARGET) |
||||||
|
|
||||||
|
.PHONY: all clean raylib rebuild |
||||||
Loading…
Reference in new issue