From 2c8adb1aea0e5abbdbc31d88c19efc0aedb24ede Mon Sep 17 00:00:00 2001 From: historic_bruno Date: Sun, 29 Jul 2012 23:04:22 +0000 Subject: [PATCH] Adds support for Boost.Filesystem v3, the only option in Boost 1.50. Fixes #1527. Refs #1360 This was SVN commit r12229. --- build/premake/extern_libs4.lua | 9 +++++---- source/graphics/TextureManager.cpp | 4 ++-- source/lib/pch/pch_boost.h | 9 ++++++++- source/ps/Filesystem.cpp | 9 +++++++++ source/ps/Filesystem.h | 5 +++++ source/simulation2/components/ICmpAIManager.cpp | 4 ++-- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/build/premake/extern_libs4.lua b/build/premake/extern_libs4.lua index d1e2baaa25..1ce93d8fe4 100644 --- a/build/premake/extern_libs4.lua +++ b/build/premake/extern_libs4.lua @@ -214,11 +214,12 @@ extern_lib_defs = { if os.getversion().description == "OpenBSD" then includedirs { "/usr/local/include" } end - -- These are only needed for boost <= 1.43 add_default_links({ - android_names = { "boost_system-gcc-mt" }, - unix_names = { "boost_system-mt" }, - bsd_names = { "boost_system" }, + -- The following are not strictly link dependencies on all systems, but + -- are included for compatibility with different versions of Boost + android_names = { "boost_filesystem-gcc-mt", "boost_system-gcc-mt" }, + unix_names = { "boost_filesystem-mt", "boost_system-mt" }, + bsd_names = { "boost_filesystem", "boost_system" }, }) end, link_settings = function() diff --git a/source/graphics/TextureManager.cpp b/source/graphics/TextureManager.cpp index 68713cd700..67a1e9bf6b 100644 --- a/source/graphics/TextureManager.cpp +++ b/source/graphics/TextureManager.cpp @@ -425,9 +425,9 @@ public: CTextureConverter::SettingsFile* f = GetSettingsFile(settingsPath); if (f) files.push_back(f); - p = p / *it; + p = p / GetWstringFromWpath(*it); } - return m_TextureConverter.ComputeSettings(srcPath.leaf(), files); + return m_TextureConverter.ComputeSettings(GetWstringFromWpath(srcPath.leaf()), files); } /** diff --git a/source/lib/pch/pch_boost.h b/source/lib/pch/pch_boost.h index 38a966cc81..d6883b735f 100644 --- a/source/lib/pch/pch_boost.h +++ b/source/lib/pch/pch_boost.h @@ -25,9 +25,16 @@ // the following boost libraries have been included in TR1 and are // thus deemed usable: -#define BOOST_FILESYSTEM_VERSION 2 +#if BOOST_VERSION >= 104400 +// Filesystem v3 is included since Boost 1.44 +// v2 is deprecated since 1.46 and removed entirely in 1.50 +# define BOOST_FILESYSTEM_VERSION 3 +#else +# define BOOST_FILESYSTEM_VERSION 2 +#endif #include namespace fs = boost::filesystem; + #include // (these ones are used more rarely, so we don't enable them in minimal configurations) diff --git a/source/ps/Filesystem.cpp b/source/ps/Filesystem.cpp index 9f31af9417..06880494ff 100644 --- a/source/ps/Filesystem.cpp +++ b/source/ps/Filesystem.cpp @@ -95,6 +95,15 @@ Status ReloadChangedFiles() return INFO::OK; } +std::wstring GetWstringFromWpath(const fs::wpath& path) +{ +#if BOOST_FILESYSTEM_VERSION == 3 + return path.wstring(); +#else + return path.string(); +#endif +} + CVFSFile::CVFSFile() : m_BufferSize(0) diff --git a/source/ps/Filesystem.h b/source/ps/Filesystem.h index 340c5bac60..f5138f635f 100644 --- a/source/ps/Filesystem.h +++ b/source/ps/Filesystem.h @@ -54,6 +54,11 @@ void UnregisterFileReloadFunc(FileReloadFunc func, void* obj); **/ extern Status ReloadChangedFiles(); +/** + * Helper function to handle API differences between Boost Filesystem v2 and v3 + */ +std::wstring GetWstringFromWpath(const fs::wpath& path); + ERROR_GROUP(CVFSFile); ERROR_TYPE(CVFSFile, LoadFailed); ERROR_TYPE(CVFSFile, AlreadyLoaded); diff --git a/source/simulation2/components/ICmpAIManager.cpp b/source/simulation2/components/ICmpAIManager.cpp index fdd0a7c896..2e4d6db4a7 100644 --- a/source/simulation2/components/ICmpAIManager.cpp +++ b/source/simulation2/components/ICmpAIManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2012 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -53,7 +53,7 @@ public: fs::wpath components = pathname.string(); fs::wpath::iterator it = components.begin(); std::advance(it, 2); - std::wstring dirname = *it; + std::wstring dirname = GetWstringFromWpath(*it); CScriptValRooted ai; self->m_ScriptInterface.Eval("({})", ai);