Skip to content

Commit

Permalink
Fixed Git build version in the about dialog
Browse files Browse the repository at this point in the history
previously the library build version was displayed instead, which is no more the same after the library and plugins repository split.
  • Loading branch information
redtide committed Jan 4, 2024
1 parent 6fe2f2f commit c2b702b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 14 deletions.
13 changes: 13 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ target_link_libraries(plugins-common
PRIVATE sfizz::internal sfizz::sfizz)
add_library(sfizz::plugins-common ALIAS plugins-common)

include(GitBuildID)
make_git_build_id(
SOURCE_DIR "${PROJECT_SOURCE_DIR}"
OUTPUT_FILE "${PROJECT_BINARY_DIR}/git-build-id/PluginGitBuildId.c"
PREFIX "Plugin"
)
add_library(plugins_git_build_id STATIC EXCLUDE_FROM_ALL
"${PROJECT_SOURCE_DIR}/plugins/git-build-id/PluginGitBuildId.h"
"${PROJECT_BINARY_DIR}/git-build-id/PluginGitBuildId.c"
)
target_include_directories(plugins_git_build_id PUBLIC "${PROJECT_SOURCE_DIR}/plugins/git-build-id")
add_library(plugins::git_build_id ALIAS plugins_git_build_id)

# Link system dependencies
if(WIN32)
elseif(ANDROID)
Expand Down
19 changes: 12 additions & 7 deletions plugins/editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ add_library(sfizz_editor STATIC EXCLUDE_FROM_ALL
)
add_library(sfizz::editor ALIAS sfizz_editor)

target_include_directories(sfizz_editor PUBLIC "src")
target_include_directories(sfizz_editor PUBLIC
src
${PROJECT_SOURCE_DIR}/plugins/git-build-id
)
target_link_libraries(sfizz_editor PUBLIC sfizz::messaging sfizz::plugins-common)
target_link_libraries(sfizz_editor PRIVATE sfizz::vstgui)
target_compile_definitions(sfizz_editor PRIVATE
Expand Down Expand Up @@ -137,9 +140,14 @@ else()
target_include_directories(sfizz_editor PRIVATE ${sfizz-gio_INCLUDE_DIRS})
target_link_libraries(sfizz_editor PRIVATE ${sfizz-gio_LIBRARIES})
endif()
target_link_libraries(sfizz_editor PRIVATE sfizz::colorspaces sfizz::stb_image
sfizz::bit_array sfizz::filesystem sfizz::pugixml)

target_link_libraries(sfizz_editor PRIVATE
sfizz::colorspaces
sfizz::stb_image
sfizz::bit_array
sfizz::filesystem
sfizz::pugixml
plugins::git_build_id
)
# layout tool
if(NOT CMAKE_CROSSCOMPILING)
set(LAYOUTMAKER_SOURCES
Expand All @@ -161,6 +169,3 @@ if(NOT CMAKE_CROSSCOMPILING)
DEPENDS layout-maker "${CMAKE_CURRENT_SOURCE_DIR}/layout/${_layout}.fl")
endforeach()
endif()

# Git build identifier
target_link_libraries(sfizz_editor PRIVATE sfizz-git-build-id)
6 changes: 3 additions & 3 deletions plugins/editor/src/editor/DlgAbout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "DlgAbout.h"
#include "GUIComponents.h"
#include "GUIDefs.h"
#include "GitBuildId.h"
#include "PluginGitBuildId.h"
#include "NativeHelpers.h"

#include "utility/vstgui_before.h"
Expand Down Expand Up @@ -53,8 +53,8 @@ SAboutDialog::SAboutDialog(const CRect& bounds)

const char* version = SFIZZ_VERSION;
std::string versionBuf;
if (GitBuildId[0]) {
versionBuf = absl::StrCat(SFIZZ_VERSION ".", GitBuildId);
if (PluginGitBuildId[0]) {
versionBuf = absl::StrCat(SFIZZ_VERSION ".", PluginGitBuildId);
version = versionBuf.c_str();
}
#if 0
Expand Down
21 changes: 21 additions & 0 deletions plugins/git-build-id/PluginGitBuildId.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: BSD-2-Clause

// This code is part of the sfizz library and is licensed under a BSD 2-clause
// license. You should have receive a LICENSE.md file along with the code.
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz

#pragma once

#if defined(__cplusplus)
extern "C" {
#endif

/**
* @brief Short identifier of the current head commit.
* This generated identifier is empty if the build is not from a Git repository.
*/
extern const char* PluginGitBuildId;

#if defined(__cplusplus)
} // extern "C"
#endif
3 changes: 2 additions & 1 deletion plugins/puredata/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ if(MINGW)
endif()

# Git build identifier
target_link_libraries(sfizz_puredata PRIVATE sfizz-git-build-id)
target_include_directories(sfizz_puredata PUBLIC "${CMAKE_SOURCE_DIR}/plugins/git-build-id")
target_link_libraries(sfizz_puredata PRIVATE plugins::git_build_id)

# Copy resources
copy_puredata_resources(sfizz_puredata
Expand Down
6 changes: 3 additions & 3 deletions plugins/puredata/sfizz_puredata.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// license. You should have receive a LICENSE.md file along with the code.
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz

#include "GitBuildId.h"
#include "PluginGitBuildId.h"
#include <m_pd.h>
#include <sfizz.h>
#include <sfizz/import/sfizz_import.h>
Expand Down Expand Up @@ -294,8 +294,8 @@ __attribute__((visibility("default")))
#endif
void sfizz_setup()
{
if (GitBuildId[0])
post("sfizz external for Puredata, version '%s.%s'", SFIZZ_VERSION, GitBuildId);
if (PluginGitBuildId[0])
post("sfizz external for Puredata, version '%s.%s'", SFIZZ_VERSION, PluginGitBuildId);
else
post("sfizz external for Puredata, version '%s'", SFIZZ_VERSION);

Expand Down

0 comments on commit c2b702b

Please sign in to comment.