fix windows build

This commit is contained in:
Anthony Rabine 2024-04-25 23:07:52 +02:00
parent 4698040979
commit bd59867bc3
9 changed files with 84 additions and 30 deletions

View file

@ -34,7 +34,7 @@ void LibraryManager::Scan()
{
// Si c'est un sous-répertoire, récursivement scanner le contenu
std::string uuid = entry.path().filename().generic_string();
if (UUID::IsValid(uuid))
if (Uuid::IsValid(uuid))
{
std::cout << "Found story directory" << std::endl;
// Look for a story.json file in this directory
@ -68,7 +68,7 @@ void LibraryManager::Scan()
std::shared_ptr<StoryProject> LibraryManager::NewProject()
{
auto story = std::make_shared<StoryProject>();
std::string uuid = UUID().String();
std::string uuid = Uuid().String();
story->New(uuid, m_library_path);
story->SetDisplayFormat(320, 240);

View file

@ -7,11 +7,11 @@
// Encaasulate the genaeration of a Version 4 UUID object
// A Version 4 UUID is a universally unique identifier that is generated using random numbers.
class UUID
class Uuid
{
public:
UUID() { New(); }
Uuid() { New(); }
// Factory method for creating UUID object.
void New()

View file

@ -21,7 +21,9 @@ endif()
find_package(OpenGL REQUIRED)
find_package(OpenSSL REQUIRED)
# set(OPENSSL_ROOT_DIR /libs/openssl)
# find_package(OpenSSL REQUIRED)
set(IMGUI_VERSION 1.90)
@ -30,14 +32,46 @@ include(FetchContent)
# =========================================================================================================================
# CURL
# =========================================================================================================================
FetchContent_Declare(curl
URL https://github.com/curl/curl/archive/refs/tags/curl-8_6_0.zip
# Définit les options de cURL pour utiliser mBedTLS
set(CMAKE_USE_OPENSSL OFF)
set(CMAKE_USE_MBEDTLS ON)
# Télécharge et configure cURL
FetchContent_Declare(
curl
GIT_REPOSITORY https://github.com/curl/curl.git
GIT_TAG curl-8_7_1
)
FetchContent_GetProperties(curl)
if(NOT curl_POPULATED)
FetchContent_Populate(curl)
set(BUILD_CURL_EXE FALSE)
set(BUILD_STATIC_LIBS TRUE)
FetchContent_MakeAvailable(curl)
add_subdirectory(${curl_SOURCE_DIR} ${curl_BINARY_DIR})
endif()
# Assurez-vous que votre projet trouve les headers de mBedTLS et cURL
include_directories(${mbedtls_SOURCE_DIR}/include)
include_directories(${curl_SOURCE_DIR}/include)
# FetchContent_Declare(curl
# URL https://github.com/curl/curl/archive/refs/tags/curl-8_6_0.zip
# )
# set(CURL_USE_mbedTLS ON CACHE BOOL "Use MBED TLS." FORCE)
# set(BUILD_TESTING OFF CACHE BOOL "No tests build, plz." FORCE)
# set(USE_MANUAL OFF CACHE BOOL "No manuals, plz." FORCE)
# set(BUILD_CURL_EXE OFF CACHE BOOL "No executable, plz. Only the lib" FORCE)
# set(CURL_ENABLE_EXPORT_TARGET OFF CACHE BOOL "No installation build, plz." FORCE)
# set(CURL_DISABLE_IMAPS ON CACHE BOOL "Use MBED TLS." FORCE)
# set(BUILD_CURL_EXE FALSE)
# set(BUILD_STATIC_LIBS TRUE)
# FetchContent_MakeAvailable(curl)
# include_directories( ${CURL_INCLUDE_DIRS} )
# =========================================================================================================================
# IMGUI and plugins
@ -293,7 +327,9 @@ if(UNIX)
elseif(WIN32)
target_link_libraries(${STORY_EDITOR_PROJECT}
OpenGL::GL
SDL2
SDL3::SDL3
SDL3_image::SDL3_image
libcurl_static
ws2_32.lib psapi.lib setupapi.lib cfgmgr32.lib advapi32.lib
)
endif()

View file

@ -1,13 +1,5 @@
# Multi-stage Docker file
# 1) Developer environment
# 2) nginx stage to serve frontend assets
# This file must be run in the parent directory:
# docker build -t gridwatch-front -f dashboard/Dockerfile .
# =======================================================
# 1. Build stage, we need a node environment
# =======================================================
# Docker image to cross-build C/C++ programs from a Linux host to a Win64 target
# Also includes nsis to create installer
FROM ubuntu:22.04
LABEL Description="Developer environment"
@ -31,3 +23,27 @@ RUN update-alternatives --set x86_64-w64-mingw32-g++ $(update-alternatives --lis
RUN update-alternatives --set x86_64-w64-mingw32-gcc $(update-alternatives --list x86_64-w64-mingw32-gcc | grep posix)
RUN mkdir /workspace
# ========================================================================
# Build OpenSSL for windows
# Libraries are installed in /libs/
# ========================================================================
ENV OPENSSL_VERSION="3.0.13"
RUN mkdir -p /libs/openssl
RUN set -x \
&& wget --no-check-certificate -O /tmp/openssl-${OPENSSL_VERSION}.tar.gz "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" \
&& tar -xvf /tmp/openssl-${OPENSSL_VERSION}.tar.gz -C /tmp/ \
&& rm -rf /tmp/openssl-${OPENSSL_VERSION}.tar.gz \
&& cd /tmp/openssl-${OPENSSL_VERSION} \
&& ./Configure --cross-compile-prefix=x86_64-w64-mingw32- mingw64 --prefix=/libs/openssl \
&& make \
&& make install \
&& cd .. \
&& rm -rf openssl-${OPENSSL_VERSION}
ENV PATH /libs/openssl/bin:$PATH

View file

@ -6,6 +6,8 @@ docker run \
-c "mkdir -p /workspace/story-editor/build-win32 && \
cd /workspace/story-editor/build-win32 && \
git config --global http.sslverify false && \
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw-w64-x86_64.cmake .. && \
cmake -DOPENSSL_ROOT_DIR=/libs/openssl \
-DOPENSSL_CRYPTO_LIBRARY=/libs/openssl/lib64 \
-DCMAKE_TOOLCHAIN_FILE=../cmake/mingw-w64-x86_64.cmake .. && \
make && \
make package"

View file

@ -102,7 +102,7 @@ std::string GetDirectory (const std::string& path)
Gui::Gui()
{
m_executablePath = std::filesystem::current_path();
m_executablePath = std::filesystem::current_path().generic_string();
std::cout << "PATH: " << m_executablePath << std::endl;
}

View file

@ -168,7 +168,7 @@ void PackArchive::DecipherFiles(const std::string &directory, const std::string
{
for (const auto & rf : std::filesystem::directory_iterator(directory))
{
std::string oldFile = rf.path();
std::string oldFile = rf.path().generic_string();
// std::cout << oldFile << std::endl;
DecipherFileOnDisk(oldFile);
@ -209,14 +209,14 @@ void PackArchive::DecipherAll(const std::string &packFileName, const std::string
for (const auto & entry : std::filesystem::directory_iterator(path))
{
std::cout << entry.path() << std::endl;
DecipherFiles(entry.path(), ".bmp");
DecipherFiles(entry.path().generic_string(), ".bmp");
}
path = mPackName + "/sf";
for (const auto & entry : std::filesystem::directory_iterator(path))
{
std::cout << entry.path() << std::endl;
DecipherFiles(entry.path(), ".mp3");
DecipherFiles(entry.path().generic_string(), ".mp3");
}
nlohmann::json j;
@ -417,7 +417,7 @@ std::string PackArchive::OpenImage(const std::string &fileName)
bool PackArchive::ImportStudioFormat(const std::string &fileName, const std::string &outputDir)
{
auto uuid = UUID().String();
auto uuid = Uuid().String();
std::string basePath = outputDir + "/" + uuid;
Unzip(fileName, basePath);
@ -447,9 +447,9 @@ bool PackArchive::ImportStudioFormat(const std::string &fileName, const std::str
// Si c'est un sous-répertoire, récursivement scanner le contenu
auto rData = std::make_shared<Resource>();
rData->file = entry.path().filename();
rData->type = ResourceManager::ExtentionInfo(entry.path().extension(), 1);
rData->format = ResourceManager::ExtentionInfo(entry.path().extension(), 0);
rData->file = entry.path().filename().generic_string();
rData->type = ResourceManager::ExtentionInfo(entry.path().extension().generic_string(), 1);
rData->format = ResourceManager::ExtentionInfo(entry.path().extension().generic_string(), 0);
res.Add(rData);
}
}

View file

@ -50,7 +50,7 @@ void NodeEditorWindow::Clear()
std::string NodeEditorWindow::GenerateNodeId()
{
return UUID().String();
return Uuid().String();
}

View file

@ -123,7 +123,7 @@ std::vector<std::string> Zip::Unzip(std::string const &zipFile, const std::strin
if (!mz_zip_reader_file_stat(&zip_archive, i, &file_stat)) continue;
if (mz_zip_reader_is_file_a_directory(&zip_archive, i)) continue; // skip directories for now
std::string fileName = file_stat.m_filename; // make path relative
std::string destFile = destination_dir + std::filesystem::path::preferred_separator + fileName; // make full dest path
std::string destFile = destination_dir + "/" + fileName; // make full dest path
// creates the directory where the file will be decompressed
std::filesystem::create_directories(std::filesystem::path(destFile).parent_path());