diff --git a/0ad-cs7783.patch b/0ad-DllLoader.patch similarity index 50% rename from 0ad-cs7783.patch rename to 0ad-DllLoader.patch index 718dfac..9e5f6e5 100644 --- a/0ad-cs7783.patch +++ b/0ad-DllLoader.patch @@ -1,22 +1,46 @@ Index: source/ps/DllLoader.cpp =================================================================== ---- source/ps/DllLoader.cpp (revision 7782) -+++ source/ps/DllLoader.cpp (revision 7783) -@@ -27,12 +27,8 @@ +--- source/ps/DllLoader.cpp (revision 7732) ++++ source/ps/DllLoader.cpp (revision 7795) +@@ -1,4 +1,4 @@ +-/* Copyright (C) 2009 Wildfire Games. ++/* Copyright (C) 2010 Wildfire Games. + * This file is part of 0 A.D. + * + * 0 A.D. is free software: you can redistribute it and/or modify +@@ -19,19 +19,25 @@ + + #include "DllLoader.h" + ++#include "lib/timer.h" + #include "lib/posix/posix_dlfcn.h" + #include "ps/CStr.h" + #include "ps/CLogger.h" ++#include "ps/GameSetup/Config.h" + void* const HANDLE_UNAVAILABLE = (void*)-1; ++// directory to search for libraries (optionally set by --libdir at build-time, ++// optionally overridden by -libdir at run-time in the test executable); ++// if we don't have an explicit libdir then the linker will look in DT_RUNPATH ++// (which we set to $ORIGIN) to find it in the executable's directory ++#ifdef INSTALLED_LIBDIR ++static CStr g_Libdir = STRINGIZE(INSTALLED_LIBDIR); ++#else ++static CStr g_Libdir = ""; ++#endif -// TODO Use path_util instead, get the actual path to the ps_dbg exe and append -// the library name. - - // note: on Linux, lib is prepended to the SO file name; --// if we don't have an explicit libdir then we don't use --// a path with '/' so the linker will look in DT_RUNPATH -+// if we don't have an explicit libdir then the linker will look in DT_RUNPATH - // (which we set to $ORIGIN) to find it in the executable's directory +-// note: on Linux, lib is prepended to the SO file name; +-// we don't use a path with '/' so the linker will look in DT_RUNPATH +-// (which we set to $ORIGIN) to find it in the executable's directory ++// note: on Linux, lib is prepended to the SO file name #if OS_UNIX - #ifdef INSTALLED_LIBDIR -@@ -47,9 +43,11 @@ + static const char* prefix = "lib"; + #else +@@ -41,15 +47,26 @@ // but for debugging/performance we prefer to use the same version as the app. // note: on Windows, the extension is replaced with .dll by dlopen. #ifndef NDEBUG @@ -30,18 +54,34 @@ Index: source/ps/DllLoader.cpp #endif // (This class is currently only used by 'Collada' and 'AtlasUI' which follow -@@ -80,23 +78,37 @@ - { - TIMER(L"LoadDLL"); + // the naming/location convention above - it'll need to be changed if we want + // to support other DLLs.) ++static CStr GenerateFilename(const CStr& name, const CStr& suffix) ++{ ++ CStr n; ++ if (!g_Libdir.empty()) ++ n = g_Libdir + "/"; ++ n += prefix + name + suffix; ++ return n; ++} ++ + DllLoader::DllLoader(const char* name) + : m_Name(name), m_Handle(0) + { +@@ -72,23 +89,39 @@ + // postcondition: m_Handle valid or == HANDLE_UNAVAILABLE. + if (m_Handle == 0) + { - CStr filename = CStr(prefix) + m_Name + suffix; -- ++ TIMER(L"LoadDLL"); + // we don't really care when relocations take place, but one of // {RTLD_NOW, RTLD_LAZY} must be passed. go with the former because // it is safer and matches the Windows load behavior. const int flags = RTLD_LOCAL|RTLD_NOW; -+ CStr filename = CStr(prefix) + m_Name + primarySuffix; ++ CStr filename = GenerateFilename(m_Name, primarySuffix); m_Handle = dlopen(filename, flags); + char* primaryError = NULL; @@ -57,7 +97,7 @@ Index: source/ps/DllLoader.cpp + primaryError = strdup(primaryError); // don't get overwritten by next dlopen + + // Try to open the other debug/release version -+ filename = CStr(prefix) + m_Name + secondarySuffix; ++ filename = GenerateFilename(m_Name, secondarySuffix); + m_Handle = dlopen(filename, flags); + } + @@ -73,3 +113,12 @@ Index: source/ps/DllLoader.cpp } return (m_Handle != HANDLE_UNAVAILABLE); +@@ -117,3 +150,8 @@ + if (*fptr == NULL) + throw PSERROR_DllLoader_SymbolNotFound(); + } ++ ++void DllLoader::OverrideLibdir(const CStr& libdir) ++{ ++ g_Libdir = libdir; ++} diff --git a/0ad-cs7758.patch b/0ad-cs7758.patch index 2883076..a51e48c 100644 --- a/0ad-cs7758.patch +++ b/0ad-cs7758.patch @@ -77,42 +77,3 @@ Index: source/ps/GameSetup/Paths.cpp const wchar_t* subdirectoryName = args.Has("writableRoot")? 0 : L"0ad"; // everything is a subdirectory of the root -Index: source/ps/DllLoader.cpp -=================================================================== ---- source/ps/DllLoader.cpp (revision 7757) -+++ source/ps/DllLoader.cpp (revision 7758) -@@ -19,6 +19,7 @@ - - #include "DllLoader.h" - -+#include "lib/timer.h" - #include "lib/posix/posix_dlfcn.h" - #include "ps/CStr.h" - #include "ps/CLogger.h" -@@ -30,10 +31,15 @@ - // the library name. - - // note: on Linux, lib is prepended to the SO file name; --// we don't use a path with '/' so the linker will look in DT_RUNPATH -+// if we don't have an explicit libdir then we don't use -+// a path with '/' so the linker will look in DT_RUNPATH - // (which we set to $ORIGIN) to find it in the executable's directory - #if OS_UNIX --static const char* prefix = "lib"; -+ #ifdef INSTALLED_LIBDIR -+ static const char* prefix = STRINGIZE(INSTALLED_LIBDIR) "/lib"; -+ #else -+ static const char* prefix = "lib"; -+ #endif - #else - static const char* prefix = ""; - #endif -@@ -72,6 +78,8 @@ - // postcondition: m_Handle valid or == HANDLE_UNAVAILABLE. - if (m_Handle == 0) - { -+ TIMER(L"LoadDLL"); -+ - CStr filename = CStr(prefix) + m_Name + suffix; - - // we don't really care when relocations take place, but one of diff --git a/0ad-cs7795.patch b/0ad-cs7795.patch index 0b9ec58..2358677 100644 --- a/0ad-cs7795.patch +++ b/0ad-cs7795.patch @@ -14,90 +14,6 @@ Index: source/ps/DllLoader.h private: // Typeless version - the public LoadSymbol hides the slightly ugly // casting from users. -Index: source/ps/DllLoader.cpp -=================================================================== ---- source/ps/DllLoader.cpp (revision 7794) -+++ source/ps/DllLoader.cpp (revision 7795) -@@ -1,4 +1,4 @@ --/* Copyright (C) 2009 Wildfire Games. -+/* Copyright (C) 2010 Wildfire Games. - * This file is part of 0 A.D. - * - * 0 A.D. is free software: you can redistribute it and/or modify -@@ -23,19 +23,23 @@ - #include "lib/posix/posix_dlfcn.h" - #include "ps/CStr.h" - #include "ps/CLogger.h" -+#include "ps/GameSetup/Config.h" - - void* const HANDLE_UNAVAILABLE = (void*)-1; - -- --// note: on Linux, lib is prepended to the SO file name; -+// directory to search for libraries (optionally set by --libdir at build-time, -+// optionally overridden by -libdir at run-time in the test executable); - // if we don't have an explicit libdir then the linker will look in DT_RUNPATH - // (which we set to $ORIGIN) to find it in the executable's directory -+#ifdef INSTALLED_LIBDIR -+static CStr g_Libdir = STRINGIZE(INSTALLED_LIBDIR); -+#else -+static CStr g_Libdir = ""; -+#endif -+ -+// note: on Linux, lib is prepended to the SO file name - #if OS_UNIX -- #ifdef INSTALLED_LIBDIR -- static const char* prefix = STRINGIZE(INSTALLED_LIBDIR) "/lib"; -- #else -- static const char* prefix = "lib"; -- #endif -+static const char* prefix = "lib"; - #else - static const char* prefix = ""; - #endif -@@ -54,6 +58,15 @@ - // the naming/location convention above - it'll need to be changed if we want - // to support other DLLs.) - -+static CStr GenerateFilename(const CStr& name, const CStr& suffix) -+{ -+ CStr n; -+ if (!g_Libdir.empty()) -+ n = g_Libdir + "/"; -+ n += prefix + name + suffix; -+ return n; -+} -+ - DllLoader::DllLoader(const char* name) - : m_Name(name), m_Handle(0) - { -@@ -83,7 +96,7 @@ - // it is safer and matches the Windows load behavior. - const int flags = RTLD_LOCAL|RTLD_NOW; - -- CStr filename = CStr(prefix) + m_Name + primarySuffix; -+ CStr filename = GenerateFilename(m_Name, primarySuffix); - m_Handle = dlopen(filename, flags); - - char* primaryError = NULL; -@@ -96,7 +109,7 @@ - primaryError = strdup(primaryError); // don't get overwritten by next dlopen - - // Try to open the other debug/release version -- filename = CStr(prefix) + m_Name + secondarySuffix; -+ filename = GenerateFilename(m_Name, secondarySuffix); - m_Handle = dlopen(filename, flags); - } - -@@ -137,3 +150,8 @@ - if (*fptr == NULL) - throw PSERROR_DllLoader_SymbolNotFound(); - } -+ -+void DllLoader::OverrideLibdir(const CStr& libdir) -+{ -+ g_Libdir = libdir; -+} Index: libraries/cxxtest/include/cxxtest/PsTestWrapper.h =================================================================== --- libraries/cxxtest/include/cxxtest/PsTestWrapper.h (revision 7794) diff --git a/0ad-cs7796.patch b/0ad-cs7796.patch new file mode 100644 index 0000000..87a0ad4 --- /dev/null +++ b/0ad-cs7796.patch @@ -0,0 +1,17 @@ +Index: source/lib/sysdep/tests/test_sysdep.h +=================================================================== +--- source/lib/sysdep/tests/test_sysdep.h (revision 7795) ++++ source/lib/sysdep/tests/test_sysdep.h (revision 7796) +@@ -120,7 +120,11 @@ + char root[PATH_MAX]; + sprintf_s(root, ARRAY_SIZE(root), "%s/pyrogenesis-test-sysdep-XXXXXX", tmpdir); + TS_ASSERT(mkdtemp(root)); +- std::string rootstr(root); ++ ++ char rootres[PATH_MAX]; ++ TS_ASSERT(realpath(root, rootres)); ++ ++ std::string rootstr(rootres); + std::wstring rootstrw(wstring_from_utf8(rootstr)); + + const char* dirs[] = { diff --git a/0ad.spec b/0ad.spec index 151b16a..605cc5d 100644 --- a/0ad.spec +++ b/0ad.spec @@ -11,10 +11,11 @@ Patch0: 0ad-cs7755.patch Patch1: 0ad-cs7757.patch Patch2: 0ad-cs7758.patch Patch3: 0ad-cs7759.patch -Patch4: 0ad-cs7783.patch -Patch5: 0ad-cs7791.patch -Patch6: 0ad-cs7793.patch -Patch7: 0ad-cs7795.patch +Patch4: 0ad-cs7791.patch +Patch5: 0ad-cs7793.patch +Patch6: 0ad-cs7795.patch +Patch7: 0ad-cs7796.patch +Patch8: 0ad-DllLoader.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: binutils-devel BuildRequires: boost-devel @@ -101,6 +102,7 @@ history. %patch5 %patch6 %patch7 +%patch8 %build export CFLAGS="%{optflags}" diff --git a/debian.series b/debian.series index 3de9892..8368b01 100644 --- a/debian.series +++ b/debian.series @@ -2,7 +2,8 @@ 0ad-cs7757.patch -p0 0ad-cs7758.patch -p0 0ad-cs7759.patch -p0 -0ad-cs7783.patch -p0 0ad-cs7791.patch -p0 0ad-cs7793.patch -p0 0ad-cs7795.patch -p0 +0ad-cs7796.patch -p0 +0ad-DllLoader.patch -p0