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 13 commits into
base: master
Choose a base branch
from
106 changes: 106 additions & 0 deletions .github/workflows/windows-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
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

# Remove?
- name: Configure
shell: bash
run: ./configure.sh

- 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
20 changes: 20 additions & 0 deletions 3party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ if (NOT WITH_SYSTEM_PROVIDED_3PARTY)
add_subdirectory(expat/expat)
add_library(expat::expat ALIAS expat)

# Add GTest library.
add_subdirectory(googletest)

# Configure Jansson library.
set(JANSSON_BUILD_DOCS OFF)
set(JANSSON_BUILD_MAN OFF)
Expand Down Expand Up @@ -63,8 +66,25 @@ 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)
add_subdirectory(libtess2)
endif()

include(FetchContent)
FetchContent_Declare(
xxHash
GIT_REPOSITORY https://github.com/Cyan4973/xxHash.git
GIT_TAG bbb27a5efb85b92a0486cf361a8635715a53f6ba # v0.8.2
SOURCE_SUBDIR cmake_unofficial
#FIND_PACKAGE_ARGS NAMES xxHash
)

set(BUILD_SHARED_LIBS OFF)
set(XXHASH_BUILD_XXHSUM OFF)
FetchContent_MakeAvailable(xxHash)
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()
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.18)

project(omim C CXX)

set(CMAKE_CXX_STANDARD 20)
Expand Down Expand Up @@ -68,7 +69,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 @@ -324,6 +325,8 @@ endif()

# Should be on the root level, not in 3party, so tests can get these dependencies.
if (PLATFORM_LINUX OR PLATFORM_WIN)
# https://gitlab.kitware.com/cmake/cmake/-/issues/25892
set(ICU_FIND_QUIETLY ON)
find_package(ICU COMPONENTS uc i18n data REQUIRED)
find_package(Freetype REQUIRED)
find_package(harfbuzz REQUIRED)
Expand All @@ -334,13 +337,18 @@ if (WITH_SYSTEM_PROVIDED_3PARTY)
find_package(gflags REQUIRED)

find_package(expat CONFIG REQUIRED)
find_package(GTest 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 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;--x-buildtrees-root=${sourceDir}/out/btrees"
}
},
"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: 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
Loading
Loading