Skip to content

Commit

Permalink
fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
arabine committed Apr 25, 2024
1 parent 4698040 commit bd59867
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 30 deletions.
4 changes: 2 additions & 2 deletions shared/library_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions shared/uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
46 changes: 41 additions & 5 deletions story-editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
36 changes: 26 additions & 10 deletions story-editor/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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

4 changes: 3 additions & 1 deletion story-editor/build_win32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion story-editor/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 7 additions & 7 deletions story-editor/src/importers/pack_archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion story-editor/src/node_editor/node_editor_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void NodeEditorWindow::Clear()

std::string NodeEditorWindow::GenerateNodeId()
{
return UUID().String();
return Uuid().String();
}


Expand Down
2 changes: 1 addition & 1 deletion story-editor/src/zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit bd59867

Please sign in to comment.