Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip windows #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .github/workflows/windows-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Windows check
on:
workflow_dispatch: # Manual trigger
push:
branches:
- master
pull_request:
paths-ignore:
- .gitignore
- .github/**
- '!.github/workflows/windows-check.yaml' # Run check on self change
- CONTRIBUTORS
- LICENSE
- NOTICE
- README.md
- android/**
- iphone/**
- data/strings/**
- docs/**
- packaging/**
- platform/*apple*
- platform/*_android*
- platform/*_ios*
- platform/*_mac*
- platform/*_linux*
- pyhelpers/**
- tools/**
- '!tools/python/test_server/**'
- xcode/**

env:
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'

jobs:
windows-matrix:
name: Windows builds
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
build_type: [{ CMAKE_BUILD_TYPE: Debug, CMAKE_MSVC_RUNTIME_LIBRARY: MultiThreadedDebug }, { CMAKE_BUILD_TYPE: Release, CMAKE_MSVC_RUNTIME_LIBRARY: MultiThreaded }]
# Cancels previous jobs if the same branch or PR was updated again.
concurrency:
group: ${{ github.workflow }}-${{ matrix.build_type.CMAKE_BUILD_TYPE }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Parallel submodules checkout
shell: bash
run: |
git \
-c submodule."3party/boost".update=none \
-c submodule."3party/expat".update=none \
-c submodule."3party/fast_double_parser/benchmarks/dependencies/abseil-cpp".update=none \
-c submodule."3party/fast_double_parser/benchmarks/dependencies/double-conversion".update=none \
-c submodule."3party/freetype/freetype".update=none \
-c submodule."3party/freetype/freetype/subprojects/dlg".update=none \
-c submodule."3party/gflags".update=none \
-c submodule."3party/googletest".update=none \
-c submodule."3party/harfbuzz/harfbuzz".update=none \
-c submodule."3party/icu/icu".update=none \
-c submodule."3party/jansson/jansson".update=none \
-c submodule."3party/protobuf".update=none \
-c submodule."3party/protobuf/protobuf/third_party/benchmark".update=none \
-c submodule."3party/pugixml/pugixml".update=none \
-c submodule."3party/utfcpp".update=none \
-c submodule."3party/Vulkan-Headers".update=none \
submodule update --depth 1 --init --recursive --jobs=$(($(nproc) * 20))

- name: Developer Command Prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@v1

- uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: CMake
shell: bash
run: |
echo "Building ${{ matrix.build_type.CMAKE_BUILD_TYPE }}"
cmake . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type.CMAKE_BUILD_TYPE }} \
-DCMAKE_MSVC_RUNTIME_LIBRARY=${{ matrix.build_type.CMAKE_MSVC_RUNTIME_LIBRARY }} \
-DWITH_SYSTEM_PROVIDED_3PARTY=ON \
-DUNITY_DISABLE=ON \
-DOMIM_USE_VCPKG=ON \
-DCMAKE_PROJECT_INCLUDE_BEFORE="${{ github.workspace }}/cmake/vcpkg/x_vcpkg_bootstrap.cmake" \
-DX_VCPKG_CLONE_DIR="${{ github.workspace }}/build/vcpkg" \
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/build/vcpkg/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET=x64-windows-static \
-DVCPKG_HOST_TRIPLET=x64-windows-static \
-DVCPKG_INSTALL_OPTIONS="--disable-metrics;--no-print-usage;--x-abi-tools-use-exact-versions;--clean-buildtrees-after-build;--clean-packages-after-build"

- name: Compile
shell: bash
working-directory: build
run: ninja
4 changes: 4 additions & 0 deletions 3party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ add_subdirectory(opening_hours)
add_subdirectory(stb_image)
add_subdirectory(succinct)

add_library(fast_double_parser INTERFACE)
add_library(fast_double_parser::fast_double_parser ALIAS fast_double_parser)
target_include_directories(fast_double_parser INTERFACE "${OMIM_ROOT}/3party/fast_double_parser/include")

add_subdirectory(vulkan_wrapper)

if (PLATFORM_DESKTOP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,29 @@
#include <ctime>
#include <boost/test/included/unit_test.hpp>

#ifdef _MSC_VER
#include <sstream>
#include <iomanip>
#endif

namespace
{
typedef std::tuple<long, long> LongTimeRange;
int countTests = 0;

#ifdef _MSC_VER
extern "C" char * strptime(char const * s, char const * f, std::tm * tm)
{
std::istringstream input(s);
input.imbue(std::locale::classic());
input >> std::get_time(tm, f);
if (input.fail()) {
return nullptr;
}
return (char*)(s + input.tellg());
}
#endif

LongTimeRange RangeToLong(std::string const & start, std::string const & end)
{
std::tm when{};
Expand Down
17 changes: 17 additions & 0 deletions 3party/opening_hours/opening_hours_tests/opening_hours_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@

#include <boost/spirit/include/qi.hpp>

#ifdef _MSC_VER
#include <iomanip>
#endif

namespace
{
template <typename T>
Expand Down Expand Up @@ -79,6 +83,19 @@ std::string ParseAndUnparse(std::string const & str)
return sstr.str();
}

#ifdef _MSC_VER
extern "C" char * strptime(char const * s, char const * f, std::tm * tm)
{
std::istringstream input(s);
input.imbue(std::locale::classic());
input >> std::get_time(tm, f);
if (input.fail()) {
return nullptr;
}
return (char*)(s + input.tellg());
}
#endif

bool GetTimeTuple(std::string const & strTime, std::string const & fmt, std::tm & tm)
{
auto const rc = strptime(strTime.data(), fmt.data(), &tm);
Expand Down
4 changes: 4 additions & 0 deletions 3party/opening_hours/rules_evaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ bool HasExtendedHours(osmoh::RuleSequence const & rule)
std::tm MakeTimetuple(time_t const timestamp)
{
std::tm tm{};
#ifdef _MSC_VER
localtime_s(&tm, &timestamp);
#else
localtime_r(&timestamp, &tm);
#endif
return tm;
}
} // namespace
Expand Down
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()
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ endif()
option(WITH_SYSTEM_PROVIDED_3PARTY "Enable compilation with system provided dependencies" OFF)
set(OMIM_ROOT ${CMAKE_SOURCE_DIR})

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OMIM_ROOT}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

include(OmimHelpers)
include(OmimTesting)
Expand Down Expand Up @@ -341,12 +341,16 @@ if (WITH_SYSTEM_PROVIDED_3PARTY)

find_package(expat CONFIG REQUIRED)
find_package(jansson CONFIG REQUIRED)
find_package(Protobuf REQUIRED)
find_package(pugixml REQUIRED)
find_package(utf8cpp REQUIRED)
endif()

find_package(ZLIB REQUIRED)

find_package(Boost CONFIG REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

# Include 3party dependencies.
add_subdirectory(3party)

Expand Down
97 changes: 97 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"version": 3,
"configurePresets": [
{
"name": "linux-debug",
"displayName": "Linux Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" },
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"vendor": { "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" } }
},

{
"name": "macos-debug",
"displayName": "macOS Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" },
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"vendor": { "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" } }
},

{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"toolchainFile": "${sourceDir}/out/vcpkg/scripts/buildsystems/vcpkg.cmake",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"WITH_SYSTEM_PROVIDED_3PARTY": "ON",
"UNITY_DISABLE": "ON",
"CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/cmake/vcpkg/x_vcpkg_bootstrap.cmake",
"X_VCPKG_CLONE_DIR": "${sourceDir}/out/vcpkg",
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/cmake/vcpkg/overlay-triplets",
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"VCPKG_HOST_TRIPLET": "x64-windows-static",
"VCPKG_INSTALLED_DIR": {
"type": "PATH",
"value": "${sourceDir}/out/vcpkg_installed"
},
"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"
}
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-windows-debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreadedDebug"
}
},
{
"name": "x64-windows-release",
"inherits": "x64-windows-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded"
}
}
],
"buildPresets": [
{
"name": "x64-windows-debug",
"configurePreset": "x64-windows-debug"
},
{
"name": "x64-windows-release",
"configurePreset": "x64-windows-release"
}
]
}
5 changes: 1 addition & 4 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} INTERFACE Threads::Threads)
target_link_libraries(${PROJECT_NAME} PUBLIC utf8cpp::utf8cpp)

if (NOT WITH_SYSTEM_PROVIDED_3PARTY)
target_include_directories(${PROJECT_NAME} PRIVATE "${OMIM_ROOT}/3party/fast_double_parser/include")
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE fast_double_parser::fast_double_parser)

omim_add_test_subdirectory(base_tests)
6 changes: 3 additions & 3 deletions base/atomic_shared_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class AtomicSharedPtr final

AtomicSharedPtr() = default;

void Set(ValueType value) noexcept { atomic_store(&m_wrapped, value); }
ValueType Get() const noexcept { return atomic_load(&m_wrapped); }
void Set(ValueType value) noexcept { m_wrapped.store(value); }
ValueType Get() const noexcept { return m_wrapped.load(); }

private:
ValueType m_wrapped = std::make_shared<ContentType>();
std::atomic<ValueType> m_wrapped = std::make_shared<ContentType>();

DISALLOW_COPY_AND_MOVE(AtomicSharedPtr);
};
Expand Down
2 changes: 1 addition & 1 deletion base/base_tests/beam_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void Smoke()

vector<double> expected;
for (size_t i = 0; i < kCapacity; ++i)
expected.emplace_back(kTotal - 1 - i);
expected.emplace_back(static_cast<double>(kTotal - 1 - i));

vector<double> actual;
actual.reserve(kCapacity);
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
3 changes: 3 additions & 0 deletions base/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <mutex>
#include <sstream>

#include <windows.h>

namespace base
{
namespace
Expand Down Expand Up @@ -79,6 +81,7 @@ void LogMessageDefault(LogLevel level, SrcPoint const & srcPoint, std::string co
logger.WriteLog(out, srcPoint, msg);

std::cerr << out.str();
OutputDebugStringA(out.str().c_str());

CHECK_LESS(level, g_LogAbortLevel, ("Abort. Log level is too serious", level));
}
Expand Down
4 changes: 3 additions & 1 deletion base/random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ template <class T> class UniformRandom

std::random_device m_rd;
std::mt19937 m_gen;
std::uniform_int_distribution<T> m_distr;

using distribution_int_type = std::conditional_t<sizeof(T) != 1, T, std::conditional_t<std::is_signed_v<T>, short, unsigned short>>;
std::uniform_int_distribution<distribution_int_type> m_distr;

public:
UniformRandom(T min, T max) : m_gen(m_rd()), m_distr(min, max) {}
Expand Down
Loading
Loading