From 64fe1201551a0b4b46d38024bcc5e19d32ceff79 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Thu, 30 Apr 2020 17:26:26 -0400 Subject: [PATCH] Use CMake for Version more extensively CMake gets a version from GIT and pushes it various places in the code base appropriately. While at it, rename things to SurgeSynthTeam and so on. Closes #1669 Closes #1615 Addresses much of #1771 --- CMakeLists.txt | 31 +++++++++++------ cmake/versiontools.cmake | 50 ++++++++++++++++++++++++++++ resources/osx-au/Info.plist | 6 ++-- src/{common => au}/surge_auversion.h | 0 src/common/gui/CAboutBox.cpp | 7 ++-- src/common/version.h | 38 --------------------- src/common/version.h.in | 28 ++++++++++++++++ src/lv2/SurgeLv2Export.cpp | 25 +++++++------- src/vst2/Vst2PluginInstance.cpp | 7 ++-- src/vst3/surgeentry.cpp | 3 +- src/windows/surge.rc | 18 +--------- src/windows/surgeversion.rc.in | 31 +++++++++++++++++ 12 files changed, 156 insertions(+), 88 deletions(-) create mode 100644 cmake/versiontools.cmake rename src/{common => au}/surge_auversion.h (100%) delete mode 100644 src/common/version.h create mode 100644 src/common/version.h.in create mode 100644 src/windows/surgeversion.rc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index bf9ced51a22..f4c60e343d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,11 @@ cmake_minimum_required(VERSION 3.10) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Build for 10.12") -project(Surge VERSION 1.7.0 LANGUAGES CXX ASM) +project(Surge VERSION 1.7.0.0 LANGUAGES CXX ASM) + +include( "cmake/versiontools.cmake" ) +add_custom_target(surge-shared) + set(CMAKE_BUILD_TYPE Release) @@ -23,8 +27,7 @@ set( BUILD_VST3 true ) if( DEFINED ENV{VST2SDK_DIR} ) set( BUILD_VST2 true ) file( TO_CMAKE_PATH "$ENV{VST2SDK_DIR}" VST2SDK_DIR ) - message( "-- Configured to build VST2 using " ${VST2SDK_DIR} ) - + message( WARNING "Building VST2 using " ${VST2SDK_DIR} " - this is an unsupported configuration" ) else() set( BUILD_VST2 false ) endif() @@ -233,6 +236,7 @@ set(SURGE_COMMON_INCLUDES src/common/dsp src/common/thread src/common/vt_dsp + ${CMAKE_BINARY_DIR}/geninclude ) set(SURGE_GUI_INCLUDES @@ -437,7 +441,8 @@ if( BUILD_AU ) ${SURGE_AU_SOURCES} ${SURGE_AU_LIBRARY_SOURCES} ) - + add_dependencies(surge-au surge-shared) + target_compile_features(surge-au PRIVATE cxx_std_17 ) target_compile_definitions(surge-au @@ -495,7 +500,8 @@ if( BUILD_VST3 ) ${SURGE_VST3_SOURCES} ${SURGE_VST3_LIBRARY_SOURCES} ) - + add_dependencies(surge-vst3 surge-shared) + target_compile_features(surge-vst3 PRIVATE cxx_std_17 ) if( APPLE ) @@ -556,10 +562,10 @@ if( BUILD_VST3 ) COMMAND ./scripts/linux/package-vst3.sh ${CMAKE_BINARY_DIR}/libsurge-vst3.so ) elseif( WIN32 ) - add_custom_target( surgev3-dll ALL ) - add_dependencies( surgev3-dll surge-vst3 ) + add_custom_target( Surge.vst3 ALL ) + add_dependencies( Surge.vst3 surge-vst3 ) add_custom_command( - TARGET surgev3-dll + TARGET Surge.vst3 POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_SOURCE_DIR}/target/vst3/Release @@ -580,7 +586,8 @@ if( BUILD_VST2 ) ${SURGE_VST2_SOURCES} ${SURGE_VST2_LIBRARY_SOURCES} ) - + add_dependencies(surge-vst2 surge-shared) + if( UNIX AND NOT APPLE ) target_sources(surge-vst2 PRIVATE src/linux/linux-aeffguieditor.cpp ) @@ -671,7 +678,8 @@ if( BUILD_LV2 ) ${SURGE_LV2_SOURCES} ${SURGE_LV2_LIBRARY_SOURCES} ) - + add_dependencies(surge-lv2 surge-shared) + target_compile_features(surge-lv2 PRIVATE cxx_std_17 ) target_compile_definitions(surge-lv2 @@ -743,7 +751,8 @@ if( BUILD_HEADLESS ) src/headless/UnitTestsMOD.cpp src/headless/UnitTestsTUN.cpp ) - + add_dependencies(surge-headless surge-shared) + target_compile_features(surge-headless PRIVATE cxx_std_17 ) target_compile_definitions(surge-headless diff --git a/cmake/versiontools.cmake b/cmake/versiontools.cmake new file mode 100644 index 00000000000..b5edfc5b485 --- /dev/null +++ b/cmake/versiontools.cmake @@ -0,0 +1,50 @@ + +find_package(Git) +execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + +execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --format=%h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + +cmake_host_system_information(RESULT BUILD_FQDN QUERY FQDN ) + +message( STATUS "Setting up surge version" ) +message( STATUS " git hash is ${GIT_COMMIT_HASH} and branch is ${GIT_BRANCH}" ) +message( STATUS " buildhost is ${BUILD_FQDN}" ) + + +if(${GIT_BRANCH} STREQUAL "master" ) + set( lverpatch "nightly" ) + set( lverrel "999" ) +else() + set( lverpatch ${GIT_BRANCH} ) + set( lverrel "1000" ) +endif() + +set( SURGE_FULL_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${lverpatch}.${GIT_COMMIT_HASH}" ) +set( SURGE_MAJOR_VERSION "${PROJECT_VERSION_MAJOR}" ) +set( SURGE_SUB_VERSION "${PROJECT_VERSION_MINOR}" ) +set( SURGE_RELEASE_VERSION "${lverpatch}" ) +set( SURGE_RELEASE_NUMBER "${lverrel}" ) +set( SURGE_BUILD_HASH "${GIT_COMMIT_HASH}" ) + +message( STATUS "Using SURGE_VERSION=${SURGE_FULL_VERSION}" ) + +configure_file( ${CMAKE_SOURCE_DIR}/src/common/version.h.in + ${CMAKE_BINARY_DIR}/geninclude/version.h ) + +if( WIN32 ) + message( STATUS "Configuring surgeversion.rc" ) + configure_file( ${CMAKE_SOURCE_DIR}/src/windows/surgeversion.rc.in + ${CMAKE_BINARY_DIR}/geninclude/surgeversion.rc + ) +endif() + diff --git a/resources/osx-au/Info.plist b/resources/osx-au/Info.plist index 6c10a6be652..a05351aae2b 100644 --- a/resources/osx-au/Info.plist +++ b/resources/osx-au/Info.plist @@ -12,13 +12,13 @@ manufacturer VmbA name - VmbA: Surge + Surge Synth Team: Surge subtype Srge type aumu version - 65536 + 65537 BuildMachineOSBuild @@ -50,6 +50,6 @@ NSHighResolutionCapable NSHumanReadableCopyright - 2019 + Copyright (c) 2020 various authors diff --git a/src/common/surge_auversion.h b/src/au/surge_auversion.h similarity index 100% rename from src/common/surge_auversion.h rename to src/au/surge_auversion.h diff --git a/src/common/gui/CAboutBox.cpp b/src/common/gui/CAboutBox.cpp index 28cdd1fdb34..5af998e3c1d 100644 --- a/src/common/gui/CAboutBox.cpp +++ b/src/common/gui/CAboutBox.cpp @@ -3,6 +3,7 @@ #include "resource.h" #include "RuntimeFont.h" #include +#include "version.h" using namespace VSTGUI; @@ -48,7 +49,7 @@ void CAboutBox::draw(CDrawContext* pContext) #elif TARGET_VST3 std::string flavor = "vst3"; #elif TARGET_VST2 - std::string flavor = "vst2"; + std::string flavor = "unsupported vst2"; #elif TARGET_LV2 std::string flavor = "lv2"; #else @@ -67,8 +68,8 @@ void CAboutBox::draw(CDrawContext* pContext) { std::vector< std::string > msgs = { { - std::string() + "Version " + SURGE_STR(SURGE_VERSION) + " (" + bittiness + " " + platform + " " + flavor + ". Built " + - __DATE__ + " " + __TIME__ + ")", + std::string() + "Version " + FULL_VERSION_STR + " (" + bittiness + " " + platform + " " + flavor + ". Built " + + __DATE__ + " " + __TIME__ + " on " + BUILD_HOST + ")", std::string() + "Resources: dataPath=" + dataPath + " userData=" + userPath, "Released under the GNU General Public License, v3", "Copyright 2005-2020 by individual contributors", diff --git a/src/common/version.h b/src/common/version.h deleted file mode 100644 index 8627a0dcc93..00000000000 --- a/src/common/version.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __version__ -#define __version__ - -#include "pluginterfaces/base/fplatform.h" - -#define SURGE_VST2_IDENTIFIER 'cjs3' - -#define MAJOR_VERSION_STR "1" -#define MAJOR_VERSION_INT 1 - -#define SUB_VERSION_STR "6" -#define SUB_VERSION_INT 6 - -#define RELEASE_NUMBER_STR "2" -#define RELEASE_NUMBER_INT 2 - -#define BUILD_NUMBER_STR "100" // Build number to be sure that each result could identified. -#define BUILD_NUMBER_INT 100 - -// Version with build number (example "1.0.3.342") -#define FULL_VERSION_STR \ - MAJOR_VERSION_STR "." SUB_VERSION_STR "." RELEASE_NUMBER_STR "." BUILD_NUMBER_STR - -// Version without build number (example "1.0.3") -#define VERSION_STR MAJOR_VERSION_STR "." SUB_VERSION_STR "." RELEASE_NUMBER_STR - -#define stringOriginalFilename "surge.vst3" -#if PLATFORM_64 -#define stringFileDescription "Vember Audio Surge" -#else -#define stringFileDescription "Vember Audio Surge" -#endif - -#define stringCompanyName "Vember Audio\0" -#define stringLegalCopyright "© 2017 Vember Audio" -#define stringLegalTrademarks "VST is a trademark of Steinberg Media Technologies GmbH" - -#endif //__version__ diff --git a/src/common/version.h.in b/src/common/version.h.in new file mode 100644 index 00000000000..b4cb53cc0aa --- /dev/null +++ b/src/common/version.h.in @@ -0,0 +1,28 @@ +#ifndef __version__ +#define __version__ + +#define SURGE_VST2_IDENTIFIER 'cjs3' + +#define MAJOR_VERSION_STR "@SURGE_MAJOR_VERSION@" +#define MAJOR_VERSION_INT @SURGE_MAJOR_VERSION@ + +#define SUB_VERSION_STR "@SURGE_SUB_VERSION@" +#define SUB_VERSION_INT @SURGE_SUB_VERSION@ + +#define RELEASE_NUMBER_STR "@SURGE_RELEASE_NUMBER@" +#define RELEASE_STR "@SURGE_RELEASE_VERSION@" +#define BUILD_NUMBER_STR "@SURGE_BUILD_HASH@" // Build number to be sure that each result could identified. + +// Version with build number (example "1.0.3.342") +#define FULL_VERSION_STR "@SURGE_FULL_VERSION@" + +#define BUILD_HOST "@BUILD_FQDN@" + +#define stringProductName "Surge" +#define stringWebsite "https://surge-synthesizer.github.io/" +#define stringFileDescription "Surge Synth Team Surge" +#define stringCompanyName "Surge Synth Team\0" +#define stringLegalCopyright "© 2017-2020 Surge Synth Team" +#define stringLegalTrademarks "VST is a trademark of Steinberg Media Technologies GmbH" + +#endif //__version__ diff --git a/src/lv2/SurgeLv2Export.cpp b/src/lv2/SurgeLv2Export.cpp index 1d0379f0133..ef7c71f52e9 100644 --- a/src/lv2/SurgeLv2Export.cpp +++ b/src/lv2/SurgeLv2Export.cpp @@ -1,4 +1,5 @@ #include "SurgeLv2Wrapper.h" +#include "version.h" #include #include @@ -46,16 +47,16 @@ void lv2_generate_ttl(const char* baseName) writePrefix(osDsp); osDsp << "<" << desc->URI << ">\n" - " doap:name \"Surge\" ;\n" - " doap:license ;\n" - " doap:maintainer [\n" - " foaf:name \"Vember Audio\" ;\n" - " foaf:homepage ;\n" - " ] ;\n" - " ui:ui <" << uidesc->URI << "> ;\n" - " lv2:optionalFeature lv2:hardRTCapable ;\n" - " lv2:requiredFeature urid:map ;\n" - " lv2:extensionData state:interface ;\n"; + " doap:name \"" << stringProductName << "\" ;\n" + " doap:license ;\n" + " doap:maintainer [\n" + " foaf:name \"" << stringCompanyName << "\" ;\n" + " foaf:homepage <" << stringWebsite << "> ;\n" + " ] ;\n" + " ui:ui <" << uidesc->URI << "> ;\n" + " lv2:optionalFeature lv2:hardRTCapable ;\n" + " lv2:requiredFeature urid:map ;\n" + " lv2:extensionData state:interface ;\n"; unsigned portIndex = 0; osDsp << " lv2:port"; @@ -138,8 +139,8 @@ void lv2_generate_ttl(const char* baseName) osDsp << " ;\n"; // TODO LV2: implement an adequate version number scheme. For now, make it the last two (so 1.6.2 gets 6 2) - osDsp << " lv2:minorVersion 6 ;\n" - " lv2:microVersion 6 .\n"; + osDsp << " lv2:minorVersion " << SUB_VERSION_INT << " ;\n" + " lv2:microVersion " << RELEASE_NUMBER_STR << " .\n"; } { diff --git a/src/vst2/Vst2PluginInstance.cpp b/src/vst2/Vst2PluginInstance.cpp index 1de00e638b3..2e491c74acc 100644 --- a/src/vst2/Vst2PluginInstance.cpp +++ b/src/vst2/Vst2PluginInstance.cpp @@ -10,6 +10,7 @@ #include #include "public.sdk/source/vst2.x/aeffeditor.h" #include "public.sdk/source/vst2.x/audioeffectx.h" +#include "version.h" #if MAC #include @@ -357,19 +358,19 @@ void Vst2PluginInstance::getParameterLabel(VstInt32 index, char* label) bool Vst2PluginInstance::getEffectName(char* name) { - strcpy(name, "Surge"); + strcpy(name, stringProductName); return true; } bool Vst2PluginInstance::getProductString(char* name) { - strcpy(name, "Surge"); + strcpy(name, stringProductName); return true; } bool Vst2PluginInstance::getVendorString(char* text) { - strcpy(text, "Vember Audio"); + strcpy(text, stringCompanyName); return true; } diff --git a/src/vst3/surgeentry.cpp b/src/vst3/surgeentry.cpp index 5632530dc66..ab6b29a7930 100644 --- a/src/vst3/surgeentry.cpp +++ b/src/vst3/surgeentry.cpp @@ -1,3 +1,4 @@ +#include "pluginterfaces/base/fplatform.h" #include "version.h" // for versioning @@ -34,7 +35,7 @@ bool DeinitModule() // GetPluginFactory function! //------------------------------------------------------------------------ -BEGIN_FACTORY_DEF("Vember Audio", "http://www.vemberaudio.se", "mailto:info@vemberaudio.se") +BEGIN_FACTORY_DEF("Surge Synth Team", "http://surge-synthesizer.github.io", "mailto:no-email@no-email.com") //---First Plug-in included in this factory------- // its kVstAudioEffectClass component diff --git a/src/windows/surge.rc b/src/windows/surge.rc index 11583aff883..a777e2f86d5 100644 --- a/src/windows/surge.rc +++ b/src/windows/surge.rc @@ -116,23 +116,7 @@ LANGUAGE LANG_NEUTRAL, // Version // - VS_VERSION_INFO VERSIONINFO - FILEVERSION 1, 6, 2, 0 - PRODUCTVERSION 1, 6, 2, 0 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L FILETYPE 0x2L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK - "000004b0" BEGIN VALUE "Comments", - "http://www.vemberaudio.se" VALUE "CompanyName", "Vember Audio" VALUE "FileDescription", - "Surge VSTi instrument" VALUE "FileVersion", "1, 6, 2, 0" VALUE "InternalName", - "surge" VALUE "LegalCopyright", "Copyright (C) 2005-2019 Authors as described in github" VALUE "OriginalFilename", - "surge.dll" VALUE "ProductName", "Surge" VALUE "ProductVersion", - "1, 6, 2, 0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0, - 1200 END END +#include "surgeversion.rc" ///////////////////////////////////////////////////////////////////////////// // diff --git a/src/windows/surgeversion.rc.in b/src/windows/surgeversion.rc.in new file mode 100644 index 00000000000..6c06a203254 --- /dev/null +++ b/src/windows/surgeversion.rc.in @@ -0,0 +1,31 @@ + + VS_VERSION_INFO VERSIONINFO + FILEVERSION 1, 6, 2, 0 + PRODUCTVERSION 1, 6, 2, 0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L + BEGIN BLOCK "StringFileInfo" + BEGIN BLOCK "000004b0" + BEGIN + VALUE "Comments", "http://surge-synthesizer.github.io" + VALUE "CompanyName", "Surge Synth Team" + VALUE "FileDescription", "Surge VSTi instrument" + VALUE "FileVersion", "@SURGE_MAJOR_VERSION@, @SURGE_SUB_VERSION@, @SURGE_RELEASE_NUMBER@, 0" + VALUE "InternalName", "surge" + VALUE "LegalCopyright", "Copyright (C) 2005-2020 Authors as described in github" + VALUE "OriginalFilename", "surge.dll" + VALUE "ProductName", "Surge" + VALUE "ProductVersion", "@SURGE_MAJOR_VERSION@, @SURGE_SUB_VERSION@, @SURGE_RELEASE_NUMBER@, 0" + END + END + BLOCK "VarFileInfo" + BEGIN VALUE "Translation", 0x0, 1200 + END + END