Skip to content

Commit

Permalink
Improve version number system
Browse files Browse the repository at this point in the history
  • Loading branch information
starg2 committed Dec 26, 2017
1 parent 2971fe7 commit 3f1b9d8
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 60 deletions.
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@ cmake_minimum_required(VERSION 3.9)

project(timidity41)

find_package(Git)

if("${Git_FOUND}" AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
add_custom_target(
UpdateTim41Version
COMMAND "${CMAKE_COMMAND}"
-DGIT_EXECUTABLE="${GIT_EXECUTABLE}"
-DINFILE="${CMAKE_CURRENT_SOURCE_DIR}/version.h.in"
-DOUTFILE="${CMAKE_CURRENT_BINARY_DIR}/version.h"
-P "${CMAKE_CURRENT_SOURCE_DIR}/WriteVersion.cmake"
COMMENT "Updating version info..."
)
else()
set(tim41VersionStr "current")
set(tim41Version3Comma "41,0,0")
configure_file(version.h.in version.h)
endif()

include_directories("${CMAKE_CURRENT_BINARY_DIR}")

add_definitions(
# TiMidity++ common
-DRETSIGTYPE=int
Expand Down
11 changes: 11 additions & 0 deletions WriteVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

execute_process(
COMMAND "${GIT_EXECUTABLE}" describe
OUTPUT_VARIABLE gitDescribeResult
OUTPUT_STRIP_TRAILING_WHITESPACE
)

string(REPLACE "tim" "" tim41VersionStr "${gitDescribeResult}")
string(REGEX MATCH "[0-9.]+\\.[0-9.]+\\.[0-9.]+" tim41Version3 "${gitDescribeResult}")
string(REPLACE "." "," tim41Version3Comma "${tim41Version3}")
configure_file(${INFILE} ${OUTFILE})
2 changes: 2 additions & 0 deletions interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ add_library(
w32g_res.rc
)

add_dependencies(interface_w32g_res UpdateTim41Version)
target_compile_definitions(interface_w32g_res PRIVATE -DIA_W32GUI -D__W32G__)

# for twsyng
Expand All @@ -140,4 +141,5 @@ add_library(
w32g_res.rc
)

add_dependencies(interface_w32gsyn_res UpdateTim41Version)
target_compile_definitions(interface_w32gsyn_res PRIVATE -DIA_W32G_SYN -D__W32G__ -DTWSYNG32)
20 changes: 13 additions & 7 deletions interface/w32g_res.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <richedit.h>
#include "w32g_res.h"
#include "afxres.h"

#include "version.h"

1 RT_MANIFEST "w32g_visualstyle.manifest"

Expand Down Expand Up @@ -3682,8 +3682,8 @@ IDI_ICON_TIMIDITY ICON "w32g_icon.ico"
//
LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,13,0,0
PRODUCTVERSION 2,13,0,0
FILEVERSION TIMID_VERSION4_COMMA
PRODUCTVERSION TIMID_VERSION4_COMMA
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
Expand All @@ -3697,14 +3697,20 @@ VS_VERSION_INFO VERSIONINFO
VALUE "Comments", "\0"
VALUE "CompanyName", "\0"
VALUE "FileDescription", "timw32g\0"
VALUE "FileVersion", "2, 13, 0, 0\0"
VALUE "FileVersion", TIMID_VERSION_RESSTR
#ifdef TWSYNG32
VALUE "InternalName", "twsyng\0"
VALUE "OriginalFilename", "twsyng.exe\0"
VALUE "ProductName", "TiMidity++ Win32GUI Synthesizer Version\0"
#else
VALUE "InternalName", "timw32g\0"
VALUE "OriginalFilename", "timw32g.exe\0"
VALUE "ProductName", "TiMidity++ Win32GUI Version\0"
#endif
VALUE "LegalCopyright", "Copyright (C) 1999-2002 Masanao Izumo <[email protected]>\r\nCopyright (C) 1995 Tuukka Toivonen <[email protected]>\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "timw32g.exe\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "TiMidity++ Win32GUI Version\0"
VALUE "ProductVersion", "2, 13, 0, 0\0"
VALUE "ProductVersion", TIMID_VERSION
VALUE "SpecialBuild", "\0"
}
}
Expand Down
6 changes: 4 additions & 2 deletions timidity/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

add_definitions(
[[-DVERSION="41.0.211.1"]]
[[-DTIMID_VERSION="41.0.211.1"]]
[[-DDEFAULT_PATH=".\\"]]
)

Expand Down Expand Up @@ -174,6 +172,7 @@ add_executable(
${TIMIDITY_COMMON_SOURCES}
)

add_dependencies(timidity UpdateTim41Version)
target_compile_definitions(timidity PRIVATE -DIA_NCURSES)
target_link_libraries(timidity interface ${TIMIDITY_COMMON_LIBS})

Expand All @@ -185,6 +184,7 @@ add_executable(
${TIMIDITY_COMMON_SOURCES}
)

add_dependencies(twsynsrv UpdateTim41Version)
target_compile_definitions(twsynsrv PRIVATE -DIA_WINSYN -DTWSYNSRV)
target_link_libraries(twsynsrv interface_synsrv ${TIMIDITY_COMMON_LIBS})

Expand All @@ -197,6 +197,7 @@ add_executable(
$<TARGET_OBJECTS:interface_w32g_res>
)

add_dependencies(timw32g UpdateTim41Version)
target_compile_definitions(timw32g PRIVATE -DIA_W32GUI -D__W32G__)
target_link_libraries(timw32g interface_w32g ${TIMIDITY_COMMON_LIBS})
DisableMSManifest(timw32g)
Expand All @@ -210,6 +211,7 @@ add_executable(
$<TARGET_OBJECTS:interface_w32gsyn_res>
)

add_dependencies(twsyng UpdateTim41Version)
target_compile_definitions(twsyng PRIVATE -DIA_W32G_SYN -D__W32G__ -DTWSYNG32)
target_link_libraries(twsyng interface_w32gsyn ${TIMIDITY_COMMON_LIBS})
DisableMSManifest(twsyng)
2 changes: 1 addition & 1 deletion timidity/flac_a.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ static int flac_output_open(const char *fname, const char *comment)

metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
if (metadata[num_metadata]) {
const char *vendor_string = "Encoded with Timidity++-" VERSION "(compiled " __DATE__ ")";
const char *vendor_string = "Encoded with Timidity++";
/* Location=output_name */
memset(&commentry, 0, sizeof(commentry));
FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&commentry, "LOCATION", comment);
Expand Down
2 changes: 1 addition & 1 deletion timidity/speex_a.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ int write_ogg_header(Speex_ctx *ctx, int fd, char *comments)
{
int ret, result;

char *vendor_string = "Encoded with Timidity++-" TIMID_VERSION "(compiled " __DATE__ ")";
char *vendor_string = "Encoded with Timidity++";
int comments_length = strlen(comments);

comment_init(&comments, &comments_length, vendor_string);
Expand Down
4 changes: 1 addition & 3 deletions timidity/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "sysdep.h"
#include "optcode.h"
#include "version.h"

const char *timidity_version = VERSION;
const char *timidity_version = TIMID_VERSION;
46 changes: 0 additions & 46 deletions version.h

This file was deleted.

29 changes: 29 additions & 0 deletions version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
TiMidity++ -- MIDI to WAVE converter and player
Copyright (C) 1999-2002 Masanao Izumo <[email protected]>
Copyright (C) 1995 Tuukka Toivonen <[email protected]>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

*/

#ifndef ___VERSION_H_
#define ___VERSION_H_

#define TIMID_VERSION "${tim41VersionStr}"
#define TIMID_VERSION4_COMMA ${tim41Version3Comma},0
#define TIMID_VERSION_RESSTR "${tim41Version3Comma},0\0"

#endif /* !___VERSION_H_ */

0 comments on commit 3f1b9d8

Please sign in to comment.