Skip to content

Commit

Permalink
Use CMake for Version more extensively
Browse files Browse the repository at this point in the history
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 surge-synthesizer#1669
Closes surge-synthesizer#1615
Addresses much of surge-synthesizer#1771
  • Loading branch information
baconpaul committed May 4, 2020
1 parent 0defcea commit 64fe120
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 88 deletions.
31 changes: 20 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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

Expand All @@ -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 )

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
50 changes: 50 additions & 0 deletions cmake/versiontools.cmake
Original file line number Diff line number Diff line change
@@ -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()

6 changes: 3 additions & 3 deletions resources/osx-au/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<key>manufacturer</key>
<string>VmbA</string>
<key>name</key>
<string>VmbA: Surge</string>
<string>Surge Synth Team: Surge</string>
<key>subtype</key>
<string>Srge</string>
<key>type</key>
<string>aumu</string>
<key>version</key>
<integer>65536</integer>
<integer>65537</integer>
</dict>
</array>
<key>BuildMachineOSBuild</key>
Expand Down Expand Up @@ -50,6 +50,6 @@
<key>NSHighResolutionCapable</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>2019</string>
<string>Copyright (c) 2020 various authors</string>
</dict>
</plist>
File renamed without changes.
7 changes: 4 additions & 3 deletions src/common/gui/CAboutBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "resource.h"
#include "RuntimeFont.h"
#include <stdio.h>
#include "version.h"

using namespace VSTGUI;

Expand Down Expand Up @@ -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
Expand All @@ -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",
Expand Down
38 changes: 0 additions & 38 deletions src/common/version.h

This file was deleted.

28 changes: 28 additions & 0 deletions src/common/version.h.in
Original file line number Diff line number Diff line change
@@ -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__
25 changes: 13 additions & 12 deletions src/lv2/SurgeLv2Export.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "SurgeLv2Wrapper.h"
#include "version.h"
#include <fstream>
#include <iomanip>

Expand Down Expand Up @@ -46,16 +47,16 @@ void lv2_generate_ttl(const char* baseName)
writePrefix(osDsp);

osDsp << "<" << desc->URI << ">\n"
" doap:name \"Surge\" ;\n"
" doap:license <https://www.gnu.org/licenses/gpl-3.0.en.html> ;\n"
" doap:maintainer [\n"
" foaf:name \"Vember Audio\" ;\n"
" foaf:homepage <https://surge-synthesizer.github.io/> ;\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 <https://www.gnu.org/licenses/gpl-3.0.en.html> ;\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";
Expand Down Expand Up @@ -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";
}

{
Expand Down
7 changes: 4 additions & 3 deletions src/vst2/Vst2PluginInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <float.h>
#include "public.sdk/source/vst2.x/aeffeditor.h"
#include "public.sdk/source/vst2.x/audioeffectx.h"
#include "version.h"

#if MAC
#include <fenv.h>
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/vst3/surgeentry.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "pluginterfaces/base/fplatform.h"

#include "version.h" // for versioning

Expand Down Expand Up @@ -34,7 +35,7 @@ bool DeinitModule()
// GetPluginFactory function!
//------------------------------------------------------------------------

BEGIN_FACTORY_DEF("Vember Audio", "http://www.vemberaudio.se", "mailto:[email protected]")
BEGIN_FACTORY_DEF("Surge Synth Team", "http://surge-synthesizer.github.io", "mailto:[email protected]")

//---First Plug-in included in this factory-------
// its kVstAudioEffectClass component
Expand Down
18 changes: 1 addition & 17 deletions src/windows/surge.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

/////////////////////////////////////////////////////////////////////////////
//
Expand Down
Loading

0 comments on commit 64fe120

Please sign in to comment.