Skip to content

Commit

Permalink
Split file import/export into separate library
Browse files Browse the repository at this point in the history
In drawdance, with a new library called dpimpex. The server doesn't need
any of that stuff, so we can reduce its dependencies by splitting it off
into a library only linked to the client and tools.
  • Loading branch information
askmeaboutlo0m committed Aug 8, 2024
1 parent 940c0f6 commit e3a3f2d
Show file tree
Hide file tree
Showing 81 changed files with 4,075 additions and 4,165 deletions.
100 changes: 51 additions & 49 deletions cmake/DrawdanceDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,65 @@

dp_find_package(ZLIB MODULE REQUIRED)

if(NOT EMSCRIPTEN)
find_package(PkgConfig QUIET)
if(PKGCONFIG_FOUND)
pkg_check_modules(LIBAV IMPORTED_TARGET GLOBAL
libavcodec
libavformat
libavutil
libswscale
)
if(TARGET PkgConfig::LIBAV)
include(CMakePrintHelpers)
cmake_print_properties(TARGETS PkgConfig::LIBAV PROPERTIES
INTERFACE_COMPILE_DEFINITIONS
INTERFACE_COMPILE_FEATURES
INTERFACE_COMPILE_OPTIONS
INTERFACE_INCLUDE_DIRECTORIES
INTERFACE_LINK_DEPENDS
INTERFACE_LINK_DIRECTORIES
INTERFACE_LINK_LIBRARIES
INTERFACE_LINK_LIBRARIES_DIRECT
INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE
INTERFACE_LINK_OPTIONS
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
if(NOT WIN32)
dp_find_package(Threads REQUIRED)
endif()

if(CLIENT OR TOOLS)
if(NOT EMSCRIPTEN)
find_package(PkgConfig QUIET)
if(PKGCONFIG_FOUND)
pkg_check_modules(LIBAV IMPORTED_TARGET GLOBAL
libavcodec
libavformat
libavutil
libswscale
)
add_library(LIBAV::LIBAV ALIAS PkgConfig::LIBAV)
if(TARGET PkgConfig::LIBAV)
include(CMakePrintHelpers)
cmake_print_properties(TARGETS PkgConfig::LIBAV PROPERTIES
INTERFACE_COMPILE_DEFINITIONS
INTERFACE_COMPILE_FEATURES
INTERFACE_COMPILE_OPTIONS
INTERFACE_INCLUDE_DIRECTORIES
INTERFACE_LINK_DEPENDS
INTERFACE_LINK_DIRECTORIES
INTERFACE_LINK_LIBRARIES
INTERFACE_LINK_LIBRARIES_DIRECT
INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE
INTERFACE_LINK_OPTIONS
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
)
add_library(LIBAV::LIBAV ALIAS PkgConfig::LIBAV)
endif()
else()
message(WARNING "PkgConfig NOT FOUND")
endif()
else()
message(WARNING "PkgConfig NOT FOUND")
add_feature_info("Video export via libav" "TARGET LIBAV::LIBAV" "")
endif()
add_feature_info("Video export via libav" "TARGET LIBAV::LIBAV" "")
endif()

if(IMAGE_IMPL STREQUAL "LIBS")
dp_find_package(PNG REQUIRED)
dp_find_package(JPEG REQUIRED)
elseif(IMAGE_IMPL STREQUAL "QT")
dp_find_package("Qt${QT_VERSION_MAJOR}" COMPONENTS Gui REQUIRED)
endif()

dp_find_package(dpwebp REQUIRED)
if(IMAGE_IMPL STREQUAL "LIBS")
dp_find_package(PNG REQUIRED)
dp_find_package(JPEG REQUIRED)
elseif(IMAGE_IMPL STREQUAL "QT")
dp_find_package("Qt${QT_VERSION_MAJOR}" COMPONENTS Gui REQUIRED)
endif()

if(NOT WIN32)
dp_find_package(Threads REQUIRED)
endif()
dp_find_package(dpwebp REQUIRED)

dp_find_package("Qt${QT_VERSION_MAJOR}" COMPONENTS Xml REQUIRED)
if(ZIP_IMPL STREQUAL "LIBZIP")
dp_find_package(libzip QUIET)
if(NOT TARGET libzip::zip)
# libzip 1.5 has only pkg-config
if(PKGCONFIG_FOUND)
pkg_check_modules(libzip REQUIRED IMPORTED_TARGET libzip)
add_library(libzip::zip ALIAS PkgConfig::libzip)
dp_find_package("Qt${QT_VERSION_MAJOR}" COMPONENTS Xml REQUIRED)
if(ZIP_IMPL STREQUAL "LIBZIP")
dp_find_package(libzip QUIET)
if(NOT TARGET libzip::zip)
# libzip 1.5 has only pkg-config
if(PKGCONFIG_FOUND)
pkg_check_modules(libzip REQUIRED IMPORTED_TARGET libzip)
add_library(libzip::zip ALIAS PkgConfig::libzip)
endif()
endif()
elseif(ZIP_IMPL STREQUAL "KARCHIVE")
dp_find_package("KF${QT_VERSION_MAJOR}Archive" REQUIRED)
endif()
elseif(ZIP_IMPL STREQUAL "KARCHIVE")
dp_find_package("KF${QT_VERSION_MAJOR}Archive" REQUIRED)
endif()

if(USE_GENERATORS)
Expand Down
2 changes: 1 addition & 1 deletion src/desktop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ target_link_libraries(drawpile PRIVATE
cmake-config
dpshared
dpclient
drawdance
drawdance_client
${QT_PACKAGE_NAME}::Core
${QT_PACKAGE_NAME}::Gui
${QT_PACKAGE_NAME}::OpenGL
Expand Down
1 change: 1 addition & 0 deletions src/desktop/dialogs/sessionsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "libclient/net/banlistmodel.h"
#include "libclient/parentalcontrols/parentalcontrols.h"
#include "libclient/utils/listservermodel.h"
#include "libshared/util/qtcompat.h"
#include "ui_sessionsettings.h"
#include <QDebug>
#include <QFile>
Expand Down
2 changes: 1 addition & 1 deletion src/desktop/filewrangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef DESKTOP_FILEWRANGLER_H
#define DESKTOP_FILEWRANGLER_H
extern "C" {
#include <dpengine/save.h>
#include <dpimpex/save.h>
}
#include "libclient/utils/images.h"
#include <QObject>
Expand Down
2 changes: 1 addition & 1 deletion src/desktop/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef DESKTOP_MAINWINDOW_H
#define DESKTOP_MAINWINDOW_H
extern "C" {
#include <dpengine/load.h>
#include <dpengine/load_enums.h>
}
#include "desktop/dialogs/flipbook.h"
#include "libclient/canvas/acl.h"
Expand Down
13 changes: 10 additions & 3 deletions src/drawdance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ add_subdirectory(libcommon)
add_subdirectory(libmsg)
add_subdirectory(libengine)

add_library(drawdance INTERFACE)
set(drawdance_libraries dpengine dpmsg dpcommon cmake-config)
target_link_libraries(drawdance INTERFACE dpengine dpmsg dpcommon cmake-config)
add_library(drawdance_server INTERFACE)
target_link_libraries(
drawdance_server INTERFACE dpengine dpmsg dpcommon cmake-config)

if(CLIENT OR TOOLS)
add_subdirectory(libimpex)
add_library(drawdance_client INTERFACE)
target_link_libraries(
drawdance_client INTERFACE dpimpex dpengine dpmsg dpcommon cmake-config)
endif()
128 changes: 65 additions & 63 deletions src/drawdance/bundled/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,71 +36,73 @@ target_include_directories(
add_library(uthash INTERFACE)
target_include_directories(uthash SYSTEM INTERFACE "uthash")

add_library(jo_gifx OBJECT jo_gifx/jo_gifx.h jo_gifx/jo_gifx.c)
target_include_directories(
jo_gifx SYSTEM PUBLIC ${CMAKE_CURRENT_LIST_DIR}/jo_gifx)
if(CLIENT OR TOOLS)
add_library(jo_gifx OBJECT jo_gifx/jo_gifx.h jo_gifx/jo_gifx.c)
target_include_directories(
jo_gifx SYSTEM PUBLIC ${CMAKE_CURRENT_LIST_DIR}/jo_gifx)

set(psd_sdk_sources
psd_sdk/Psd.h
psd_sdk/PsdAllocator.cpp
psd_sdk/PsdAllocator.h
psd_sdk/PsdAssert.h
psd_sdk/PsdBitUtil.h
psd_sdk/PsdBitUtil.inl
psd_sdk/PsdBlendMode.cpp
psd_sdk/PsdBlendMode.h
psd_sdk/PsdChannel.h
psd_sdk/PsdColorMode.cpp
psd_sdk/PsdColorMode.h
psd_sdk/PsdCompilerMacros.h
psd_sdk/PsdCompressionType.h
psd_sdk/PsdDecompressRle.cpp
psd_sdk/PsdDecompressRle.h
psd_sdk/PsdDocument.h
psd_sdk/PsdEndianConversion.h
psd_sdk/PsdEndianConversion.inl
psd_sdk/PsdFile.cpp
psd_sdk/PsdFile.h
psd_sdk/PsdFixedSizeString.cpp
psd_sdk/PsdFixedSizeString.h
psd_sdk/PsdKey.h
psd_sdk/PsdLayer.h
psd_sdk/PsdLayerMask.h
psd_sdk/PsdLayerMaskSection.h
psd_sdk/PsdLayerType.h
psd_sdk/PsdLog.h
psd_sdk/PsdMallocAllocator.cpp
psd_sdk/PsdMallocAllocator.h
psd_sdk/PsdMemoryUtil.h
psd_sdk/PsdMemoryUtil.inl
psd_sdk/PsdNamespace.h
psd_sdk/PsdParseDocument.cpp
psd_sdk/PsdParseDocument.h
psd_sdk/PsdParseLayerMaskSection.cpp
psd_sdk/PsdParseLayerMaskSection.h
psd_sdk/PsdPch.cpp
psd_sdk/PsdPch.h
psd_sdk/PsdPlatform.h
psd_sdk/PsdSection.h
psd_sdk/PsdSyncFileReader.cpp
psd_sdk/PsdSyncFileReader.h
psd_sdk/PsdSyncFileUtil.h
psd_sdk/PsdSyncFileUtil.inl
psd_sdk/PsdTypes.h
psd_sdk/PsdUnionCast.h
psd_sdk/PsdUnionCast.inl
psd_sdk/PsdVectorMask.h
psd_sdk/Psdinttypes.h
psd_sdk/Psdispod.h
psd_sdk/Psdisunsigned.h
psd_sdk/Psdminiz.c
psd_sdk/Psdminiz.h
psd_sdk/Psdstdint.h
)
set(psd_sdk_sources
psd_sdk/Psd.h
psd_sdk/PsdAllocator.cpp
psd_sdk/PsdAllocator.h
psd_sdk/PsdAssert.h
psd_sdk/PsdBitUtil.h
psd_sdk/PsdBitUtil.inl
psd_sdk/PsdBlendMode.cpp
psd_sdk/PsdBlendMode.h
psd_sdk/PsdChannel.h
psd_sdk/PsdColorMode.cpp
psd_sdk/PsdColorMode.h
psd_sdk/PsdCompilerMacros.h
psd_sdk/PsdCompressionType.h
psd_sdk/PsdDecompressRle.cpp
psd_sdk/PsdDecompressRle.h
psd_sdk/PsdDocument.h
psd_sdk/PsdEndianConversion.h
psd_sdk/PsdEndianConversion.inl
psd_sdk/PsdFile.cpp
psd_sdk/PsdFile.h
psd_sdk/PsdFixedSizeString.cpp
psd_sdk/PsdFixedSizeString.h
psd_sdk/PsdKey.h
psd_sdk/PsdLayer.h
psd_sdk/PsdLayerMask.h
psd_sdk/PsdLayerMaskSection.h
psd_sdk/PsdLayerType.h
psd_sdk/PsdLog.h
psd_sdk/PsdMallocAllocator.cpp
psd_sdk/PsdMallocAllocator.h
psd_sdk/PsdMemoryUtil.h
psd_sdk/PsdMemoryUtil.inl
psd_sdk/PsdNamespace.h
psd_sdk/PsdParseDocument.cpp
psd_sdk/PsdParseDocument.h
psd_sdk/PsdParseLayerMaskSection.cpp
psd_sdk/PsdParseLayerMaskSection.h
psd_sdk/PsdPch.cpp
psd_sdk/PsdPch.h
psd_sdk/PsdPlatform.h
psd_sdk/PsdSection.h
psd_sdk/PsdSyncFileReader.cpp
psd_sdk/PsdSyncFileReader.h
psd_sdk/PsdSyncFileUtil.h
psd_sdk/PsdSyncFileUtil.inl
psd_sdk/PsdTypes.h
psd_sdk/PsdUnionCast.h
psd_sdk/PsdUnionCast.inl
psd_sdk/PsdVectorMask.h
psd_sdk/Psdinttypes.h
psd_sdk/Psdispod.h
psd_sdk/Psdisunsigned.h
psd_sdk/Psdminiz.c
psd_sdk/Psdminiz.h
psd_sdk/Psdstdint.h
)

add_library(psd_sdk STATIC ${psd_sdk_sources})
target_include_directories(
psd_sdk SYSTEM PUBLIC ${CMAKE_CURRENT_LIST_DIR}/psd_sdk)
add_library(psd_sdk STATIC ${psd_sdk_sources})
target_include_directories(
psd_sdk SYSTEM PUBLIC ${CMAKE_CURRENT_LIST_DIR}/psd_sdk)
endif()

# The project root adds compiler warnings and tidy to all targets, but
# third-party code does not follow the same code hygiene rules, so turn those
Expand Down
3 changes: 2 additions & 1 deletion src/drawdance/generators/bindgen.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ bindgen \
-I../bundled \
-I../libcommon \
-I../libmsg \
-I../libengine
-I../libengine \
-I../libimpex
2 changes: 1 addition & 1 deletion src/drawdance/generators/qt_image_resize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
#include <cstdio>
#include <QImage>
#include "../libengine/test/resize_image.h"
#include "../libimpex/test/resize_image.h"

static QImage generate_base_image()
{
Expand Down
Loading

0 comments on commit e3a3f2d

Please sign in to comment.