From 7e8edd7c3eddfac9f5df16abf29f06bbaded49cf Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 13 Feb 2013 13:26:04 +0000 Subject: [PATCH] sys: add the base source directory to the list of search directories on automake platforms, too. --- configure.ac | 2 +- src/debug/fps.cpp | 4 ++-- src/lol/sys/init.h | 7 ++++++- src/sys/init.cpp | 32 ++++++++++++++++++++++++++++---- tutorial/11_fractal.cpp | 6 +++--- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index bd63f081..4b1997f5 100644 --- a/configure.ac +++ b/configure.ac @@ -378,7 +378,7 @@ LOL_DEPENDENCIES="${LOL_DEPENDENCIES} \$(top_builddir)/src/bullet/liblolbullet.a dnl How to use the Lol Engine inside this tree AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(top_srcdir)/src" -AM_CPPFLAGS="${AM_CPPFLAGS} -DLOL_SOURCE_SUBDIR=\\\"\$(subdir)\\\"" +AM_CPPFLAGS="${AM_CPPFLAGS} -DLOL_CONFIG_SOURCESUBDIR=\\\"\$(subdir)\\\"" AM_CPPFLAGS="${AM_CPPFLAGS} ${LOL_CFLAGS}" AM_LDFLAGS="${AM_LDFLAGS} ${LOL_DEPENDENCIES}" AM_LDFLAGS="${AM_LDFLAGS} ${LOL_LIBS}" diff --git a/src/debug/fps.cpp b/src/debug/fps.cpp index 4cb473c3..52b64f62 100644 --- a/src/debug/fps.cpp +++ b/src/debug/fps.cpp @@ -44,12 +44,12 @@ DebugFps::DebugFps(int x, int y) #if 0 for (int i = 0; i < 5; i ++) { - data->lines[i] = new Text(NULL, "src/data/font/ascii.png"); + data->lines[i] = new Text(NULL, "data/font/ascii.png"); data->lines[i]->SetPos(ivec3(x, y + (i ? 8 : 0) + 16 * i, 0)); Ticker::Ref(data->lines[i]); } #else - data->lines[0] = new Text(NULL, "src/data/font/ascii.png"); + data->lines[0] = new Text(NULL, "data/font/ascii.png"); data->lines[0]->SetPos(ivec3(x, y, 100)); Ticker::Ref(data->lines[0]); #endif diff --git a/src/lol/sys/init.h b/src/lol/sys/init.h index 3c2c459c..74a9fbca 100644 --- a/src/lol/sys/init.h +++ b/src/lol/sys/init.h @@ -34,6 +34,10 @@ namespace lol # define LOL_CONFIG_SOLUTIONDIR "" #endif +#if !defined LOL_CONFIG_SOURCESUBDIR +# define LOL_CONFIG_SOURCESUBDIR "" +#endif + /* * System namespace. The platform-specific stuff in there makes the API * not as clean as the rest of the framework. @@ -44,7 +48,8 @@ namespace System extern void Init(int argc, char *argv[], String const &projectdir = LOL_CONFIG_PROJECTDIR, - String const &solutiondir = LOL_CONFIG_SOLUTIONDIR); + String const &solutiondir = LOL_CONFIG_SOLUTIONDIR, + String const &sourcesubdir = LOL_CONFIG_SOURCESUBDIR); extern void AddDataDir(String const &dir); extern Array GetPathList(String const &file); diff --git a/src/sys/init.cpp b/src/sys/init.cpp index 416f689f..e62ac10d 100644 --- a/src/sys/init.cpp +++ b/src/sys/init.cpp @@ -38,7 +38,9 @@ namespace System static Array data_dir; void Init(int argc, char *argv[], - String const &projectdir, String const &solutiondir) + String const &projectdir, + String const &solutiondir, + String const &sourcesubdir) { using namespace std; @@ -76,10 +78,17 @@ void Init(int argc, char *argv[], * assume it was. */ if (i) { - String rootdir = projectdir; + String rootdir = solutiondir; if (rootdir.Last() != SEPARATOR) rootdir += SEPARATOR; + rootdir += "../../src/"; /* FIXME: use SEPARATOR? */ AddDataDir(rootdir); + + rootdir = projectdir; + if (rootdir.Last() != SEPARATOR) + rootdir += SEPARATOR; + AddDataDir(rootdir); + got_rootdir = true; } break; @@ -89,7 +98,22 @@ void Init(int argc, char *argv[], /* If no rootdir found, use the executable location */ if (!got_rootdir) { - AddDataDir(binarydir); + String rootdir = binarydir; + if (rootdir.Last() != SEPARATOR) + rootdir += SEPARATOR; + for (int i = 1; i < sourcesubdir.Count(); ++i) + { + if ((sourcesubdir[i] == SEPARATOR + && sourcesubdir[i - 1] != SEPARATOR) + || i == sourcesubdir.Count() - 1) + rootdir += "../"; + } + rootdir += "src/"; + AddDataDir(rootdir); + + rootdir = binarydir; + AddDataDir(rootdir); + got_rootdir = true; } @@ -113,7 +137,7 @@ Array GetPathList(String const &file) Array ret; for (int i = 0; i < data_dir.Count(); ++i) - ret << data_dir[0] + file; + ret << data_dir[i] + file; if (ret.Count() == 0) ret << file; diff --git a/tutorial/11_fractal.cpp b/tutorial/11_fractal.cpp index 311f6655..267a0c5c 100644 --- a/tutorial/11_fractal.cpp +++ b/tutorial/11_fractal.cpp @@ -104,15 +104,15 @@ public: } #if !defined __native_client__ - m_centertext = new Text(NULL, "src/data/font/ascii.png"); + m_centertext = new Text(NULL, "data/font/ascii.png"); m_centertext->SetPos(ivec3(5, m_window_size.y - 15, 1)); Ticker::Ref(m_centertext); - m_mousetext = new Text(NULL, "src/data/font/ascii.png"); + m_mousetext = new Text(NULL, "data/font/ascii.png"); m_mousetext->SetPos(ivec3(5, m_window_size.y - 29, 1)); Ticker::Ref(m_mousetext); - m_zoomtext = new Text(NULL, "src/data/font/ascii.png"); + m_zoomtext = new Text(NULL, "data/font/ascii.png"); m_zoomtext->SetPos(ivec3(5, m_window_size.y - 43, 1)); Ticker::Ref(m_zoomtext); #endif