From 3c010d81a919617933d09f9b1826396d216277c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sun, 10 Mar 2024 00:44:34 +0100 Subject: [PATCH] Minor build stuff --- src/app/GUI/aboutwidget.cpp | 20 +++++---- src/app/GUI/welcomedialog.cpp | 2 +- src/core/CMakeLists.txt | 2 +- src/core/appsupport.cpp | 55 ++++++++++++++--------- src/core/appsupport.h | 4 +- src/scripts/build_docker.sh | 2 + src/scripts/build_vfxplatform_friction.sh | 8 ++-- 7 files changed, 55 insertions(+), 38 deletions(-) diff --git a/src/app/GUI/aboutwidget.cpp b/src/app/GUI/aboutwidget.cpp index 9f0215ba9..e718fea92 100644 --- a/src/app/GUI/aboutwidget.cpp +++ b/src/app/GUI/aboutwidget.cpp @@ -41,14 +41,18 @@ AboutWidget::AboutWidget(QWidget *parent) const auto mTopLabel = new QLabel(this); - mTopLabel->setText(QString::fromUtf8("
" - "" - "

%3
%1

" - "
") - .arg(AppSupport::getAppVersion(true), - QString::number(96), - AppSupport::getAppDisplayName(), - AppSupport::getAppName())); + QString label = QString::fromUtf8("
" + "" + "

%3
%1

" + "
").arg(AppSupport::getAppVersion(), + QString::number(96), + AppSupport::getAppDisplayName(), + AppSupport::getAppName()); + const auto buildInfo = AppSupport::getAppBuildInfo(true); + if (!buildInfo.isEmpty()) { + label.append(buildInfo); + } + mTopLabel->setText(label); mTopLayout->addStretch(); mTopLayout->addWidget(mTopLabel); diff --git a/src/app/GUI/welcomedialog.cpp b/src/app/GUI/welcomedialog.cpp index 94b1a220d..950ae0850 100755 --- a/src/app/GUI/welcomedialog.cpp +++ b/src/app/GUI/welcomedialog.cpp @@ -57,7 +57,7 @@ WelcomeDialog::WelcomeDialog(QMenu *recentMenu, "

" "

%3
%1

" "") - .arg(AppSupport::getAppVersion(false), + .arg(AppSupport::getAppVersion(), QString::number(logoSize), AppSupport::getAppDisplayName(), AppSupport::getAppName())); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 1991f9381..8b78bd9a9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -33,7 +33,7 @@ message("-- ffmpeg libraries: ${FFMPEG_LIBRARIES_DIRS} ${FFMPEG_LIBRARIES}") message("-- skia libraries: ${SKIA_LIBRARIES}") add_definitions(-DPROJECT_VERSION="${PROJECT_VERSION}") -add_definitions(-DPROJECT_GIT="${GIT_COMMIT}") +add_definitions(-DPROJECT_COMMIT="${GIT_COMMIT}") add_definitions(-DPROJECT_BRANCH="${GIT_BRANCH}") add_definitions(-DCORE_LIBRARY) diff --git a/src/core/appsupport.cpp b/src/core/appsupport.cpp index 59fa0f225..ba5e6024d 100644 --- a/src/core/appsupport.cpp +++ b/src/core/appsupport.cpp @@ -150,35 +150,41 @@ const QString AppSupport::getAppUrl() return QString::fromUtf8("https://friction.graphics"); } -const QString AppSupport::getAppVersion(bool html) +const QString AppSupport::getAppVersion() { - QString version = QString::fromUtf8("0.9.6"); // fallback, should not happen -#ifdef PROJECT_VERSION - version = QString::fromUtf8(PROJECT_VERSION); -#endif + QString version = QString::fromUtf8(PROJECT_VERSION); #ifndef PROJECT_OFFICIAL version.append("-dev"); #endif - QString git; -#ifdef PROJECT_GIT - git = QString::fromUtf8(PROJECT_GIT); -#endif - QString branch; -#ifdef PROJECT_BRANCH - branch = QString::fromUtf8(PROJECT_BRANCH); -#endif - if (!branch.isEmpty()) { - version.append(QString::fromUtf8(" %1").arg(branch)); - } - if (!git.isEmpty()) { - if (branch.isEmpty()) { version.append(QString::fromUtf8(" ")); } - else { version.append(QString::fromUtf8("/")); } - version.append(html ? QString::fromUtf8("%1").arg(git, - getAppCommitUrl()) : git); - } return version; } +const QString AppSupport::getAppBuildInfo(bool html) +{ +#if defined(PROJECT_COMMIT) && defined(PROJECT_BRANCH) + const auto commit = QString::fromUtf8(PROJECT_COMMIT); + const auto branch = QString::fromUtf8(PROJECT_BRANCH); + if (commit.isEmpty() || branch.isEmpty()) { return QString(); } + if (!html) { + return QString("%1 %2 %3 %4.").arg(tr("Built from"), + commit, + tr("on"), + branch); + } else { + return QString("%1 %2 %3 %4.") + .arg(tr("Built from"), + commit, + tr("on"), + branch, + getAppCommitUrl(), + getAppBranchUrl()); + } +#else + Q_UNUSED(html) +#endif + return QString(); +} + const QString AppSupport::getAppDesc() { return QString::fromUtf8("Motion Graphics"); @@ -209,6 +215,11 @@ const QString AppSupport::getAppCommitUrl() return QString::fromUtf8("https://github.com/friction2d/friction/commit"); } +const QString AppSupport::getAppBranchUrl() +{ + return QString::fromUtf8("https://github.com/friction2d/friction/tree"); +} + const QString AppSupport::getAppConfigPath() { QString path = QString::fromUtf8("%1/%2") diff --git a/src/core/appsupport.h b/src/core/appsupport.h index f302464ad..03b01a278 100644 --- a/src/core/appsupport.h +++ b/src/core/appsupport.h @@ -63,13 +63,15 @@ class CORE_EXPORT AppSupport : public QObject static const QString getAppDomain(); static const QString getAppID(); static const QString getAppUrl(); - static const QString getAppVersion(bool html = false); + static const QString getAppVersion(); + static const QString getAppBuildInfo(bool html = false); static const QString getAppDesc(); static const QString getAppCompany(); static const QString getAppContributorsUrl(); static const QString getAppIssuesUrl(); static const QString getAppLatestReleaseUrl(); static const QString getAppCommitUrl(); + static const QString getAppBranchUrl(); static const QString getAppConfigPath(); static const QString getAppOutputProfilesPath(); static const QString getAppPathEffectsPath(); diff --git a/src/scripts/build_docker.sh b/src/scripts/build_docker.sh index bfcdbe059..9ec6f2e35 100755 --- a/src/scripts/build_docker.sh +++ b/src/scripts/build_docker.sh @@ -101,6 +101,8 @@ CMAKE_EXTRA="${CMAKE_EXTRA} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clan if [ "${REL}" = 1 ]; then cmake -G Ninja \ -DFRICTION_OFFICIAL_RELEASE=ON \ + -DGIT_COMMIT=${COMMIT} \ + -DGIT_BRANCH=${BRANCH} \ ${CMAKE_EXTRA} .. VERSION=`cat version.txt` else diff --git a/src/scripts/build_vfxplatform_friction.sh b/src/scripts/build_vfxplatform_friction.sh index 84e7fba60..af191f2a1 100755 --- a/src/scripts/build_vfxplatform_friction.sh +++ b/src/scripts/build_vfxplatform_friction.sh @@ -81,10 +81,6 @@ CMAKE_EXTRA="" GIT_COMMIT=`git rev-parse --short=8 HEAD` GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` -if [ "${REL}" != 1 ]; then - CMAKE_EXTRA="-DGIT_COMMIT=${GIT_COMMIT} -DGIT_BRANCH=${GIT_BRANCH}" -fi - cmake -GNinja \ -DCMAKE_INSTALL_PREFIX=${SDK} \ -DCMAKE_PREFIX_PATH=${SDK} \ @@ -97,7 +93,9 @@ cmake -GNinja \ -DQSCINTILLA_LIBRARIES=qscintilla2_friction_qt5 \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_C_COMPILER=clang \ -${CMAKE_EXTRA} .. +-DGIT_COMMIT=${GIT_COMMIT} \ +-DGIT_BRANCH=${GIT_BRANCH} \ +.. VERSION=`cat version.txt` if [ "${REL}" != 1 ]; then