Просмотр исходного кода

Merge pull request #2943 from DarkLordZach/azure-titlebars-v2

ci: Add custom titlebars for mainline and patreon
bunnei 6 лет назад
Родитель
Сommit
6f511c8006

+ 1 - 1
.ci/scripts/linux/docker.sh

@@ -5,7 +5,7 @@ cd /yuzu
 ccache -s
 
 mkdir build || true && cd build
-cmake .. -G Ninja -DYUZU_USE_BUNDLED_UNICORN=ON -DYUZU_USE_QT_WEB_ENGINE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON
+cmake .. -G Ninja -DDISPLAY_VERSION=$1 -DYUZU_USE_BUNDLED_UNICORN=ON -DYUZU_USE_QT_WEB_ENGINE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON
 
 ninja
 

+ 1 - 1
.ci/scripts/linux/exec.sh

@@ -2,4 +2,4 @@
 
 mkdir -p "ccache"  || true
 chmod a+x ./.ci/scripts/linux/docker.sh
-docker run -e ENABLE_COMPATIBILITY_REPORTING -e CCACHE_DIR=/yuzu/ccache -v $(pwd):/yuzu yuzuemu/build-environments:linux-fresh /bin/bash /yuzu/.ci/scripts/linux/docker.sh
+docker run -e ENABLE_COMPATIBILITY_REPORTING -e CCACHE_DIR=/yuzu/ccache -v $(pwd):/yuzu yuzuemu/build-environments:linux-fresh /bin/bash /yuzu/.ci/scripts/linux/docker.sh $1

+ 1 - 1
.ci/scripts/windows/docker.sh

@@ -13,7 +13,7 @@ echo '' >> /bin/cmd
 chmod +x /bin/cmd
 
 mkdir build || true && cd build
-cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DYUZU_USE_BUNDLED_UNICORN=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DCMAKE_BUILD_TYPE=Release
+cmake .. -G Ninja -DDISPLAY_VERSION=$1 -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DYUZU_USE_BUNDLED_UNICORN=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DCMAKE_BUILD_TYPE=Release
 ninja
 
 # Clean up the dirty hacks

+ 1 - 1
.ci/scripts/windows/exec.sh

@@ -2,4 +2,4 @@
 
 mkdir -p "ccache" || true
 chmod a+x ./.ci/scripts/windows/docker.sh
-docker run -e CCACHE_DIR=/yuzu/ccache -v $(pwd):/yuzu yuzuemu/build-environments:linux-mingw /bin/bash -ex /yuzu/.ci/scripts/windows/docker.sh
+docker run -e CCACHE_DIR=/yuzu/ccache -v $(pwd):/yuzu yuzuemu/build-environments:linux-mingw /bin/bash -ex /yuzu/.ci/scripts/windows/docker.sh $1

+ 2 - 1
.ci/templates/build-msvc.yml

@@ -1,9 +1,10 @@
 parameters:
   artifactSource: 'true'
   cache: 'false'
+  version: ''
 
 steps:
-- script: mkdir build && cd build && set DATE=`date '+%Y.%m.%d'` && set CI=true && set AZURE_REPO_NAME=yuzu-emu/yuzu-$(BuildName) && set AZURE_REPO_TAG=$(BuildName)-$DATE && cmake -G "Visual Studio 15 2017 Win64" --config Release -DYUZU_USE_BUNDLED_QT=1 -DYUZU_USE_BUNDLED_SDL2=1 -DYUZU_USE_BUNDLED_UNICORN=1 -DYUZU_USE_QT_WEB_ENGINE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DUSE_DISCORD_PRESENCE=ON .. && cd ..
+- script: mkdir build && cd build && cmake -G "Visual Studio 15 2017 Win64" --config Release -DYUZU_USE_BUNDLED_QT=1 -DYUZU_USE_BUNDLED_SDL2=1 -DYUZU_USE_BUNDLED_UNICORN=1 -DYUZU_USE_QT_WEB_ENGINE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DUSE_DISCORD_PRESENCE=ON -DDISPLAY_VERSION=${{ parameters['version'] }} .. && cd ..
   displayName: 'Configure CMake'
 - task: MSBuild@1
   displayName: 'Build'

+ 2 - 1
.ci/templates/build-single.yml

@@ -1,6 +1,7 @@
 parameters:
   artifactSource: 'true'
   cache: 'false'
+  version: ''
 
 steps:
 - task: DockerInstaller@0
@@ -13,7 +14,7 @@ steps:
     key: yuzu-v1-$(BuildName)-$(BuildSuffix)-$(CacheSuffix)
     path: $(System.DefaultWorkingDirectory)/ccache
     cacheHitVar: CACHE_RESTORED
-- script: export DATE=`date '+%Y.%m.%d'` && export CI=true && export AZURE_REPO_NAME=yuzu-emu/yuzu-$(BuildName) && export AZURE_REPO_TAG=$(BuildName)-$DATE && chmod a+x ./.ci/scripts/$(ScriptFolder)/exec.sh && ./.ci/scripts/$(ScriptFolder)/exec.sh
+- script: chmod a+x ./.ci/scripts/$(ScriptFolder)/exec.sh && ./.ci/scripts/$(ScriptFolder)/exec.sh ${{ parameters['version'] }}
   displayName: 'Build'
 - script: chmod a+x ./.ci/scripts/$(ScriptFolder)/upload.sh && RELEASE_NAME=$(BuildName) ./.ci/scripts/$(ScriptFolder)/upload.sh
   displayName: 'Package Artifacts'

+ 5 - 1
.ci/templates/build-standard.yml

@@ -1,3 +1,6 @@
+parameters:
+  version: ''
+
 jobs:
 - job: build
   displayName: 'standard'
@@ -20,4 +23,5 @@ jobs:
   - template: ./build-single.yml
     parameters:
       artifactSource: 'false'
-      cache: $(parameters.cache)
+      cache: $(parameters.cache)
+      version: $(parameters.version)

+ 4 - 0
.ci/templates/build-testing.yml

@@ -1,3 +1,6 @@
+parameters:
+  version: ''
+
 jobs:
 - job: build_test
   displayName: 'testing'
@@ -31,3 +34,4 @@ jobs:
       parameters:
         artifactSource: 'false'
         cache: 'false'
+        version: $(parameters.version)

+ 5 - 0
.ci/yuzu-mainline-step2.yml

@@ -1,6 +1,9 @@
 trigger:
 - master
 
+variables:
+  DisplayVersion: $[counter(variables['DisplayPrefix'], 1)]
+
 stages:
 - stage: format
   displayName: 'format'
@@ -34,6 +37,7 @@ stages:
       parameters:
         artifactSource: 'false'
         cache: 'true'
+        version: $(DisplayVersion)
 - stage: build_win
   dependsOn: format
   displayName: 'build-windows'
@@ -51,6 +55,7 @@ stages:
       parameters:
         artifactSource: 'false'
         cache: 'true'
+        version: $(DisplayVersion)
 - stage: release
   displayName: 'Release'
   dependsOn:

+ 4 - 0
.ci/yuzu-patreon-step2.yml

@@ -1,6 +1,9 @@
 trigger:
 - master
 
+variables:
+  DisplayVersion: $[counter(variables['DisplayPrefix'], 1)]
+
 stages:
 - stage: format
   displayName: 'format'
@@ -28,3 +31,4 @@ stages:
       parameters:
         artifactSource: 'false'
         cache: $(parameters.cache)
+        version: $(DisplayVersion)

+ 12 - 0
src/common/CMakeLists.txt

@@ -15,11 +15,23 @@ if (DEFINED ENV{CI})
     set(BUILD_TAG $ENV{AZURE_REPO_TAG})
   endif()
 endif()
+if (DEFINED ENV{TITLEBARFORMATIDLE})
+  set(TITLE_BAR_FORMAT_IDLE $ENV{TITLEBARFORMATIDLE})
+endif ()
+if (DEFINED ENV{TITLEBARFORMATRUNNING})
+  set(TITLE_BAR_FORMAT_RUNNING $ENV{TITLEBARFORMATRUNNING})
+endif ()
+if (DEFINED ENV{DISPLAYVERSION})
+  set(DISPLAY_VERSION $ENV{DISPLAYVERSION})
+endif ()
 add_custom_command(OUTPUT scm_rev.cpp
     COMMAND ${CMAKE_COMMAND}
       -DSRC_DIR="${CMAKE_SOURCE_DIR}"
       -DBUILD_REPOSITORY="${BUILD_REPOSITORY}"
+      -DTITLE_BAR_FORMAT_IDLE="${TITLE_BAR_FORMAT_IDLE}"
+      -DTITLE_BAR_FORMAT_RUNNING="${TITLE_BAR_FORMAT_RUNNING}"
       -DBUILD_TAG="${BUILD_TAG}"
+      -DBUILD_ID="${DISPLAY_VERSION}"
       -P "${CMAKE_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake"
     DEPENDS
       # WARNING! It was too much work to try and make a common location for this list,

+ 6 - 0
src/common/scm_rev.cpp.in

@@ -11,6 +11,9 @@
 #define BUILD_DATE   "@BUILD_DATE@"
 #define BUILD_FULLNAME "@BUILD_FULLNAME@"
 #define BUILD_VERSION "@BUILD_VERSION@"
+#define BUILD_ID "@BUILD_ID@"
+#define TITLE_BAR_FORMAT_IDLE "@TITLE_BAR_FORMAT_IDLE@"
+#define TITLE_BAR_FORMAT_RUNNING "@TITLE_BAR_FORMAT_RUNNING@"
 #define SHADER_CACHE_VERSION "@SHADER_CACHE_VERSION@"
 
 namespace Common {
@@ -22,6 +25,9 @@ const char g_build_name[]   = BUILD_NAME;
 const char g_build_date[]   = BUILD_DATE;
 const char g_build_fullname[] = BUILD_FULLNAME;
 const char g_build_version[]  = BUILD_VERSION;
+const char g_build_id[] = BUILD_ID;
+const char g_title_bar_format_idle[] = TITLE_BAR_FORMAT_IDLE;
+const char g_title_bar_format_running[] = TITLE_BAR_FORMAT_RUNNING;
 const char g_shader_cache_version[] = SHADER_CACHE_VERSION;
 
 } // namespace

+ 3 - 0
src/common/scm_rev.h

@@ -13,6 +13,9 @@ extern const char g_build_name[];
 extern const char g_build_date[];
 extern const char g_build_fullname[];
 extern const char g_build_version[];
+extern const char g_build_id[];
+extern const char g_title_bar_format_idle[];
+extern const char g_title_bar_format_running[];
 extern const char g_shader_cache_version[];
 
 } // namespace Common

+ 15 - 6
src/yuzu/main.cpp

@@ -1889,15 +1889,24 @@ void GMainWindow::OnCaptureScreenshot() {
 }
 
 void GMainWindow::UpdateWindowTitle(const QString& title_name) {
-    const QString full_name = QString::fromUtf8(Common::g_build_fullname);
-    const QString branch_name = QString::fromUtf8(Common::g_scm_branch);
-    const QString description = QString::fromUtf8(Common::g_scm_desc);
+    const auto full_name = std::string(Common::g_build_fullname);
+    const auto branch_name = std::string(Common::g_scm_branch);
+    const auto description = std::string(Common::g_scm_desc);
+    const auto build_id = std::string(Common::g_build_id);
+
+    const auto date =
+        QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd")).toStdString();
 
     if (title_name.isEmpty()) {
-        setWindowTitle(QStringLiteral("yuzu %1| %2-%3").arg(full_name, branch_name, description));
+        const auto fmt = std::string(Common::g_title_bar_format_idle);
+        setWindowTitle(QString::fromStdString(fmt::format(fmt.empty() ? "yuzu {0}| {1}-{2}" : fmt,
+                                                          full_name, branch_name, description,
+                                                          std::string{}, date, build_id)));
     } else {
-        setWindowTitle(QStringLiteral("yuzu %1| %4 | %2-%3")
-                           .arg(full_name, branch_name, description, title_name));
+        const auto fmt = std::string(Common::g_title_bar_format_idle);
+        setWindowTitle(QString::fromStdString(
+            fmt::format(fmt.empty() ? "yuzu {0}| {3} | {1}-{2}" : fmt, full_name, branch_name,
+                        description, std::string{}, date, build_id)));
     }
 }