diff --git a/.gitignore b/.gitignore index 426b82c..d68d976 100644 --- a/.gitignore +++ b/.gitignore @@ -77,3 +77,5 @@ story-editor/.idea/ story-editor/buildxcode/ story-editor/cmake-build-debug/ + +story-editor/build-win32/ diff --git a/software/common/audio_player.h b/software/common/audio_player.h index 72ec5a6..ceba559 100644 --- a/software/common/audio_player.h +++ b/software/common/audio_player.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "thread_safe_queue.h" diff --git a/software/library/library_manager.cpp b/software/library/library_manager.cpp index ec69fa8..4fd2b68 100644 --- a/software/library/library_manager.cpp +++ b/software/library/library_manager.cpp @@ -26,7 +26,7 @@ void LibraryManager::Scan() if (std::filesystem::is_directory(entry.path())) { // Si c'est un sous-répertoire, récursivement scanner le contenu - std::string uuid = entry.path().filename(); + std::string uuid = entry.path().filename().generic_string(); if (UUID::IsValid(uuid)) { std::cout << "Found story directory" << std::endl; diff --git a/software/library/story_project.cpp b/software/library/story_project.cpp index d4e538e..ca89ab5 100644 --- a/software/library/story_project.cpp +++ b/software/library/story_project.cpp @@ -328,7 +328,7 @@ void StoryProject::SetDisplayFormat(int w, int h) std::string StoryProject::GetProjectFilePath() const { - return m_project_file_path; + return m_project_file_path.generic_string(); } std::string StoryProject::GetWorkingDir() const diff --git a/story-editor/CMakeLists.txt b/story-editor/CMakeLists.txt index 41fc45d..39332e6 100644 --- a/story-editor/CMakeLists.txt +++ b/story-editor/CMakeLists.txt @@ -269,6 +269,9 @@ install_files("." FILES "${CMAKE_SOURCE_DIR}/tools/imgui.ini") if(WIN32) install_files("." FILES "${SDL2_BIN_DIR}/SDL2.dll") + install_files("." FILES "/usr/lib/gcc/x86_64-w64-mingw32/10-posix/libstdc++-6.dll") + install_files("." FILES "/usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll") + install_files("." FILES "/usr/lib/gcc/x86_64-w64-mingw32/10-posix/libgcc_s_seh-1.dll") endif() # Personnaliser l'icône pour les installateurs Windows diff --git a/story-editor/Dockerfile b/story-editor/Dockerfile index 7e519a1..4bd79e2 100644 --- a/story-editor/Dockerfile +++ b/story-editor/Dockerfile @@ -1,12 +1,21 @@ +# 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 +# ======================================================= + + FROM ubuntu:22.04 -LABEL Description="Build environment" +LABEL Description="Developer environment" ENV HOME /root SHELL ["/bin/bash", "-c"] -RUN mkdir /workspace - RUN apt-get update && apt-get -y --no-install-recommends install \ build-essential \ cmake \ @@ -14,3 +23,11 @@ RUN apt-get update && apt-get -y --no-install-recommends install \ mingw-w64 \ git \ wget + +# Make sure to use the POSIX version of MinGW: +# Manual equivalent command is : update-alternatives --config x86_64-w64-mingw32-g++ + +RUN update-alternatives --set x86_64-w64-mingw32-g++ $(update-alternatives --list x86_64-w64-mingw32-g++ | grep posix) +RUN update-alternatives --set x86_64-w64-mingw32-gcc $(update-alternatives --list x86_64-w64-mingw32-gcc | grep posix) + +RUN mkdir /workspace diff --git a/story-editor/README.md b/story-editor/README.md index 83df36a..dbd8ed4 100644 --- a/story-editor/README.md +++ b/story-editor/README.md @@ -2,64 +2,19 @@ ## How to generate a Windows executable and setup executable on Ubuntu -All the commands listed here are invoked from this `story-editor` root directory. -Make sure to have Docker installed: - -``` -sudo apt install docker.io -``` - -Build the Docker image that contains all the necessary development tools: - -``` -docker build -t cpp-dev . -``` - -Run it: - -``` -docker run -it -v $(pwd)/..:/workspace cpp-dev -``` - - -Make sure to use the POSIX version of MinGW: - -``` -update-alternatives --config x86_64-w64-mingw32-g++ - - - Selection Path Priority Status ------------------------------------------------------------- - 0 /usr/bin/x86_64-w64-mingw32-g++-win32 60 auto mode -* 1 /usr/bin/x86_64-w64-mingw32-g++-posix 30 manual mode - 2 /usr/bin/x86_64-w64-mingw32-g++-win32 60 manual mode - - -update-alternatives --config x86_64-w64-mingw32-gcc - - Selection Path Priority Status ------------------------------------------------------------- - 0 /usr/bin/x86_64-w64-mingw32-gcc-win32 60 auto mode -* 1 /usr/bin/x86_64-w64-mingw32-gcc-posix 30 manual mode - 2 /usr/bin/x86_64-w64-mingw32-gcc-win32 60 manual mode - -``` - - -Cross build, first generate the Makefile: - -``` -git config --global http.sslverify false # avoid error during clone -cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw-w64-x86_64.cmake .. -``` - -Then build the executable and then the installer: - +The build system uses a Docker environment image for reproductible builds. + +Run `build_win32.sh` script. + +Output file is located here: `story-editor/build-win32/Open-Story-Editor-1.0.0-win64.exe` + +## Linux build ``` +cd story-editor +mkdir build +cd build +cmake .. make -j4 make package - ``` - - diff --git a/story-editor/build_win32.sh b/story-editor/build_win32.sh new file mode 100755 index 0000000..3574886 --- /dev/null +++ b/story-editor/build_win32.sh @@ -0,0 +1,11 @@ +docker build -t cpp-dev . +docker run -it \ + -v $(pwd)/..:/workspace \ + cpp-dev \ + bash \ + -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 .. && \ + make && \ + make package" \ No newline at end of file diff --git a/story-editor/src/platform_folders.cpp b/story-editor/src/platform_folders.cpp index d070c51..5f86c9d 100644 --- a/story-editor/src/platform_folders.cpp +++ b/story-editor/src/platform_folders.cpp @@ -121,6 +121,17 @@ namespace pf } } // namesapce internal + + + +std::string getExecutablePath() +{ + char path[MAX_PATH]; + DWORD length = GetModuleFileName(NULL, path, MAX_PATH); + return std::string(path); +} + + } // namespace pf class FreeCoTaskMemory