mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Remove InitialiseLocale()
Setting the global locale is no longer needed, as Boost.Filesystem and Boost.Locale are no longer used. All Boost dependencies are now header-only. Install language packs on Travis to ensure that the Turkish and Greek locales exist for testing. Now that only header-only Boost libraries are used, just download and extract the Boost archive on Travis. change boost url
This commit is contained in:
+5
-7
@@ -12,20 +12,18 @@ addons:
|
||||
- libhttp-parser-dev
|
||||
- libssh2-1-dev
|
||||
- libicu-dev
|
||||
- language-pack-el
|
||||
- language-pack-tr
|
||||
- gcc-8
|
||||
- g++-8
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/boost_1_67_0/boost
|
||||
- $HOME/boost_1_67_0/stage/64/lib
|
||||
cargo: true
|
||||
|
||||
install:
|
||||
- export CXX="g++-8" CC="gcc-8"
|
||||
# Build Boost.
|
||||
- wget https://raw.githubusercontent.com/Ortham/ci-scripts/2.1.2/install_boost.py
|
||||
- python3 install_boost.py --directory ~ --boost-version 1.67.0 -a 64 -t gcc-8 locale system
|
||||
# Get Boost.
|
||||
- curl -fsSL 'https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2' | tar -xj -C "$HOME"
|
||||
# Install packages for generating documentation
|
||||
- pyenv install 3.6.3
|
||||
- pyenv global 3.6.3
|
||||
@@ -43,7 +41,7 @@ before_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
# Link dynamically to the C++ standard library runtime.
|
||||
- cmake .. -DBOOST_ROOT=~/boost_1_67_0 -DBOOST_LIBRARYDIR=~/boost_1_67_0/stage/64/lib
|
||||
- cmake .. -DBOOST_ROOT=~/boost_1_67_0
|
||||
|
||||
script:
|
||||
- make all
|
||||
|
||||
+3
-3
@@ -63,7 +63,7 @@ ELSE ()
|
||||
set(RUST_TARGET x86_64-unknown-linux-gnu)
|
||||
ENDIF ()
|
||||
|
||||
find_package(Boost REQUIRED COMPONENTS locale system)
|
||||
find_package(Boost REQUIRED)
|
||||
|
||||
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
find_package(ICU REQUIRED COMPONENTS uc)
|
||||
@@ -396,12 +396,12 @@ ENDIF ()
|
||||
# Build tests.
|
||||
add_executable (libloot_internals_tests ${LIBLOOT_SRC} ${LIBLOOT_HEADERS} ${LOOT_TESTS_SRC} ${LOOT_TESTS_HEADERS})
|
||||
add_dependencies (libloot_internals_tests esplugin libgit2 libloadorder loot-condition-interpreter spdlog yaml-cpp GTest testing-metadata testing-plugins)
|
||||
target_link_libraries(libloot_internals_tests ${Boost_LIBRARIES} ${LIBGIT2_LIBRARIES} ${ESPLUGIN_LIBRARIES} ${LIBLOADORDER_LIBRARIES} ${LOOT_LIBS} ${LCI_LIBRARIES} ${YAML_CPP_LIBRARIES} ${GTEST_LIBRARIES} ${ICU_LIBRARIES})
|
||||
target_link_libraries(libloot_internals_tests ${LIBGIT2_LIBRARIES} ${ESPLUGIN_LIBRARIES} ${LIBLOADORDER_LIBRARIES} ${LOOT_LIBS} ${LCI_LIBRARIES} ${YAML_CPP_LIBRARIES} ${GTEST_LIBRARIES} ${ICU_LIBRARIES})
|
||||
|
||||
# Build API.
|
||||
add_library (loot ${LIBLOOT_SRC} ${LIBLOOT_HEADERS})
|
||||
add_dependencies (loot esplugin libgit2 libloadorder loot-condition-interpreter spdlog yaml-cpp)
|
||||
target_link_libraries(loot ${Boost_LIBRARIES} ${LIBGIT2_LIBRARIES} ${ESPLUGIN_LIBRARIES} ${LIBLOADORDER_LIBRARIES} ${LOOT_LIBS} ${LCI_LIBRARIES} ${YAML_CPP_LIBRARIES} ${ICU_LIBRARIES})
|
||||
target_link_libraries(loot ${LIBGIT2_LIBRARIES} ${ESPLUGIN_LIBRARIES} ${LIBLOADORDER_LIBRARIES} ${LOOT_LIBS} ${LCI_LIBRARIES} ${YAML_CPP_LIBRARIES} ${ICU_LIBRARIES})
|
||||
|
||||
# Build API tests.
|
||||
add_executable (libloot_tests ${LIBLOOT_TESTS_SRC} ${LIBLOOT_TESTS_HEADERS})
|
||||
|
||||
@@ -31,8 +31,6 @@ Functions
|
||||
|
||||
.. doxygenfunction:: loot::IsCompatible
|
||||
|
||||
.. doxygenfunction:: loot::InitialiseLocale
|
||||
|
||||
.. doxygenfunction:: loot::CreateGameHandle
|
||||
|
||||
Interfaces
|
||||
|
||||
@@ -96,16 +96,6 @@ LOOT_API bool IsCompatible(const unsigned int major,
|
||||
*************************************************************************/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Initialise the current global locale using the given ID.
|
||||
*
|
||||
* This sets the global locale up so that the library's UTF-8 support can
|
||||
* function.
|
||||
* @param id A locale ID. The default value is a blank string, which will
|
||||
* use the system default locale.
|
||||
*/
|
||||
LOOT_API void InitialiseLocale(const std::string& id = "");
|
||||
|
||||
/**
|
||||
* @brief Initialise a new game handle.
|
||||
* @details Creates a handle for a game, which is then used by all
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
#include "api/game/game.h"
|
||||
#include "api/helpers/logging.h"
|
||||
|
||||
@@ -74,10 +72,6 @@ LOOT_API bool IsCompatible(const unsigned int versionMajor,
|
||||
return versionMinor == loot::LootVersion::minor;
|
||||
}
|
||||
|
||||
LOOT_API void InitialiseLocale(const std::string& id) {
|
||||
std::locale::global(boost::locale::generator().generate(id));
|
||||
}
|
||||
|
||||
LOOT_API std::shared_ptr<GameInterface> CreateGameHandle(
|
||||
const GameType game,
|
||||
const std::filesystem::path& gamePath,
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
#include "api/helpers/text.h"
|
||||
|
||||
using std::lock_guard;
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
#include "loot/metadata/file.h"
|
||||
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
#include "api/metadata/yaml/file.h"
|
||||
#include "api/helpers/text.h"
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <regex>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
#include "api/game/game.h"
|
||||
#include "api/helpers/logging.h"
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <filesystem>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
#include "api/game/game.h"
|
||||
#include "api/helpers/crc.h"
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <boost/graph/breadth_first_search.hpp>
|
||||
#include <boost/graph/iteration_macros.hpp>
|
||||
#include <boost/graph/topological_sort.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
#include "api/game/game.h"
|
||||
#include "api/helpers/logging.h"
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "plugin_sorting_data.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
#include <loot/metadata/group.h>
|
||||
#include "api/helpers/text.h"
|
||||
|
||||
@@ -30,13 +30,7 @@
|
||||
#include "tests/api/interface/game_interface_test.h"
|
||||
#include "tests/api/interface/is_compatible_test.h"
|
||||
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Set the locale to get encoding conversions working correctly.
|
||||
std::locale::global(boost::locale::generator().generate(""));
|
||||
loot::InitialiseLocale("");
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -203,6 +203,15 @@ TEST(ExtractVersion, shouldExtractSingleDigitAfterVersionColonSpace) {
|
||||
TEST(CompareFilenames, shouldBeCaseInsensitiveAndLocaleInvariant) {
|
||||
// ICU sees all three greek rhos as case-insensitively equal, unlike Windows.
|
||||
// A small enough deviation that it should hopefully be insignificant.
|
||||
#ifdef _WIN32
|
||||
const char * turkishLocale = "tr-TR";
|
||||
const char * greekLocale = "el-GR";
|
||||
const int expectedRhoSymbolOrder = 1;
|
||||
#else
|
||||
const char * turkishLocale = "tr_TR.UTF-8";
|
||||
const char * greekLocale = "el_GR.UTF-8";
|
||||
const int expectedRhoSymbolOrder = 0;
|
||||
#endif
|
||||
|
||||
EXPECT_EQ(0, CompareFilenames("i", "I"));
|
||||
EXPECT_EQ(-1, CompareFilenames("i", u8"\u0130"));
|
||||
@@ -210,17 +219,12 @@ TEST(CompareFilenames, shouldBeCaseInsensitiveAndLocaleInvariant) {
|
||||
EXPECT_EQ(-1, CompareFilenames("I", u8"\u0130"));
|
||||
EXPECT_EQ(-1, CompareFilenames("I", u8"\u0131"));
|
||||
EXPECT_EQ(-1, CompareFilenames(u8"\u0130", u8"\u0131"));
|
||||
#ifdef _WIN32
|
||||
EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03a1"));
|
||||
EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03c1"));
|
||||
#else
|
||||
EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03a1"));
|
||||
EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03c1"));
|
||||
#endif
|
||||
EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03a1"));
|
||||
EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03c1"));
|
||||
EXPECT_EQ(0, CompareFilenames(u8"\u03a1", u8"\u03c1"));
|
||||
|
||||
// Set locale to Turkish.
|
||||
std::locale::global(boost::locale::generator().generate("tr_TR.UTF-8"));
|
||||
std::locale::global(std::locale(turkishLocale));
|
||||
|
||||
EXPECT_EQ(0, CompareFilenames("i", "I"));
|
||||
EXPECT_EQ(-1, CompareFilenames("i", u8"\u0130"));
|
||||
@@ -228,17 +232,12 @@ TEST(CompareFilenames, shouldBeCaseInsensitiveAndLocaleInvariant) {
|
||||
EXPECT_EQ(-1, CompareFilenames("I", u8"\u0130"));
|
||||
EXPECT_EQ(-1, CompareFilenames("I", u8"\u0131"));
|
||||
EXPECT_EQ(-1, CompareFilenames(u8"\u0130", u8"\u0131"));
|
||||
#ifdef _WIN32
|
||||
EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03a1"));
|
||||
EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03c1"));
|
||||
#else
|
||||
EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03a1"));
|
||||
EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03c1"));
|
||||
#endif
|
||||
EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03a1"));
|
||||
EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03c1"));
|
||||
EXPECT_EQ(0, CompareFilenames(u8"\u03a1", u8"\u03c1"));
|
||||
|
||||
// Set locale to Greek.
|
||||
std::locale::global(boost::locale::generator().generate("el_GR.UTF-8"));
|
||||
std::locale::global(std::locale(greekLocale));
|
||||
|
||||
EXPECT_EQ(0, CompareFilenames("i", "I"));
|
||||
EXPECT_EQ(-1, CompareFilenames("i", u8"\u0130"));
|
||||
@@ -246,17 +245,12 @@ TEST(CompareFilenames, shouldBeCaseInsensitiveAndLocaleInvariant) {
|
||||
EXPECT_EQ(-1, CompareFilenames("I", u8"\u0130"));
|
||||
EXPECT_EQ(-1, CompareFilenames("I", u8"\u0131"));
|
||||
EXPECT_EQ(-1, CompareFilenames(u8"\u0130", u8"\u0131"));
|
||||
#ifdef _WIN32
|
||||
EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03a1"));
|
||||
EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03c1"));
|
||||
#else
|
||||
EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03a1"));
|
||||
EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03c1"));
|
||||
#endif
|
||||
EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03a1"));
|
||||
EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03c1"));
|
||||
EXPECT_EQ(0, CompareFilenames(u8"\u03a1", u8"\u03c1"));
|
||||
|
||||
// Reset locale.
|
||||
std::locale::global(boost::locale::generator().generate(""));
|
||||
std::locale::global(std::locale::classic());
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -270,7 +264,7 @@ TEST(NormalizeFilename, shouldUppercaseStringsAndBeLocaleInvariant) {
|
||||
EXPECT_EQ(u8"\u03a1", NormalizeFilename(u8"\u03c1"));
|
||||
|
||||
// Set locale to Turkish.
|
||||
std::locale::global(boost::locale::generator().generate("tr_TR.UTF-8"));
|
||||
std::locale::global(std::locale("tr-TR"));
|
||||
|
||||
EXPECT_EQ("I", NormalizeFilename("i"));
|
||||
EXPECT_EQ("I", NormalizeFilename("I"));
|
||||
@@ -281,7 +275,7 @@ TEST(NormalizeFilename, shouldUppercaseStringsAndBeLocaleInvariant) {
|
||||
EXPECT_EQ(u8"\u03a1", NormalizeFilename(u8"\u03c1"));
|
||||
|
||||
// Set locale to Greek.
|
||||
std::locale::global(boost::locale::generator().generate("el_GR.UTF-8"));
|
||||
std::locale::global(std::locale("el-GR"));
|
||||
|
||||
EXPECT_EQ("I", NormalizeFilename("i"));
|
||||
EXPECT_EQ("I", NormalizeFilename("I"));
|
||||
@@ -292,7 +286,7 @@ TEST(NormalizeFilename, shouldUppercaseStringsAndBeLocaleInvariant) {
|
||||
EXPECT_EQ(u8"\u03a1", NormalizeFilename(u8"\u03c1"));
|
||||
|
||||
// Reset locale.
|
||||
std::locale::global(boost::locale::generator().generate(""));
|
||||
std::locale::global(std::locale::classic());
|
||||
}
|
||||
#else
|
||||
TEST(NormalizeFilename, shouldCaseFoldStringsAndBeLocaleInvariant) {
|
||||
@@ -310,7 +304,7 @@ TEST(NormalizeFilename, shouldCaseFoldStringsAndBeLocaleInvariant) {
|
||||
EXPECT_EQ(u8"\u03c1", NormalizeFilename(u8"\u03c1"));
|
||||
|
||||
// Set locale to Turkish.
|
||||
std::locale::global(boost::locale::generator().generate("tr_TR.UTF-8"));
|
||||
std::locale::global(std::locale("tr_TR.UTF-8"));
|
||||
|
||||
EXPECT_EQ("i", NormalizeFilename("i"));
|
||||
EXPECT_EQ("i", NormalizeFilename("I"));
|
||||
@@ -321,7 +315,7 @@ TEST(NormalizeFilename, shouldCaseFoldStringsAndBeLocaleInvariant) {
|
||||
EXPECT_EQ(u8"\u03c1", NormalizeFilename(u8"\u03c1"));
|
||||
|
||||
// Set locale to Greek.
|
||||
std::locale::global(boost::locale::generator().generate("el_GR.UTF-8"));
|
||||
std::locale::global(std::locale("el_GR.UTF-8"));
|
||||
|
||||
EXPECT_EQ("i", NormalizeFilename("i"));
|
||||
EXPECT_EQ("i", NormalizeFilename("I"));
|
||||
@@ -332,7 +326,7 @@ TEST(NormalizeFilename, shouldCaseFoldStringsAndBeLocaleInvariant) {
|
||||
EXPECT_EQ(u8"\u03c1", NormalizeFilename(u8"\u03c1"));
|
||||
|
||||
// Reset locale.
|
||||
std::locale::global(boost::locale::generator().generate(""));
|
||||
std::locale::global(std::locale::classic());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
<https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
#include "tests/api/internals/game/game_cache_test.h"
|
||||
#include "tests/api/internals/game/game_test.h"
|
||||
#include "tests/api/internals/game/load_order_handler_test.h"
|
||||
@@ -276,9 +274,6 @@ TEST(Filesystem, canonicalShouldNotFoldCase) {
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Set the locale to get encoding conversions working correctly.
|
||||
std::locale::global(boost::locale::generator().generate(""));
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user