fix windows build, new build script for win32 setup executable generation

This commit is contained in:
Anthony Rabine 2024-03-10 14:56:41 +01:00
parent 8581dbf253
commit 37d79c5e33
9 changed files with 61 additions and 61 deletions

2
.gitignore vendored
View file

@ -77,3 +77,5 @@ story-editor/.idea/
story-editor/buildxcode/
story-editor/cmake-build-debug/
story-editor/build-win32/

View file

@ -8,6 +8,7 @@
#include <thread>
#include <condition_variable>
#include <queue>
#include <thread>
#include "thread_safe_queue.h"

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
```

11
story-editor/build_win32.sh Executable file
View file

@ -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"

View file

@ -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