Improve build system, add model and icon sources
This commit is contained in:
parent
7c2a6c8341
commit
2a786b9c7e
|
@ -1,5 +1,8 @@
|
|||
build
|
||||
build_sdl
|
||||
racing
|
||||
racing.bin
|
||||
racing.g3a
|
||||
prizm/*
|
||||
!prizm/Makefile
|
||||
|
||||
sdl/*
|
||||
!sdl/Makefile
|
||||
|
||||
resources/models/models.h
|
||||
resources/models/models.blend1
|
||||
|
|
49
Makefile
49
Makefile
|
@ -1,46 +1,15 @@
|
|||
CC = g++
|
||||
CFLAGS += -Wall -Wextra
|
||||
CFLAGS += -DSDL
|
||||
LIB += -lSDL2 -lSDL2_ttf
|
||||
LDFLAGS = $(LIB)
|
||||
INCLUDES =
|
||||
all: sdl prizm
|
||||
|
||||
SRCDIR = src
|
||||
sdl: sdl/racing
|
||||
|
||||
SOURCES = $(wildcard src/*.cpp)
|
||||
OBJECTS = $(patsubst $(SRCDIR)/%,build_sdl/%,$(SOURCES:.cpp=.o))
|
||||
DEPS = $(patsubst $(SRCDIR)/%,build_sdl/%,$(SOURCES:.cpp=.d))
|
||||
|
||||
TARGET = racing
|
||||
|
||||
all: debug
|
||||
|
||||
debug: CFLAGS += -Og -g
|
||||
debug: $(TARGET)
|
||||
|
||||
release: CFLAGS += -Ofast
|
||||
release: $(TARGET)
|
||||
|
||||
profile-generate: CFLAGS += -fprofile-generate
|
||||
profile-generate: LDFLAGS += -fprofile-generate
|
||||
profile-generate: release
|
||||
|
||||
profile-use: CFLAGS += -fprofile-use=profile
|
||||
profile-use: LDFLAGS += -fprofile-use=profile -lgcov
|
||||
profile-use: release
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
@echo "Linking..."
|
||||
$(CC) $^ -o $(TARGET) $(LIB)
|
||||
|
||||
build_sdl/%.o: $(SRCDIR)/%.cpp
|
||||
mkdir -p build_sdl
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ -MMD $< -MF "build_sdl/$(patsubst $(SRCDIR)/%,%,$(<:.cpp=.d))"
|
||||
prizm: prizm/racing.g3a
|
||||
|
||||
clean:
|
||||
rm $(TARGET)
|
||||
rm build_sdl -r
|
||||
make $(MFLAGS) -C sdl/ clean
|
||||
make $(MFLAGS) -C prizm/ clean
|
||||
|
||||
.PHONY: clean
|
||||
sdl/racing:
|
||||
make $(MFLAGS) -C sdl/
|
||||
|
||||
-include $(DEPS)
|
||||
prizm/racing.g3a:
|
||||
make $(MFLAGS) -C prizm/
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# to use a system environment var in the future.
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(FXCGSDK)),)
|
||||
export FXCGSDK := $(abspath ../../)
|
||||
export FXCGSDK := $(abspath ../../../)
|
||||
endif
|
||||
|
||||
include $(FXCGSDK)/toolchain/prizm_rules
|
||||
|
@ -19,9 +19,9 @@ include $(FXCGSDK)/toolchain/prizm_rules
|
|||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
TARGET := racing
|
||||
BUILD := build
|
||||
SOURCES := src
|
||||
SOURCES := ../src
|
||||
DATA := data
|
||||
INCLUDES :=
|
||||
|
||||
|
@ -29,7 +29,7 @@ INCLUDES :=
|
|||
# options for code and add-in generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
MKG3AFLAGS := -n basic:racing -i uns:../resources/unselected.bmp -i sel:../resources/selected.bmp
|
||||
MKG3AFLAGS := -n basic:racing -i uns:../../resources/icons/unselected.bmp -i sel:../../resources/icons/selected.bmp
|
||||
|
||||
# Optional: add -flto to CFLAGS and LDFLAGS to enable link-time optimization
|
||||
# (LTO). Doing so will usually allow the compiler to generate much better code
|
||||
|
@ -105,7 +105,7 @@ export OUTPUT := $(CURDIR)/$(TARGET)
|
|||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile-prizm
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
$(BUILD):
|
||||
@mkdir $@
|
Binary file not shown.
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
@ -0,0 +1,5 @@
|
|||
../../src/models.h: models.blend export_models.py
|
||||
blender $(CURDIR)/models.blend -b -P $(CURDIR)/export_models.py
|
||||
|
||||
clean:
|
||||
rm -f ../../src/models.h
|
|
@ -0,0 +1,20 @@
|
|||
import bpy
|
||||
import os
|
||||
|
||||
file = open(os.path.dirname(__file__) + "/../../src/models.h", "w")
|
||||
file.truncate(0)
|
||||
for object in bpy.data.objects:
|
||||
if object.type == 'MESH':
|
||||
file.write("Triangle " + object.name + "_triangles[" + str(len(object.data.polygons)) + "] = {\n")
|
||||
for polygon in object.data.polygons:
|
||||
file.write("\t{\n")
|
||||
for vertex in polygon.vertices:
|
||||
v = object.data.vertices[vertex].co
|
||||
file.write("\t\t{{{:.3f}, {:.3f}, {:.3f}}},\n".format(v.x, -v.z, v.y))
|
||||
n = polygon.normal
|
||||
file.write("\t\t{{{:.3f}, {:.3f}, {:.3f}}},\n".format(n.x, -n.z, n.y))
|
||||
color = object.data.materials[polygon.material_index].node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value
|
||||
file.write("\t\tnewColor({:d}, {:d}, {:d})\n".format(int(color[0]*255), int(color[1]*255), int(color[2]*255)))
|
||||
file.write("\t},\n")
|
||||
file.write("};\n")
|
||||
file.close()
|
Binary file not shown.
|
@ -0,0 +1,36 @@
|
|||
CC = g++
|
||||
CFLAGS += -Wall -Wextra
|
||||
CFLAGS += -DSDL
|
||||
LIB += -lSDL2 -lSDL2_ttf
|
||||
LDFLAGS = $(LIB)
|
||||
INCLUDES =
|
||||
|
||||
SRCDIR = ../src
|
||||
|
||||
SOURCES = $(wildcard $(SRCDIR)/*.cpp)
|
||||
OBJECTS = $(patsubst $(SRCDIR)/%,%,$(SOURCES:.cpp=.o))
|
||||
DEPS = $(patsubst $(SRCDIR)/%,%,$(SOURCES:.cpp=.d))
|
||||
|
||||
TARGET = racing
|
||||
|
||||
all: debug
|
||||
|
||||
debug: CFLAGS += -Og -g
|
||||
debug: $(TARGET)
|
||||
|
||||
release: CFLAGS += -Ofast
|
||||
release: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
@echo "Linking..."
|
||||
$(CC) $^ -o $(TARGET) $(LIB)
|
||||
|
||||
%.o: $(SRCDIR)/%.cpp
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ -MMD $< -MF "$(patsubst $(SRCDIR)/%,%,$(<:.cpp=.d))"
|
||||
|
||||
clean:
|
||||
rm $(TARGET) $(OBJECTS) $(DEPS) -f
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
-include $(DEPS)
|
1522
src/main.cpp
1522
src/main.cpp
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue