Skip to content

Commit

Permalink
Add CLI with import/export from fs archive
Browse files Browse the repository at this point in the history
  • Loading branch information
myst6re committed May 17, 2024
1 parent ab9b7ea commit c07bba3
Show file tree
Hide file tree
Showing 14 changed files with 887 additions and 52 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ on:

jobs:
main_build:
name: ${{ matrix.package_suffix }}
name: ${{ matrix.package_suffix }} ${{ matrix.interface }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
qt:
- 6.6.2
- 6.6.3
os:
- ubuntu-latest
- macos-latest
- windows-latest
interface:
- cli
- gui
build_type:
- Release
include:
Expand All @@ -40,6 +43,12 @@ jobs:
qt_arch: win64_msvc2019_64
cmake_extra_args: '-DZLIB_ROOT=C:/zlib'
qt_tools: tools_ninja, tools_cmake
- interface: gui
cmake_cli_arg: 'OFF'
cmake_gui_arg: 'ON'
- interface: cli
cmake_cli_arg: 'ON'
cmake_gui_arg: 'OFF'

env:
qt_installation_path: ${{ github.workspace }}
Expand Down Expand Up @@ -135,11 +144,11 @@ jobs:
- name: Build Deling
id: main_build
run: |
cmake -B ${{ env.deling_build_path }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DCMAKE_INSTALL_PREFIX=${{ env.deling_installation_path }} -DPRERELEASE_STRING="$PRERELEASE_STRING" -Dlz4_DIR=${{ env.lz4_installation_path }}/lib/cmake/lz4 ${{ matrix.cmake_extra_args }}
cmake -B ${{ env.deling_build_path }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DCMAKE_INSTALL_PREFIX=${{ env.deling_installation_path }} -DCLI:BOOL=${{ matrix.cmake_cli_arg }} -DGUI:BOOL=${{ matrix.cmake_gui_arg }} -DPRERELEASE_STRING="$PRERELEASE_STRING" -Dlz4_DIR=${{ env.lz4_installation_path }}/lib/cmake/lz4 ${{ matrix.cmake_extra_args }}
cmake --build ${{ env.deling_build_path }} --target package -j3
- name: Build AppImage (Linux)
if: runner.os == 'Linux'
if: runner.os == 'Linux' && matrix.interface == 'gui'
run: |
sudo add-apt-repository -y universe
sudo apt install -y libfuse2 libxkbcommon-x11-0 libxcb-cursor0
Expand All @@ -153,16 +162,16 @@ jobs:
-e "${{ env.deling_installation_path }}"/bin/Deling \
-d "${{ env.deling_installation_path }}"/share/applications/io.github.myst6re.deling.desktop \
-i "${{ env.deling_installation_path }}"/share/icons/hicolor/256x256/apps/io.github.myst6re.deling.png
mv *.AppImage deling-continuous-${{ matrix.package_suffix }}.AppImage
mv *.AppImage deling-continuous-${{ matrix.interface }}-${{ matrix.package_suffix }}.AppImage
- name: Prepare Upload
shell: bash
run: mv ../build-deling/*.${{ matrix.package_extension }} deling-continuous-${{ matrix.package_suffix }}.${{ matrix.package_extension }}
run: mv ../build-deling/*.${{ matrix.package_extension }} deling-continuous-${{ matrix.interface }}-${{ matrix.package_suffix }}.${{ matrix.package_extension }}

- name: Upload
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.package_suffix }}
name: artifact-${{ matrix.package_suffix }}-${{ matrix.interface }}
path: ${{ github.workspace }}/deling-continuous-*.*

pre_release_assets:
Expand Down
139 changes: 100 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cmake_policy(SET CMP0091 NEW)

set(RELEASE_NAME "Deling")
set(GUI_TARGET "${RELEASE_NAME}")
set(CLI_TARGET "deling-cli")
if(NOT PRERELEASE_STRING)
set(PRERELEASE_STRING "")
endif()
Expand Down Expand Up @@ -52,6 +53,9 @@ set(CMAKE_AUTOUIC OFF)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

option(GUI "Build the gui executable" ON)
option(CLI "Build the cli executable" OFF)

add_compile_definitions(
QT_DISABLE_DEPRECATED_BEFORE=0x050F00
#QT_RESTRICTED_CAST_FROM_ASCII
Expand Down Expand Up @@ -94,8 +98,8 @@ set(PROJECT_SOURCES
"src/Config.h"
"src/ConfigDialog.cpp"
"src/ConfigDialog.h"
"src/CsvFile.cpp"
"src/CsvFile.h"
"src/CsvFile.cpp"
"src/CsvFile.h"
"src/Data.cpp"
"src/Data.h"
"src/EncounterExporter.cpp"
Expand Down Expand Up @@ -245,10 +249,10 @@ set(PROJECT_SOURCES
"src/SpecialCharactersDialog.h"
"src/TdwManagerDialog.cpp"
"src/TdwManagerDialog.h"
"src/TextExporter.cpp"
"src/TextExporter.h"
"src/TextExporterWidget.cpp"
"src/TextExporterWidget.h"
"src/TextExporter.cpp"
"src/TextExporter.h"
"src/TextExporterWidget.cpp"
"src/TextExporterWidget.h"
"src/TextPreview.cpp"
"src/TextPreview.h"
"src/VarManager.cpp"
Expand Down Expand Up @@ -303,16 +307,39 @@ if(APPLE)
)
endif()

set(PROJECT_CLI_SOURCES
"src/main.cpp"
"src/ArchiveObserver.h"
"src/Arguments.cpp"
"src/Arguments.h"
"src/ArgumentsExport.cpp"
"src/ArgumentsExport.h"
"src/ArgumentsImport.cpp"
"src/ArgumentsImport.h"
"src/CLI.cpp"
"src/CLI.h"
"src/Config.cpp"
"src/Config.h"
"src/FsArchive.cpp"
"src/FsArchive.h"
"src/LZS.cpp"
"src/LZS.h"
"src/QLZ4.cpp"
"src/QLZ4.h"
)

set(RESOURCES "src/qt/${RELEASE_NAME}.qrc")

if(APPLE)
set(ICON_FILE "deploy/macosx/${RELEASE_NAME}.icns")
set(EXTRA_RESOURCES_GUI ${ICON_FILE})
set(EXTRA_RESOURCES_CLI "")

set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
elseif (WIN32)
set(ICON_FILE "src/qt/images/deling.ico")
set(EXTRA_RESOURCES_GUI "src/qt/${RELEASE_NAME}.rc")
set(EXTRA_RESOURCES_CLI "${EXTRA_RESOURCES_GUI}")
endif()

function(add_translations target)
Expand All @@ -329,39 +356,53 @@ function(add_translations target)
add_dependencies(${target}_lrelease ${target}_lupdate)
endfunction()

qt_add_executable(${GUI_TARGET} MANUAL_FINALIZATION MACOSX_BUNDLE WIN32 ${PROJECT_SOURCES} ${QM_FILES} ${RESOURCES} ${EXTRA_RESOURCES_GUI})
target_include_directories(${GUI_TARGET} PRIVATE "${CMAKE_SOURCE_DIR}/src")
target_link_libraries(${GUI_TARGET} PRIVATE
Qt::OpenGL
Qt::Widgets
Qt::OpenGLWidgets
ZLIB::ZLIB
LZ4::lz4_static
)

if(${QT_VERSION_MAJOR} EQUAL 6)
target_compile_definitions(${GUI_TARGET}
PRIVATE TASKBAR_BUTTON=1
)
if(GUI)
qt_add_executable(${GUI_TARGET} MANUAL_FINALIZATION MACOSX_BUNDLE WIN32 ${PROJECT_SOURCES} ${QM_FILES} ${RESOURCES} ${EXTRA_RESOURCES_GUI})
target_include_directories(${GUI_TARGET} PRIVATE "${CMAKE_SOURCE_DIR}/src")
target_link_libraries(${GUI_TARGET} PRIVATE
Qt::OpenGL
Qt::Widgets
Qt::OpenGLWidgets
ZLIB::ZLIB
LZ4::lz4_static
)

if(${QT_VERSION_MAJOR} EQUAL 6)
target_compile_definitions(${GUI_TARGET}
PRIVATE TASKBAR_BUTTON=1
)
endif()

set_target_properties(${GUI_TARGET} PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "Deling"
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
MACOSX_BUNDLE_GUI_IDENTIFIER org.myst6re.deling
MACOSX_BUNDLE_ICON_FILE ${RELEASE_NAME}.icns
)

if(APPLE OR WIN32)
set_target_properties(${GUI_TARGET} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")
endif()

add_translations(${GUI_TARGET}
TS_FILES ${TS_FILES}
QM_FILES_OUTPUT_VARIABLE QM_FILES)
endif()

set_target_properties(${GUI_TARGET} PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "Deling"
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
MACOSX_BUNDLE_GUI_IDENTIFIER org.myst6re.deling
MACOSX_BUNDLE_ICON_FILE ${RELEASE_NAME}.icns
)

if(APPLE OR WIN32)
set_target_properties(${GUI_TARGET} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")
if(CLI)
qt_add_executable(${CLI_TARGET} MANUAL_FINALIZATION ${PROJECT_CLI_SOURCES} ${RESOURCES} ${EXTRA_RESOURCES_CLI})
target_include_directories(${CLI_TARGET} PRIVATE "${CMAKE_SOURCE_DIR}/src")
target_link_libraries(${CLI_TARGET} PRIVATE
ZLIB::ZLIB
LZ4::lz4_static
)
target_compile_definitions(${CLI_TARGET}
PRIVATE DELING_CONSOLE=1 QT_NO_DEBUG_OUTPUT=1
)
endif()

add_translations(${GUI_TARGET}
TS_FILES ${TS_FILES}
QM_FILES_OUTPUT_VARIABLE QM_FILES)

include(GNUInstallDirs)

if(APPLE)
Expand All @@ -379,24 +420,44 @@ elseif(WIN32)
if(NOT QT_DEPLOY_TMP_DIR)
set(QT_DEPLOY_TMP_DIR "${CMAKE_BINARY_DIR}/win32-deploy" CACHE PATH "Directory to run deployqt scripts")
endif()
install(TARGETS ${GUI_TARGET} RUNTIME DESTINATION "${QT_DEPLOY_TMP_DIR}")
if(GUI)
install(TARGETS ${GUI_TARGET} RUNTIME DESTINATION "${QT_DEPLOY_TMP_DIR}")
endif()
if(CLI)
install(TARGETS ${CLI_TARGET} RUNTIME DESTINATION "${QT_DEPLOY_TMP_DIR}")
endif()
endif()

add_subdirectory(deploy)

if(APPLE)
install(TARGETS ${GUI_TARGET} BUNDLE DESTINATION ".")
if(GUI)
install(TARGETS ${GUI_TARGET} BUNDLE DESTINATION ".")
endif()
if(CLI)
install(TARGETS ${CLI_TARGET} RUNTIME EXCLUDE_FROM_ALL)
endif()
elseif(WIN32)
install(DIRECTORY "${QT_DEPLOY_TMP_DIR}/" DESTINATION ".")
install(CODE "file(REMOVE_RECURSE \"${QT_DEPLOY_TMP_DIR}\")")
else()
install(FILES ${CMAKE_SOURCE_DIR}/src/qt/images/Deling.png DESTINATION share/icons/hicolor/256x256/apps RENAME io.github.myst6re.deling.png)
install(FILES ${CMAKE_SOURCE_DIR}/deploy/linux/io.github.myst6re.deling.desktop DESTINATION share/applications)
install(FILES ${QM_FILES} DESTINATION share/deling/translations)
install(TARGETS ${GUI_TARGET} RUNTIME)
if(GUI)
install(TARGETS ${GUI_TARGET} RUNTIME)
endif()
if(CLI)
install(TARGETS ${CLI_TARGET} RUNTIME)
endif()
endif()

qt_finalize_executable(${GUI_TARGET})
if(GUI)
qt_finalize_executable(${GUI_TARGET})
endif()
if(CLI)
qt_finalize_executable(${CLI_TARGET})
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CPACK_SYSTEM_NAME "macos")
Expand Down
2 changes: 1 addition & 1 deletion deploy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ endif()
install(FILES ${QM_FILES} DESTINATION "${TRANSLATIONS_PATH}")

# Deploy Qt using macdeployqt and windeployqt scripts
if(APPLE OR WIN32)
if((APPLE AND GUI) OR WIN32)
install(CODE "set(_target_file_dir \"${QT_DEPLOY_TMP_DIR}\")")
install(CODE "set(_target_bundle_name \"${PROJECT_NAME}.app\")")
install(CODE "set(_qt_translations_dir \"${_qt_translations_dir}\")")
Expand Down
Loading

0 comments on commit c07bba3

Please sign in to comment.