Skip to content

Commit

Permalink
Add object creator to releases (CleverRaven#68173)
Browse files Browse the repository at this point in the history
* Optional code needs to be commented out now

* Add object creator to releases

* Add object creator sources to astyle

* Change object creator source dir

Co-authored-by: andrei <[email protected]>

* Add the help->about option

* Object creator now built in devcontainer

Both the windows and linux versions are now built in the devcontainer. The windows version was already built in the devcontainer. I changed the linux version to be built inside the devcontainer too because an error shows up when opening the binary when it was compiled using github actions directly.

* Add qt5 libs install to dockerfile

* Add QT license file

---------

Co-authored-by: andrei <[email protected]>
  • Loading branch information
snipercup and andrei8l authored Sep 21, 2023
1 parent c14b1ec commit bfdc824
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 35 deletions.
55 changes: 28 additions & 27 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,36 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends libsdl2-dev libsdl2-ttf-dev \
libsdl2-image-dev libsdl2-mixer-dev libfreetype6-dev build-essential astyle ccache

# [Optional] comment out this section unless you want to compile the Object Creator. Install some QT libraries
RUN apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools


# [Optional] uncomment this section to include dependencies for Windows cross-compilation from Linux
# [Optional] comment out this section unless you want to cross-compile from Linux to Windows
# This section should align with doc/COMPILING/COMPILING.md#cross-compile-to-windows-from-linux
# With the exception of the installation of packages that are already installed earlier in the Dockerfile
# Like: astyle, cmake
# RUN apt-get -y install autoconf automake autopoint bash bison bzip2 flex gettext git g++ \
# gperf intltool libffi-dev libgdk-pixbuf2.0-dev libtool libltdl-dev libssl-dev \
# libxml-parser-perl lzip make mingw-w64 openssl p7zip-full patch perl pkg-config \
# python3 ruby scons sed unzip wget xz-utils g++-multilib libc6-dev-i386 libtool-bin python3-mako
RUN apt-get -y install autoconf automake autopoint bash bison bzip2 flex gettext git g++ \
gperf intltool libffi-dev libgdk-pixbuf2.0-dev libtool libltdl-dev libssl-dev \
libxml-parser-perl lzip make mingw-w64 openssl p7zip-full patch perl pkg-config \
python3 ruby scons sed unzip wget xz-utils g++-multilib libc6-dev-i386 libtool-bin python3-mako

# WORKDIR /opt
# RUN mkdir -p mxe
# RUN mkdir -p libbacktrace
# RUN git clone https://github.com/mxe/mxe.git ./mxe
# WORKDIR /opt/mxe

# # because of https://github.com/mxe/mxe/issues/2659, we have to link python 3 to python
# RUN ln /usr/bin/python3 /usr/bin/python
# # Builds windows version of SDL2 which is required to later cross-compile CDDA.
# RUN make -j4 MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' \
# MXE_PLUGIN_DIRS=plugins/gcc12 sdl2 sdl2_ttf sdl2_image sdl2_mixer gettext
# WORKDIR /opt/libbacktrace
# RUN wget https://github.com/Qrox/libbacktrace/releases/download/2020-01-03/libbacktrace-x86_64-w64-mingw32.tar.gz
# RUN wget https://github.com/Qrox/libbacktrace/releases/download/2020-01-03/libbacktrace-i686-w64-mingw32.tar.gz
# RUN tar -xzf libbacktrace-x86_64-w64-mingw32.tar.gz --exclude=LICENSE -C /opt/mxe/usr/x86_64-w64-mingw32.static
# RUN tar -xzf libbacktrace-i686-w64-mingw32.tar.gz --exclude=LICENSE -C /opt/mxe/usr/i686-w64-mingw32.static

# #Additional steps to cross compile object_creator. Uncomment this if you want to cross-compile the object cretor
# WORKDIR /opt/mxe
# RUN make MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' qtbase
# RUN export PATH=/opt/mxe/usr/bin:$PATH
WORKDIR /opt
RUN mkdir -p mxe
RUN mkdir -p libbacktrace
RUN git clone https://github.com/mxe/mxe.git ./mxe
WORKDIR /opt/mxe

# because of https://github.com/mxe/mxe/issues/2659, we have to link python 3 to python
RUN ln /usr/bin/python3 /usr/bin/python
# Builds windows version of SDL2 which is required to later cross-compile CDDA.
RUN make -j4 MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' \
MXE_PLUGIN_DIRS=plugins/gcc12 sdl2 sdl2_ttf sdl2_image sdl2_mixer gettext
WORKDIR /opt/libbacktrace
RUN wget https://github.com/Qrox/libbacktrace/releases/download/2020-01-03/libbacktrace-x86_64-w64-mingw32.tar.gz
RUN wget https://github.com/Qrox/libbacktrace/releases/download/2020-01-03/libbacktrace-i686-w64-mingw32.tar.gz
RUN tar -xzf libbacktrace-x86_64-w64-mingw32.tar.gz --exclude=LICENSE -C /opt/mxe/usr/x86_64-w64-mingw32.static
RUN tar -xzf libbacktrace-i686-w64-mingw32.tar.gz --exclude=LICENSE -C /opt/mxe/usr/i686-w64-mingw32.static

#Additional steps to cross compile object_creator. comment this out if you don't want to cross-compile the object cretor
WORKDIR /opt/mxe
RUN make MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' qtbase
RUN export PATH=/opt/mxe/usr/bin:$PATH
57 changes: 53 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ jobs:
ext: zip
content: application/zip
sound: 1
- name: Windows Object Creator x64
mxe: x86_64
artifact: windows-objectcreator-x64
android: none
os: ubuntu-latest
ext: zip
content: application/zip
- name: Linux Tiles x64
os: ubuntu-20.04
mxe: none
Expand Down Expand Up @@ -105,6 +112,13 @@ jobs:
artifact: linux-curses-x64
ext: tar.gz
content: application/gzip
- name: Linux object creator x64
os: ubuntu-20.04
mxe: none
android: none
artifact: linux-objectcreator-x64
ext: tar.gz
content: application/gzip
- name: macOS Curses Universal Binary (x64 and arm64)
os: macos-12
mxe: none
Expand Down Expand Up @@ -172,11 +186,11 @@ jobs:
run: |
vcpkg integrate install --vcpkg-root '${{ runner.workspace }}\b\vcpkg'
- name: Install dependencies (windows mxe)
if: matrix.mxe != 'none'
if: matrix.mxe != 'none' && matrix.artifact != 'windows-objectcreator-x64'
run: |
sudo apt install gettext
- name: Install MXE
if: matrix.mxe != 'none'
if: matrix.mxe != 'none' && matrix.artifact != 'windows-objectcreator-x64'
run: |
curl -L -o mxe-${{ matrix.mxe }}.tar.xz https://github.com/BrettDong/MXE-GCC/releases/download/mxe-sdl-2-0-20/mxe-${{ matrix.mxe }}.tar.xz
curl -L -o mxe-${{ matrix.mxe }}.tar.xz.sha256 https://github.com/BrettDong/MXE-GCC/releases/download/mxe-sdl-2-0-20/mxe-${{ matrix.mxe }}.tar.xz.sha256
Expand Down Expand Up @@ -222,12 +236,47 @@ jobs:
run: |
lang/compile_mo.sh all
- name: Build CDDA (linux)
if: runner.os == 'Linux' && matrix.mxe == 'none' && matrix.android == 'none'
if: runner.os == 'Linux' && matrix.mxe == 'none' && matrix.android == 'none' && matrix.artifact != 'linux-objectcreator-x64'
run: |
make -j$((`nproc`+0)) TILES=${{ matrix.tiles }} SOUND=${{ matrix.tiles }} RELEASE=1 LOCALIZE=1 LANGUAGES=all BACKTRACE=0 PCH=0 bindist
mv cataclysmdda-0.F.tar.gz cdda-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.tar.gz
- name: Login to GitHub Container Registry
if: matrix.artifact == 'windows-objectcreator-x64' || matrix.artifact == 'linux-objectcreator-x64'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build object creator (windows)
if: matrix.artifact == 'windows-objectcreator-x64'
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/cleverRaven/cataclysm-dda/cataclysm-dda-devcontainer
cacheFrom: ghcr.io/cleverRaven/cataclysm-dda/cataclysm-dda-devcontainer
push: always
runCmd: |
git config --global --add safe.directory /workspaces/Cataclysm-DDA
make object_creator.exe CROSS="/opt/mxe/usr/bin/x86_64-w64-mingw32.static-" TILES=1 SOUND=1 RELEASE=1 LOCALIZE=1 PREFIX=output PCH=0 MXE_TARGETS='x86_64-w64-mingw32.static' -j4
- name: Build object creator (linux)
if: matrix.artifact == 'linux-objectcreator-x64'
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/cleverRaven/cataclysm-dda/cataclysm-dda-devcontainer
cacheFrom: ghcr.io/cleverRaven/cataclysm-dda/cataclysm-dda-devcontainer
push: never
runCmd: |
git config --global --add safe.directory /workspaces/Cataclysm-DDA
make -j$((`nproc`+0)) TILES=1 LINTJSON=0 RELEASE=1 object_creator
- name: zip Object Creator (windows)
if: matrix.artifact == 'windows-objectcreator-x64'
run: |
zip cdda-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.${{ matrix.ext }} ./object_creator/object_creator.exe ./object_creator/qt-license.txt
- name: tar Object Creator (linux)
if: matrix.artifact == 'linux-objectcreator-x64'
run: |
tar -czf cdda-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.${{ matrix.ext }} ./object_creator/object_creator ./object_creator/qt-license.txt
- name: Build CDDA (windows mxe)
if: matrix.mxe != 'none'
if: matrix.mxe != 'none' && matrix.artifact != 'windows-objectcreator-x64'
env:
PLATFORM: /opt/mxe/usr/bin/${{ matrix.mxe }}-w64-mingw32.static.gcc12-
run: |
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,8 @@ else
endif
THIRD_PARTY_SOURCES := $(wildcard $(SRC_DIR)/third-party/flatbuffers/*.cpp)
HEADERS := $(wildcard $(SRC_DIR)/*.h)
OBJECT_CREATOR_SOURCES := $(wildcard $object_creator/*.cpp)
OBJECT_CREATOR_HEADERS := $(wildcard $object_creator/*.h)
TESTSRC := $(wildcard tests/*.cpp)
TESTHDR := $(wildcard tests/*.h)
JSON_FORMATTER_SOURCES := $(wildcard tools/format/*.cpp) src/wcwidth.cpp src/json.cpp
Expand All @@ -870,6 +872,8 @@ CLANG_TIDY_PLUGIN_HEADERS := \
ASTYLE_SOURCES := $(sort \
$(SOURCES) \
$(HEADERS) \
$(OBJECT_CREATOR_SOURCES) \
$(OBJECT_CREATOR_HEADERS) \
$(TESTSRC) \
$(TESTHDR) \
$(JSON_FORMATTER_SOURCES) \
Expand Down
29 changes: 25 additions & 4 deletions doc/COMPILING/COMPILING-DEVCONTAINER.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,32 @@ The devcontainer was introduced in [#65748](https://github.com/CleverRaven/Catac
3. Add Cleverraven as the remote upstream with git remote add upstream [email protected]:CleverRaven/Cataclysm-DDA.git
4. Open the folder where you cloned your repository in Visual Studio Code via the UI or by navigating to the directory in a terminal and typing Code
5. Visual Studio Code will show a pup-up in the bottom right with recommended extentions. Install those.
6. Now restart visual studio code. When prompted, click "Reopen in container":
6. If you don't plan to compile the object creator, open the Dockerfile in the VSCode file browser and scroll down to find this section:
![Image showing the uncommented part of the dockerfile](../img/Devcontainer-Find-Uncommented-Linux-QT5-Libs.png)

comment out that part so it looks like this:
![Image showing the uncommented part of the dockerfile](../img/Devcontainer-Commented-Out-Qt5-Linux-Libs.png)

If you don't plan to cross-compile the game, scroll down to find this section:

![Image showing the uncommented part of the dockerfile](../img/Devcontainer-Uncomment-Windows-Part-In-Dockerfile.png)

comment out that part (select it and press ctrl+/ in vscode) so it looks like this:
![Image showing the commented part of the dockerfile](../img/Devcontainer-Find-Commented-Windows-Commands-In-Dockerfile.png)

Next, scroll down to find this section:
![Image showing the uncommented part of the dockerfile](../img/Devcontainer-Uncomment-QT5-Part-In-Dockerfile.png)

comment that part out (select it and press ctrl+/ in vscode) so it looks like this:

![Image showing the commented part of the dockerfile](../img/Devcontainer-Find-Commented-QT5-Commands-In-Dockerfile.png)


7. Now restart visual studio code. When prompted, click "Reopen in container":

![Re-open devcontainer in vscode](../img/Devcontainer-Re-Open-In-Container.png)

6.1 Linux only: You may see this message:
7.1 Linux only: You may see this message:

![User does not have access to group, add user to docker group first](../img/Devcontainer-User-Does-Not-Have-Access-Add-To-Group-First.png)

Expand All @@ -32,12 +53,12 @@ The devcontainer was introduced in [#65748](https://github.com/CleverRaven/Catac
After that, log out of your account and log back in so the permissions are updated. If that doesn't work, reboot your computer.


7. Allow the container to build and for VSCode to Reopen. If everything goes well, you will see the container running:
8. Allow the container to build and for VSCode to Reopen. If everything goes well, you will see the container running:

![Image showing the container is running in vscode](../img/Devcontainer-Running-Cataclysm-Devcontainer.png)


8. Select the makefile extension on the bottom left and choose your desired configuration. Press the "Play" button to build the project
9. Select the makefile extension on the bottom left and choose your desired configuration. Press the "Play" button to build the project

![Image the buttons to press in the makefile extention](../img/Devcontainer-Make-File-Configs.png)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions object_creator/creator_main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <QtWidgets/qtabwidget.h>
#include <QtWidgets/qsplashscreen.h>
#include <QtGui/qpainter.h>
#include <QtWidgets/qmenubar.h>
#include <QtWidgets/qmessagebox.h>



namespace io
Expand Down Expand Up @@ -44,6 +47,26 @@ int creator::main_window::execute( QApplication &app )
std::this_thread::sleep_for( std::chrono::seconds( 2 ) );
app.processEvents();

//Add a menu bar with the file->exit option and the help->about option
QMenuBar* menuBar = creator_main_window.menuBar();
QMenu* fileMenu = menuBar->addMenu( "File" );
QAction* exitAction = fileMenu->addAction( "Exit" );
QObject::connect( exitAction, &QAction::triggered, &creator_main_window, &QMainWindow::close );
QMenu* helpMenu = menuBar->addMenu( "Help" );
QAction* aboutAction = helpMenu->addAction( "About" );
//When the about option is clicked, show a message box information about the object creator
QObject::connect( aboutAction, &QAction::triggered, &creator_main_window, [&creator_main_window]() {
QMessageBox::about( &creator_main_window, "About", "This is the Cataclysm: DDA object creator.\n"
"It is used to create new spells, itemgroups, etc.\n"
"Find more info and contribute to https://github.com/CleverRaven/Cataclysm-DDA.\n");
} );

//Add an option to the help menu to show the about qt dialog
QAction* aboutQtAction = helpMenu->addAction( "About Qt" );
QObject::connect( aboutQtAction, &QAction::triggered, &app, &QApplication::aboutQt );



//Create a tab widget and add it to the main window
QTabWidget* tabWidget = new QTabWidget(&creator_main_window);
creator_main_window.setCentralWidget(tabWidget);
Expand Down
Loading

0 comments on commit bfdc824

Please sign in to comment.