Skip to content

Commit

Permalink
Split backend into a lib and frontend into a thin exec. off static lib
Browse files Browse the repository at this point in the history
This allows for different frontends (i.e. console-based) to be added
easily, and also advances towards unit testing being easier (though at
this moment its still very impractical).
  • Loading branch information
oblivioncth committed Oct 29, 2024
1 parent 9f3046a commit 854af2b
Show file tree
Hide file tree
Showing 106 changed files with 1,235 additions and 965 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ project(CLIFp

# Get helper scripts
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FetchOBCMake.cmake)
fetch_ob_cmake("v0.3.7.1")
fetch_ob_cmake("19d33b5bb1752b50767f78ca3e17796868354ac3")

# Initialize project according to standard rules
include(OB/Project)
Expand Down Expand Up @@ -101,9 +101,18 @@ ob_fetch_quazip(
include(OB/FetchMagicEnum)
ob_fetch_magicenum("v0.9.6")

# Bring in frontend framework module
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib/frontend_framework/cmake")

# Process Targets
set(APP_TARGET_NAME ${PROJECT_NAMESPACE_LC}_${PROJECT_NAMESPACE_LC})
set(APP_ALIAS_NAME ${PROJECT_NAMESPACE})
set(BACKEND_TARGET_NAME ${PROJECT_NAMESPACE_LC}_backend)
set(BACKEND_ALIAS_NAME Backend)
string(TOLOWER "${BACKEND_ALIAS_NAME}" BACKEND_ALIAS_NAME_LC)
set(FRONTEND_FRAMEWORK_TARGET_NAME ${PROJECT_NAMESPACE_LC}_frontend_framework)
set(FRONTEND_FRAMEWORK_ALIAS_NAME FrontendFramework)
add_subdirectory(lib)
set(APP_GUI_TARGET_NAME ${PROJECT_NAMESPACE_LC}_${PROJECT_NAMESPACE_LC})
set(APP_GUI_ALIAS_NAME ${PROJECT_NAMESPACE})
add_subdirectory(app)

#--------------------Package Config-----------------------
Expand All @@ -112,7 +121,7 @@ ob_standard_project_package_config(
COMPATIBILITY "SameMinorVersion"
CONFIG STANDARD
TARGET_CONFIGS
TARGET "${PROJECT_NAMESPACE}::${APP_ALIAS_NAME}" COMPONENT "${APP_ALIAS_NAME}" DEFAULT
TARGET "${PROJECT_NAMESPACE}::${APP_GUI_ALIAS_NAME}" COMPONENT "${APP_GUI_ALIAS_NAME}" DEFAULT
)

#================= Install ==========================
Expand Down
178 changes: 2 additions & 176 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,176 +1,2 @@
#================= Common Build =========================

# Pre-configure target
set(CLIFP_SOURCE
kernel/buildinfo.h
kernel/core.h
kernel/core.cpp
kernel/directive.h
kernel/director.h
kernel/director.cpp
kernel/directorate.h
kernel/directorate.cpp
kernel/driver.h
kernel/driver.cpp
kernel/errorstatus.h
kernel/errorstatus.cpp
command/command.h
command/command.cpp
command/c-download.h
command/c-download.cpp
command/c-link.h
command/c-link.cpp
command/c-play.h
command/c-play.cpp
command/c-prepare.h
command/c-prepare.cpp
command/c-run.h
command/c-run.cpp
command/c-share.h
command/c-share.cpp
command/c-show.cpp
command/c-show.h
command/c-update.h
command/c-update.cpp
command/title-command.h
command/title-command.cpp
task/task.h
task/task.cpp
task/t-download.h
task/t-download.cpp
task/t-exec.h
task/t-exec.cpp
task/t-extra.h
task/t-extra.cpp
task/t-extract.h
task/t-extract.cpp
task/t-generic.h
task/t-generic.cpp
task/t-message.h
task/t-message.cpp
task/t-mount.h
task/t-mount.cpp
task/t-sleep.h
task/t-sleep.cpp
tools/blockingprocessmanager.h
tools/blockingprocessmanager.cpp
tools/deferredprocessmanager.h
tools/deferredprocessmanager.cpp
tools/mounter_game_server.h
tools/mounter_game_server.cpp
tools/mounter_qmp.h
tools/mounter_qmp.cpp
tools/mounter_router.h
tools/mounter_router.cpp
frontend/statusrelay.h
frontend/statusrelay.cpp
controller.h
controller.cpp
utility.h
utility.cpp
main.cpp
)

set(CLIFP_LINKS
PRIVATE
Qt6::Core
Qt6::Gui
Qt6::Widgets
Qt6::Sql
Qt6::Network
Qx::Core
Qx::Io
Qx::Network
Qx::Widgets
Fp::Fp
QuaZip::QuaZip
magic_enum::magic_enum
QI-QMP::Qmpi
)

if(CMAKE_SYSTEM_NAME STREQUAL Windows)
list(APPEND CLIFP_SOURCE
command/c-link_win.cpp
task/t-exec_win.cpp
task/t-bideprocess.h
task/t-bideprocess.cpp
)

list(APPEND CLIFP_LINKS
PRIVATE
Qx::Windows
)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Linux)
list(APPEND CLIFP_SOURCE
command/c-link_linux.cpp
task/t-awaitdocker.h
task/t-awaitdocker.cpp
task/t-exec_linux.cpp
)
list(APPEND CLIFP_LINKS
PRIVATE
Qx::Linux
)
endif()

# Add via ob standard executable
include(OB/Executable)
ob_add_standard_executable(${APP_TARGET_NAME}
NAMESPACE "${PROJECT_NAMESPACE}"
ALIAS "${APP_ALIAS_NAME}"
SOURCE ${CLIFP_SOURCE}
RESOURCE "resources.qrc"
LINKS ${CLIFP_LINKS}
CONFIG STANDARD
WIN32
)

## Forward select project variables to C++ code
include(OB/CppVars)
ob_add_cpp_vars(${APP_TARGET_NAME}
NAME "project_vars"
PREFIX "PROJECT_"
VARS
VERSION_STR "\"${PROJECT_VERSION_VERBOSE}\""
SHORT_NAME "\"${APP_ALIAS_NAME}\""
TARGET_FP_VER_PFX_STR "\"${TARGET_FP_VERSION_PREFIX}\""
APP_NAME "\"${PROJECT_FORMAL_NAME}\""
)

## Add build info
if(BUILD_SHARED_LIBS)
set(link_str "Shared")
else()
set(link_str "Static")
endif()

ob_add_cpp_vars(${APP_TARGET_NAME}
NAME "_buildinfo"
PREFIX "BUILDINFO_"
VARS
SYSTEM "\"${CMAKE_SYSTEM_NAME}\""
LINKAGE "\"${link_str}\""
COMPILER "u\"${CMAKE_CXX_COMPILER_ID}\"_s"
COMPILER_VER_STR "u\"${CMAKE_CXX_COMPILER_VERSION}\"_s"
)

## Add exe details on Windows
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
# Set target exe details
include(OB/WinExecutableDetails)
ob_set_win_executable_details(${APP_TARGET_NAME}
ICON "${CMAKE_CURRENT_SOURCE_DIR}/res/app/CLIFp.ico"
FILE_VER ${PROJECT_VERSION}
PRODUCT_VER ${TARGET_FP_VERSION_PREFIX}
COMPANY_NAME "oblivioncth"
FILE_DESC "CLI for Flashpoint Archive"
INTERNAL_NAME "CLIFp"
COPYRIGHT "Open Source @ 2022 oblivioncth"
TRADEMARKS_ONE "All Rights Reserved"
TRADEMARKS_TWO "GNU AGPL V3"
ORIG_FILENAME "CLIFp.exe"
PRODUCT_NAME "${PROJECT_FORMAL_NAME}"
)
endif()
add_subdirectory(gui)
add_subdirectory(console)
Empty file added app/cmake/Frontend.cmake
Empty file.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added app/cmake/res/app/CLIFp.ico
Binary file not shown.
File renamed without changes.
File renamed without changes
Empty file added app/console/CMakeLists.txt
Empty file.
File renamed without changes.
27 changes: 27 additions & 0 deletions app/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#================= Common Build =========================

# Add via ob standard executable
include(OB/Executable)
ob_add_standard_executable(${APP_GUI_TARGET_NAME}
NAMESPACE "${PROJECT_NAMESPACE}"
ALIAS "${APP_GUI_ALIAS_NAME}"
SOURCE
frontend/gui.h
frontend/gui.cpp
main.cpp
RESOURCE "resources.qrc"
LINKS
PRIVATE
CLIFp::FrontendFramework
${Qt}::Widgets
Qx::Widgets
magic_enum::magic_enum
CONFIG STANDARD
WIN32
)

# Add exe details on Windows
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
include(FrontendFramework)
set_clip_exe_details(${APP_GUI_TARGET_NAME} ${APP_GUI_ALIAS_NAME})
endif()
5 changes: 5 additions & 0 deletions app/gui/res/resources.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/frontend">
<file>tray/Exit.png</file>
</qresource>
</RCC>
Binary file added app/gui/res/tray/Exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 854af2b

Please sign in to comment.