Skip to content

Commit

Permalink
Tmp
Browse files Browse the repository at this point in the history
Signed-off-by: Osyotr <[email protected]>
  • Loading branch information
Osyotr committed Oct 31, 2024
1 parent eba763b commit a848d5d
Show file tree
Hide file tree
Showing 31 changed files with 213 additions and 724 deletions.
7 changes: 6 additions & 1 deletion 3party/vulkan_wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ target_include_directories(${PROJECT_NAME} PUBLIC .)


# dlopen
target_link_libraries(${PROJECT_NAME} $<$<BOOL:CMAKE_DL_LIBS>:${CMAKE_DL_LIBS}>)
if(WIN32)
find_package(dlfcn-win32 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} dlfcn-win32::dl)
else()
target_link_libraries(${PROJECT_NAME} $<$<BOOL:CMAKE_DL_LIBS>:${CMAKE_DL_LIBS}>)
endif()
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"VCPKG_INSTALL_OPTIONS": {
"type": "STRING",
"value": "--disable-metrics;--no-print-usage;--x-abi-tools-use-exact-versions;--clean-buildtrees-after-build;--clean-packages-after-build;--x-buildtrees-root=${sourceDir}/out/btrees"
"value": "--disable-metrics;--no-print-usage;--x-abi-tools-use-exact-versions;--clean-buildtrees-after-build;--clean-packages-after-build"
}
},
"condition": {
Expand Down
6 changes: 1 addition & 5 deletions base/file_name_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ string GetDirectory(string const & name)

string::value_type GetNativeSeparator()
{
#ifdef OMIM_OS_WINDOWS
return '\\';
#else
return '/';
#endif
return '/';
}

string AddSlashIfNeeded(string const & path)
Expand Down
14 changes: 6 additions & 8 deletions base/string_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,37 +362,35 @@ UniChar LastUniChar(std::string const & s);
//@{
namespace internal
{
template <typename T, typename = std::enable_if_t<std::is_signed<T>::value &&
sizeof(T) < sizeof(long long)>>
template <typename T, std::enable_if_t<std::is_signed_v<T> && (sizeof(T) < sizeof(long)), int> = 0>
long IntConverter(char const * start, char ** stop, int base)
{
return std::strtol(start, stop, base);
}

template <typename T, typename = std::enable_if_t<std::is_unsigned<T>::value &&
sizeof(T) < sizeof(unsigned long long)>>
template <typename T, std::enable_if_t<std::is_unsigned_v<T> && (sizeof(T) < sizeof(unsigned long)), int> = 0>
unsigned long IntConverter(char const * start, char ** stop, int base)
{
return std::strtoul(start, stop, base);
}

template <typename T, typename = std::enable_if_t<std::is_signed<T>::value &&
sizeof(T) == sizeof(long long)>>
sizeof(T) >= sizeof(long)>>
long long IntConverter(char const * start, char ** stop, int base)
{
#ifdef OMIM_OS_WINDOWS_NATIVE
return _strtoi64(start, &stop, base);
return _strtoi64(start, stop, base);
#else
return std::strtoll(start, stop, base);
#endif
}

template <typename T, typename = std::enable_if_t<std::is_unsigned<T>::value &&
sizeof(T) == sizeof(unsigned long long)>>
sizeof(T) >= sizeof(unsigned long)>>
unsigned long long IntConverter(char const * start, char ** stop, int base)
{
#ifdef OMIM_OS_WINDOWS_NATIVE
return _strtoui64(start, &stop, base);
return _strtoui64(start, stop, base);
#else
return std::strtoull(start, stop, base);
#endif
Expand Down
1 change: 0 additions & 1 deletion cmake/OmimConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ set(OMIM_WARNING_FLAGS
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-unused-parameter> # We have a lot of functions with unused parameters
)
set(3PARTY_INCLUDE_DIRS "${OMIM_ROOT}/3party/boost")
set(OMIM_DATA_DIR "${OMIM_ROOT}/data")
set(OMIM_USER_RESOURCES_DIR "${OMIM_ROOT}/data")
2 changes: 0 additions & 2 deletions cmake/OmimHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ function(omim_add_executable executable)

# Enable warnings for all our binaries.
target_compile_options(${executable} PRIVATE ${OMIM_WARNING_FLAGS})
target_include_directories(${executable} SYSTEM PRIVATE ${3PARTY_INCLUDE_DIRS})
target_compile_definitions(${executable} PRIVATE $<$<BOOL:${PLATFORM_WIN}>:BOOST_ALL_NO_LIB>)
if (USE_ASAN)
target_link_libraries(${executable}
Expand Down Expand Up @@ -53,7 +52,6 @@ function(omim_add_library library)

# Enable warnings for all our libraries.
target_compile_options(${library} PRIVATE ${OMIM_WARNING_FLAGS})
target_include_directories(${library} SYSTEM PRIVATE ${3PARTY_INCLUDE_DIRS})
target_compile_definitions(${library} PRIVATE $<$<BOOL:${PLATFORM_WIN}>:BOOST_ALL_NO_LIB>)
if (USE_PPROF AND PLATFORM_MAC)
find_path(PPROF_INCLUDE_DIR NAMES gperftools/profiler.h)
Expand Down
4 changes: 2 additions & 2 deletions cmake/OmimTesting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ endif()
# TestServer fixture configuration
add_test(
NAME OmimStartTestServer
COMMAND start_server.py
COMMAND Python3::Interpreter start_server.py
WORKING_DIRECTORY ${OMIM_ROOT}/tools/python/test_server
)
add_test(
NAME OmimStopTestServer
COMMAND stop_server.py
COMMAND Python3::Interpreter stop_server.py
WORKING_DIRECTORY ${OMIM_ROOT}/tools/python/test_server
)
set_tests_properties(OmimStartTestServer PROPERTIES FIXTURES_SETUP TestServer)
Expand Down
18 changes: 10 additions & 8 deletions coding/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,16 @@ set(SRC
omim_add_library(${PROJECT_NAME} ${SRC})

target_link_libraries(${PROJECT_NAME}
base
expat::expat
cppjansson
succinct
ICU::uc
ICU::i18n # For transliteration.
minizip
ZLIB::ZLIB
PUBLIC
base
PRIVATE
expat::expat
cppjansson
succinct
ICU::uc
ICU::i18n # For transliteration.
minizip
ZLIB::ZLIB
)

omim_add_test_subdirectory(coding_tests)
17 changes: 10 additions & 7 deletions coding/internal/file_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
#include <cerrno>
#include <cstring>
#include <exception>
#include <filesystem>
#include <fstream>
#include <vector>

#ifdef OMIM_OS_WINDOWS
#include <io.h>
#include <windows.h>
#else
#include <unistd.h> // ftruncate
#endif
Expand Down Expand Up @@ -212,8 +214,9 @@ bool DeleteFileX(string const & fName)

bool RenameFileX(string const & fOld, string const & fNew)
{
int res = rename(fOld.c_str(), fNew.c_str());
return CheckFileOperationResult(res, fOld);
std::error_code ec;
std::filesystem::rename(fOld, fNew, ec);
return CheckFileOperationResult(ec.value(), fOld);
}

bool MoveFileX(string const & fOld, string const & fNew)
Expand Down Expand Up @@ -270,13 +273,13 @@ void AppendFileToFile(string const & fromFilename, string const & toFilename)

bool CopyFileX(string const & fOld, string const & fNew)
{
ifstream ifs;
ofstream ofs;
ifs.exceptions(ifstream::failbit | ifstream::badbit);
ofs.exceptions(ifstream::failbit | ifstream::badbit);

try
{
ifstream ifs;
ofstream ofs;
ifs.exceptions(ifstream::failbit | ifstream::badbit);
ofs.exceptions(ifstream::failbit | ifstream::badbit);

ifs.open(fOld.c_str());
ofs.open(fNew.c_str());

Expand Down
6 changes: 3 additions & 3 deletions drape/drape_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ target_compile_definitions(${PROJECT_NAME}

if (WITH_SYSTEM_PROVIDED_3PARTY)
find_package(GTest REQUIRED)
target_link_libraries(${PROJECT_NAME} GTest::gtest)
else()
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../../3party/googletest" "${CMAKE_CURRENT_BINARY_DIR}/googletest")
target_include_directories(${PROJECT_NAME} PUBLIC ${OMIM_ROOT}/3party/glm)
endif()

target_include_directories(${PROJECT_NAME} PUBLIC ${OMIM_ROOT}/3party/glm)

target_link_libraries(${PROJECT_NAME}
qt_tstfrm
GTest::gmock
${DRAPE_LINK_LIBRARIES}
GTest::gmock
)
34 changes: 20 additions & 14 deletions drape/gl_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ typedef void(DP_APIENTRY * TglClearFn)(GLbitfield mask);
typedef void(DP_APIENTRY * TglViewportFn)(GLint x, GLint y, GLsizei w, GLsizei h);
typedef void(DP_APIENTRY * TglScissorFn)(GLint x, GLint y, GLsizei w, GLsizei h);
typedef void(DP_APIENTRY * TglFlushFn)();
typedef void(DP_APIENTRY * TglStencilOpSeparateFn)(GLenum face, GLenum func, GLenum ref, GLenum mask);
typedef void(DP_APIENTRY * TglStencilFuncSeparateFn)(GLenum face, GLenum sfail, GLint dpfail, GLuint dppass);

typedef void(DP_APIENTRY * TglActiveTextureFn)(GLenum texture);
typedef void(DP_APIENTRY * TglBlendEquationFn)(GLenum mode);
Expand Down Expand Up @@ -79,7 +81,7 @@ typedef void(DP_APIENTRY * TglFlushMappedBufferRangeFn)(GLenum target, GLintptr

typedef GLuint(DP_APIENTRY * TglCreateShaderFn)(GLenum type);
typedef void(DP_APIENTRY * TglShaderSourceFn)(GLuint shaderID, GLsizei count,
GLchar const ** string, GLint const * length);
GLchar const * const * string, GLint const * length);
typedef void(DP_APIENTRY * TglCompileShaderFn)(GLuint shaderID);
typedef void(DP_APIENTRY * TglDeleteShaderFn)(GLuint shaderID);
typedef void(DP_APIENTRY * TglGetShaderivFn)(GLuint shaderID, GLenum name, GLint * p);
Expand Down Expand Up @@ -138,6 +140,9 @@ TglViewportFn glViewportFn = nullptr;
TglScissorFn glScissorFn = nullptr;
TglFlushFn glFlushFn = nullptr;

TglStencilOpSeparateFn glStencilOpSeparateFn = nullptr;
TglStencilFuncSeparateFn glStencilFuncSeparateFn = nullptr;

TglActiveTextureFn glActiveTextureFn = nullptr;
TglBlendEquationFn glBlendEquationFn = nullptr;

Expand Down Expand Up @@ -228,6 +233,7 @@ TFunc LoadExtension(std::string const & ext)
return func;
}
#define LOAD_GL_FUNC(type, func) LoadExtension<type>(#func);
#define LOAD_GL_FUNC_SIMPLE(type, func) static_cast<type>(&::func)
#else
#define LOAD_GL_FUNC(type, func) static_cast<type>(&::func)
#endif
Expand Down Expand Up @@ -314,13 +320,19 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
}
glMapBufferFn = LOAD_GL_FUNC(TglMapBufferFn, glMapBuffer);
glUnmapBufferFn = LOAD_GL_FUNC(TglUnmapBufferFn, glUnmapBuffer);
glMapBufferRangeFn = LOAD_GL_FUNC(TglMapBufferRangeFn, glMapBufferRange);
glFlushMappedBufferRangeFn = LOAD_GL_FUNC(TglFlushMappedBufferRangeFn, glFlushMappedBufferRange);
glGetStringiFn = LOAD_GL_FUNC(TglGetStringiFn, glGetStringi);
#endif

glClearColorFn = LOAD_GL_FUNC(TglClearColorFn, glClearColor);
glClearFn = LOAD_GL_FUNC(TglClearFn, glClear);
glViewportFn = LOAD_GL_FUNC(TglViewportFn, glViewport);
glScissorFn = LOAD_GL_FUNC(TglScissorFn, glScissor);
glFlushFn = LOAD_GL_FUNC(TglFlushFn, glFlush);
glClearColorFn = LOAD_GL_FUNC_SIMPLE(TglClearColorFn, glClearColor);
glClearFn = LOAD_GL_FUNC_SIMPLE(TglClearFn, glClear);
glViewportFn = LOAD_GL_FUNC_SIMPLE(TglViewportFn, glViewport);
glScissorFn = LOAD_GL_FUNC_SIMPLE(TglScissorFn, glScissor);
glFlushFn = LOAD_GL_FUNC_SIMPLE(TglFlushFn, glFlush);

glStencilFuncSeparateFn = LOAD_GL_FUNC(TglStencilFuncSeparateFn, glStencilFuncSeparate);
glStencilOpSeparateFn = LOAD_GL_FUNC(TglStencilOpSeparateFn, glStencilOpSeparate);

glActiveTextureFn = LOAD_GL_FUNC(TglActiveTextureFn, glActiveTexture);
glBlendEquationFn = LOAD_GL_FUNC(TglBlendEquationFn, glBlendEquation);
Expand All @@ -340,13 +352,7 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)

/// Shaders
glCreateShaderFn = LOAD_GL_FUNC(TglCreateShaderFn, glCreateShader);
#ifdef OMIM_OS_WINDOWS
glShaderSourceFn = LOAD_GL_FUNC(TglShaderSourceFn, glShaderSource);
#else
typedef void(DP_APIENTRY * glShaderSource_Type)(GLuint shaderID, GLsizei count,
GLchar const ** string, GLint const * length);
glShaderSourceFn = reinterpret_cast<glShaderSource_Type>(&::glShaderSource);
#endif
glCompileShaderFn = LOAD_GL_FUNC(TglCompileShaderFn, glCompileShader);
glDeleteShaderFn = LOAD_GL_FUNC(TglDeleteShaderFn, glDeleteShader);
glGetShaderivFn = LOAD_GL_FUNC(TglGetShaderivFn, glGetShaderiv);
Expand Down Expand Up @@ -484,13 +490,13 @@ void GLFunctions::glCullFace(glConst face)
void GLFunctions::glStencilOpSeparate(glConst face, glConst sfail, glConst dpfail, glConst dppass)
{
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
GLCHECK(::glStencilOpSeparate(face, sfail, dpfail, dppass));
GLCHECK(glStencilOpSeparateFn(face, sfail, dpfail, dppass));
}

void GLFunctions::glStencilFuncSeparate(glConst face, glConst func, int ref, uint32_t mask)
{
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
GLCHECK(::glStencilFuncSeparate(face, func, ref, mask));
GLCHECK(glStencilFuncSeparateFn(face, func, ref, mask));
}

void GLFunctions::glPixelStore(glConst name, uint32_t value)
Expand Down
12 changes: 6 additions & 6 deletions drape/harfbuzz_shaping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ size_t ScriptSetIntersect(char32_t codepoint, TScriptsArray & inOutScripts, size
//
// Consider 3 characters with the script values {Kana}, {Hira, Kana}, {Kana}. Without script extensions only the first
// script in each set would be taken into account, resulting in 3 segments where 1 would be enough.
size_t ScriptInterval(std::u16string const & text, int32_t start, size_t length, UScriptCode & outScript)
int32_t ScriptInterval(std::u16string const & text, int32_t start, int32_t length, UScriptCode & outScript)
{
ASSERT_GREATER(length, 0U, ());
ASSERT_GREATER(length, 0, ());

auto const begin = text.begin() + start;
auto const end = text.begin() + start + static_cast<int32_t>(length);
auto const end = text.begin() + start + length;
auto iterator = begin;

auto c32 = utf8::unchecked::next16(iterator);
Expand All @@ -118,7 +118,7 @@ size_t ScriptInterval(std::u16string const & text, int32_t start, size_t length,
scriptsSize = ScriptSetIntersect(c32, scripts, scriptsSize);
if (scriptsSize == 0U)
{
length = iterator - begin - 1;
length = static_cast<int32_t>(iterator - begin - 1);
break;
}
}
Expand Down Expand Up @@ -167,7 +167,7 @@ void GetSingleTextLineRuns(TextSegments & segments)
{
// Find the longest sequence of characters that have at least one common UScriptCode value.
UScriptCode script = USCRIPT_INVALID_CODE;
size_t const scriptRunEnd = ScriptInterval(segments.m_text, scriptRunStart, bidiRunEnd - scriptRunStart, script) + scriptRunStart;
int32_t const scriptRunEnd = ScriptInterval(segments.m_text, scriptRunStart, bidiRunEnd - scriptRunStart, script) + scriptRunStart;
ASSERT_LESS(scriptRunStart, base::asserted_cast<int32_t>(scriptRunEnd), ());

// TODO(AB): May need to break on different unicode blocks, parentheses, and control chars (spaces).
Expand All @@ -177,7 +177,7 @@ void GetSingleTextLineRuns(TextSegments & segments)
bidiLevel & 0x01 ? HB_DIRECTION_RTL : HB_DIRECTION_LTR);

// Move to the next script sequence.
scriptRunStart = static_cast<int32_t>(scriptRunEnd);
scriptRunStart = scriptRunEnd;
}
// Move to the next direction sequence.
bidiRunStart = bidiRunEnd;
Expand Down
2 changes: 1 addition & 1 deletion drape/texture_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class TextureManager
std::vector<drape_ptr<HWTexture>> m_texturesToCleanup;

base::Timer m_uploadTimer;
std::atomic_flag m_nothingToUpload {false};
std::atomic_flag m_nothingToUpload = ATOMIC_FLAG_INIT;
std::mutex m_calcGlyphsMutex;

// TODO(AB): Make a more robust use of BreakIterator to split strings and get rid of this space glyph.
Expand Down
2 changes: 1 addition & 1 deletion generator/search_index_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ void BuildAddressTable(FilesContainerR & container, std::string const & addressD

// Prepare threads and mwm contexts for each thread.
std::vector<std::thread> threads;
for (size_t i = 0; i < threadsCount; ++i)
for (uint32_t i = 0; i < threadsCount; ++i)
{
auto handle = dataSource.GetMwmHandleById(mwmId);
contexts[i] = std::make_unique<search::MwmContext>(std::move(handle));
Expand Down
10 changes: 6 additions & 4 deletions platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@ set(SRC
utm_mgrs_utils.hpp
)

if (NOT SKIP_QT_GUI AND PLATFORM_DESKTOP AND PLATFORM_LINUX)
message("Building with Qt Positioning")
if (NOT SKIP_QT_GUI AND PLATFORM_DESKTOP AND (PLATFORM_LINUX OR PLATFORM_WIN))
find_package(Qt6 REQUIRED COMPONENTS Positioning)
set(QT_POSITIONING true)
append(SRC
qt_location_service.hpp
qt_location_service.cpp
)
else()
message("Building without Qt Positioning")
set(QT_POSITIONING false)
endif()

Expand Down Expand Up @@ -101,7 +99,7 @@ elseif(${PLATFORM_ANDROID})
)
else() # neither iPhone nor Android
# Find bash first, on Windows it can be either in Git or in WSL
find_program(BASH bash REQUIRED)
find_program(BASH bash REQUIRED HINTS "$ENV{ProgramFiles}/Git/bin")
# Generate version header file.
execute_process(COMMAND "${BASH}" tools/unix/version.sh qt_version
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
Expand Down Expand Up @@ -204,6 +202,10 @@ target_link_libraries(${PROJECT_NAME}
$<$<BOOL:${PLATFORM_WIN}>:bcrypt> # For boost::uuid
)

if (PLATFORM_WIN)
target_link_libraries(${PROJECT_NAME} shlwapi)
endif()

omim_add_test_subdirectory(platform_tests_support)
omim_add_test_subdirectory(platform_tests)

Expand Down
Loading

0 comments on commit a848d5d

Please sign in to comment.