Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/dtkcore-archlinux-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Build dtkcore on Arch Linux

on:
push:

pull_request:

jobs:
container:
runs-on: ubuntu-latest
container: archlinux:latest
strategy:
matrix:
include:
- qt_version: 5
dtk5: "ON"
- qt_version: 6
dtk5: "OFF"
steps:
- name: Initialize pacman and system update
run: |
pacman-key --init
pacman --noconfirm --noprogressbar -Syu

- name: Install base build tools
run: |
pacman -S --noconfirm --noprogressbar base-devel git cmake ninja pkgconf

- name: Install dtkcore Qt5 system dependencies
if: matrix.qt_version == 5
run: |
pacman -S --noconfirm --noprogressbar \
qt5-base qt5-tools \
icu uchardet dbus \
gtest spdlog \
gsettings-qt \
dtkcommon dtklog

- name: Install dtkcore Qt6 system dependencies
if: matrix.qt_version == 6
run: |
pacman -S --noconfirm --noprogressbar \
qt6-base qt6-tools \
icu uchardet dbus \
gtest spdlog \
dtkcommon dtk6log

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure and build dtkcore
run: |
cmake -B build \
-GNinja \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE=Release \
-DMKSPECS_INSTALL_DIR=lib/qt/mkspecs/modules \
-DBUILD_DOCS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
-DDTK5=${{ matrix.dtk5 }}
cmake --build build -j$(nproc)
echo "✅ dtkcore Qt${{ matrix.qt_version }} built successfully!"

- name: Install dtkcore to staging directory
run: |
DESTDIR=/tmp/dtkcore-install cmake --install build
echo "Total: $(find /tmp/dtkcore-install -type f | wc -l) files"

- name: Create installation package
run: |
cd /tmp/dtkcore-install
pacman -S --noconfirm zip
zip -r /tmp/dtkcore-archlinux-qt${{ matrix.qt_version }}-$(date +%Y%m%d-%H%M%S).zip .
ls -la /tmp/dtkcore-archlinux-qt${{ matrix.qt_version }}-*.zip

- name: Upload dtkcore Arch Linux build artifacts
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v4
with:
name: dtkcore-archlinux-qt${{ matrix.qt_version }}-build
path: "/tmp/dtkcore-archlinux-qt${{ matrix.qt_version }}-*.zip"
if-no-files-found: error
retention-days: 30
77 changes: 77 additions & 0 deletions .github/workflows/dtkcore-deepin-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build dtkcore on Deepin crimson

on:
push:

pull_request:

jobs:
container:
runs-on: ubuntu-latest
container: linuxdeepin/deepin:crimson
strategy:
matrix:
include:
- qt_version: 5
dtk_profile: nodtk6
- qt_version: 6
dtk_profile: nodtk5
steps:
- uses: actions/checkout@v4

- name: Setup apt sources and build tools
run: |
set -euxo pipefail
echo "deb [trusted=yes] http://mirrors.kernel.org/deepin/beige/ crimson main commercial community" > /etc/apt/sources.list
echo "deb-src [trusted=yes] http://mirrors.kernel.org/deepin/beige/ crimson main commercial community" >> /etc/apt/sources.list
rm -rf /etc/apt/sources.list.d
apt-get update
apt-get install -y devscripts equivs git

- name: Build and install dtkcommon from source
run: |
set -euxo pipefail
cd /tmp
git clone --depth=1 https://github.com/linuxdeepin/dtkcommon.git
cd dtkcommon
mk-build-deps --install --remove --tool='apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes' debian/control
dpkg-buildpackage -uc -us -b
dpkg -i ../*.deb 2>/dev/null || apt-get install -f -y
echo "✅ dtkcommon installed"

- name: Build and install dtklog from source
run: |
set -euxo pipefail
cd /tmp
git clone --depth=1 https://github.com/linuxdeepin/dtklog.git
cd dtklog
mk-build-deps --install --remove --tool='apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes' debian/control
dpkg-buildpackage -uc -us -b -P${{ matrix.dtk_profile }}
dpkg -i ../*.deb 2>/dev/null || apt-get install -f -y
echo "✅ dtklog installed"

- name: Install dtkcore build dependencies
run: |
set -euxo pipefail
mk-build-deps --install --remove --tool='apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes' debian/control

- name: Build dtkcore deb packages
run: |
set -euxo pipefail
dpkg-buildpackage -uc -us -b -P${{ matrix.dtk_profile }}
echo "✅ dtkcore Qt${{ matrix.qt_version }} deb packages built successfully!"
ls -la ../

- name: Collect deb artifacts
run: |
mkdir -p dist
mv ../*.deb dist/
ls -la dist

- name: Upload dtkcore deb packages as artifacts
uses: actions/upload-artifact@v4
with:
name: dtkcore-deepin-deb-packages-qt${{ matrix.qt_version }}
path: dist/*.deb
if-no-files-found: error
retention-days: 30
12 changes: 6 additions & 6 deletions src/dci/private/ddcifileengine.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#include <QtGlobal>

Check warning on line 4 in src/dci/private/ddcifileengine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtGlobal> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <filesystem> //Avoid changing the access control of the standard library
#endif

#define private public
#define protected public
#include <private/qfile_p.h>

Check warning on line 10 in src/dci/private/ddcifileengine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <private/qfile_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#undef private
#undef protected

#include "util/dprivateaccessor_p.h"

Check warning on line 12 in src/dci/private/ddcifileengine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "util/dprivateaccessor_p.h" not found.
#include "ddcifileengine_p.h"
#include "dci/ddcifile.h"

Check warning on line 14 in src/dci/private/ddcifileengine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dci/ddcifile.h" not found.

#include <QBuffer>

Check warning on line 16 in src/dci/private/ddcifileengine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QBuffer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QLoggingCategory>

Check warning on line 17 in src/dci/private/ddcifileengine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLoggingCategory> not found. Please note: Cppcheck does not need standard library headers to get proper results.

D_DECLARE_PRIVATE_METHOD(QFile_d_func_tag, QFile, d_func, QFilePrivate *);
D_DECLARE_PRIVATE_CONST_METHOD(QFilePrivate_engine_tag, QFilePrivate, engine, QAbstractFileEngine *);

DCORE_BEGIN_NAMESPACE

#ifdef QT_DEBUG
Expand Down Expand Up @@ -306,7 +306,7 @@
{
if (!flush())
return false;
return realDciFile.d_func()->engine()->syncToDisk();
return D_PRIVATE_CALL(*D_PRIVATE_CALL(realDciFile, QFile_d_func_tag{}), QFilePrivate_engine_tag{})->syncToDisk();
}

qint64 DDciFileEngine::size() const
Expand Down
73 changes: 73 additions & 0 deletions src/util/dprivateaccessor_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#pragma once

#include <QtCore/qcompilerdetection.h>

// Private member accessor using the explicit template instantiation technique.
//
// C++ Standard [temp.explicit]/12 states:
// "The usual access checking rules do not apply to names used to
// specify explicit instantiation definitions."
//
// This allows passing pointers to private/protected data members and
// member functions as template arguments in explicit instantiations,
// bypassing normal access control — without modifying the class definition
// and without the UB caused by "#define private public".
//
// NOTE: These helper structs must be in the SAME namespace as the Tag structs
// (global namespace, since the macros expand at file scope). If they were in a
// sub-namespace, the friend definition would create a different function than
// the friend declaration in the Tag struct, causing undefined-reference errors.

QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wnon-template-friend")

template<typename Tag>
struct DtkCorePrivateAccessor
{
using MemberPtr = typename Tag::MemberPtr;
friend MemberPtr get(Tag) noexcept;
};

template<typename Tag, typename Tag::MemberPtr Ptr>
struct DtkCorePrivateAccessorImpl : DtkCorePrivateAccessor<Tag>
{
friend typename Tag::MemberPtr get(Tag) noexcept { return Ptr; }
};

QT_WARNING_POP

#define D_DECLARE_PRIVATE_MEMBER(TagName, ClassName, Member, MemberType) \
struct TagName { \
using MemberPtr = MemberType ClassName::*; \
friend MemberPtr get(TagName) noexcept; \
}; \
template struct DtkCorePrivateAccessorImpl<TagName, &ClassName::Member>

#define D_DECLARE_PRIVATE_METHOD(TagName, ClassName, MethodName, RetType, ...) \
struct TagName { \
using MemberPtr = RetType (ClassName::*)(__VA_ARGS__); \
friend MemberPtr get(TagName) noexcept; \
}; \
template struct DtkCorePrivateAccessorImpl<TagName, &ClassName::MethodName>

#define D_DECLARE_PRIVATE_CONST_METHOD(TagName, ClassName, MethodName, RetType, ...) \
struct TagName { \
using MemberPtr = RetType (ClassName::*)(__VA_ARGS__) const; \
friend MemberPtr get(TagName) noexcept; \
}; \
template struct DtkCorePrivateAccessorImpl<TagName, &ClassName::MethodName>

// Trampoline: ensures get(tag) is called from a context with no class-scope
// get() member that might suppress ADL (C++ [basic.lookup.argdep] para 3).
namespace dtk_private_detail {
template<typename Tag>
inline typename Tag::MemberPtr access(Tag t) noexcept { return get(t); }
}

#define D_PRIVATE_MEMBER(obj, tag) ((obj).*dtk_private_detail::access(tag))
#define D_PRIVATE_CALL(obj, tag, ...) ((obj).*dtk_private_detail::access(tag))(__VA_ARGS__)

3 changes: 3 additions & 0 deletions tools/dci/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ target_include_directories(${BIN_NAME} PUBLIC
../../include/base/
../../include/global/
)
target_include_directories(${BIN_NAME} PRIVATE
../../src/
)
set_target_properties(${BIN_NAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME})
#end dci

Expand Down
Loading