aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvimene <vincent.menegaux@gmail.com>2026-02-16 11:45:19 +0100
committervimene <vincent.menegaux@gmail.com>2026-02-16 11:45:19 +0100
commit523b27e38c0978f6513c95f90582e7e5ab160e3d (patch)
treeface9fe3aee978a9d1b9d41d3a86d7e28ba4f242 /src
parent7536dd705d121ed3a49b7e4b05af88fd241d1674 (diff)
downloadengine-main.tar.gz
small improvementsHEADmain
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/engine.cpp2
-rw-r--r--src/path_utils.cpp19
-rw-r--r--src/path_utils.hpp8
-rw-r--r--src/spvshaders/Makefile.am4
5 files changed, 23 insertions, 13 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 00e76ac..1239928 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-include ../common.am
+include $(top_srcdir)/common.am
bin_PROGRAMS = engine
@@ -46,6 +46,7 @@ engine_CPPFLAGS = -std=gnu++23 -Wall -Wextra -I'$(srcdir)/src' \
-DBINDIR='"$(BINDIR_CXX)"' \
-DPKGDATADIR='"$(PKGDATADIR_CXX)"' \
-DSPVSHADERSDIR='"$(SPVSHADERSDIR_CXX)"' \
+ -DEXENAME='"engine$(EXEEXT)"' \
$(GLFW3_CFLAGS) $(VULKAN_CFLAGS)
if !DEBUG
engine_CPPFLAGS += -DNDEBUG
diff --git a/src/engine.cpp b/src/engine.cpp
index 1f57bd7..0876932 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -100,7 +100,7 @@ enum class GameType {
constexpr GameType game_type { GameType::test };
static void print_usage(std::ostream& output_stream) {
- output_stream << "Usage: ./engine [-htg] [--help] [--term] [--graphical]\n"
+ output_stream << "Usage: " EXENAME " [-htg] [--help] [--term] [--graphical]\n"
<< " -h, --help show usage (this)\n"
<< " -t, --term terminal mode\n"
<< " -g, --graphical graphical mode (default)\n"
diff --git a/src/path_utils.cpp b/src/path_utils.cpp
index 94bbba5..50c70cd 100644
--- a/src/path_utils.cpp
+++ b/src/path_utils.cpp
@@ -7,7 +7,7 @@
# include <tchar.h>
#endif
-std::optional<std::filesystem::path> engine::path_utils::exe_path() noexcept {
+std::optional<std::filesystem::path> engine::path_utils::exe() noexcept {
#if defined(_WIN32)
TCHAR filename[MAX_PATH];
if (!GetModuleFileName(NULL, filename, MAX_PATH))
@@ -21,14 +21,19 @@ std::optional<std::filesystem::path> engine::path_utils::exe_path() noexcept {
}
engine::path_utils::Paths::Paths() noexcept {
- const auto exe_path_opt = engine::path_utils::exe_path();
- if (!exe_path_opt) {
+ const auto exe_opt = engine::path_utils::exe();
+ if (!exe_opt) {
std::cerr << "cannot find path of executable" << std::endl;
exit(1);
}
- const auto files_root = (*exe_path_opt).parent_path();
+ m_exe = *exe_opt;
- m_assets_objs = files_root / std::filesystem::relative(PKGDATADIR "/assets/objs", BINDIR);
- m_assets_textures = files_root / std::filesystem::relative(PKGDATADIR "/assets/textures", BINDIR);
- m_spvshaders = files_root / std::filesystem::relative(SPVSHADERSDIR, BINDIR);
+ const auto files_root = m_exe.parent_path();
+ const auto bin = std::filesystem::weakly_canonical(BINDIR);
+ const std::filesystem::path pkgdata { PKGDATADIR };
+ const auto assets = pkgdata / "assets";
+
+ m_assets_objs = std::filesystem::canonical(files_root / std::filesystem::weakly_canonical(assets / "objs") .lexically_relative(bin));
+ m_assets_textures = std::filesystem::canonical(files_root / std::filesystem::weakly_canonical(assets / "textures").lexically_relative(bin));
+ m_spvshaders = std::filesystem::canonical(files_root / std::filesystem::weakly_canonical(SPVSHADERSDIR) .lexically_relative(bin));
}
diff --git a/src/path_utils.hpp b/src/path_utils.hpp
index 76567bc..2594206 100644
--- a/src/path_utils.hpp
+++ b/src/path_utils.hpp
@@ -6,12 +6,16 @@
namespace engine::path_utils {
-std::optional<std::filesystem::path> exe_path() noexcept;
+std::optional<std::filesystem::path> exe() noexcept;
class Paths {
public:
Paths() noexcept;
+ const std::filesystem::path& exe() const & noexcept {
+ return m_exe;
+ }
+
const std::filesystem::path& assets_objs() const & noexcept {
return m_assets_objs;
}
@@ -25,7 +29,7 @@ class Paths {
}
private:
- std::filesystem::path m_assets_objs, m_assets_textures, m_spvshaders;
+ std::filesystem::path m_exe, m_assets_objs, m_assets_textures, m_spvshaders;
};
}
diff --git a/src/spvshaders/Makefile.am b/src/spvshaders/Makefile.am
index 5a5a362..c707798 100644
--- a/src/spvshaders/Makefile.am
+++ b/src/spvshaders/Makefile.am
@@ -1,7 +1,7 @@
-include ../../common.am
+include $(top_srcdir)/common.am
spvshaders_DATA = shader.spv
-CLEANFILES = shader.spv
+CLEANFILES = $(spvshaders_DATA)
shader_spv_SLANGFLAGS = -target spirv -profile spirv_1_4 -emit-spirv-directly -fvk-use-entrypoint-name -entry vert_main -entry frag_main