From 2973e82a9052e2c4598f3614be917bda874200bd Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sun, 16 Oct 2022 00:59:21 +0200 Subject: [PATCH] wscript: sanitize strings from fetch_*_revision_date early instead of applying str() all over This can perhaps be simplified further when Python2 support is dropped. --- gtk2_ardour/wscript | 14 +++++++------- libs/ardour/wscript | 20 ++++++++++---------- libs/auscan/wscript | 2 +- libs/fst/wscript | 4 ++-- luasession/wscript | 4 ++-- session_utils/wscript | 4 ++-- wscript | 11 +++++------ 7 files changed, 29 insertions(+), 30 deletions(-) diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 4a712942fe..cee20aef67 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -695,7 +695,7 @@ def build(bld): obj = bld(features = 'subst') obj.source = 'ardour.sh.in' - obj.target = 'ardour' + str (bld.env['MAJOR']) + obj.target = 'ardour' + bld.env['MAJOR'] obj.chmod = Utils.O755 obj.dict = wrapper_subst_dict obj.install_path = bld.env['BINDIR'] @@ -827,16 +827,16 @@ def build(bld): # Freedesktop freedesktop_subst_dict = { - 'ARDOUR_EXEC' : str (bld.env['lwrcase_dirname']), - 'ARDOUR_ICON' : str (bld.env['lwrcase_dirname']), + 'ARDOUR_EXEC' : bld.env['lwrcase_dirname'], + 'ARDOUR_ICON' : bld.env['lwrcase_dirname'], 'VERSION': bld.env['VERSION'], - 'DATE': str (bld.env['DATE']), + 'DATE': bld.env['DATE'], } if bld.env['FREEDESKTOP']: obj = bld(features = 'subst') obj.source = 'ardour.desktop.in' - obj.target = str (bld.env['lwrcase_dirname']) + '.desktop' + obj.target = bld.env['lwrcase_dirname'] + '.desktop' obj.chmod = Utils.O644 obj.dict = freedesktop_subst_dict set_subst_dict(obj, freedesktop_subst_dict) @@ -853,14 +853,14 @@ def build(bld): appdata_i18n_xmlin(bld) obj = bld(features = 'subst') obj.source = 'ardour.appdata.xml.in' - obj.target = str (bld.env['lwrcase_dirname']) + '.appdata.xml' + obj.target = bld.env['lwrcase_dirname'] + '.appdata.xml' obj.chmod = Utils.O644 obj.dict = freedesktop_subst_dict set_subst_dict(obj, freedesktop_subst_dict) bld.install_files (os.path.join (bld.env['PREFIX'], 'share/appdata'), obj.target) # install desktop icon files - icon_file_name = str (bld.env['lwrcase_dirname']) + '.png' + icon_file_name = bld.env['lwrcase_dirname'] + '.png' bld.install_as('${PREFIX}/share/icons/hicolor/16x16/apps/' + icon_file_name, 'resources/Ardour-icon_16px.png') bld.install_as('${PREFIX}/share/icons/hicolor/22x22/apps/'+ icon_file_name, 'resources/Ardour-icon_22px.png') bld.install_as('${PREFIX}/share/icons/hicolor/32x32/apps/'+ icon_file_name, 'resources/Ardour-icon_32px.png') diff --git a/libs/ardour/wscript b/libs/ardour/wscript index af390ce61f..a23657c49d 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -406,7 +406,7 @@ def build(bld): obj.vnum = LIBARDOUR_LIB_VERSION obj.install_path = bld.env['LIBDIR'] obj.defines += [ - 'PACKAGE="' + I18N_PACKAGE + str(bld.env['MAJOR']) + '"', + 'PACKAGE="' + I18N_PACKAGE + bld.env['MAJOR'] + '"', 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"', 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"', 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"', @@ -574,7 +574,7 @@ def build(bld): mo_files = bld.path.ant_glob('po/*.mo') for mo in mo_files: lang = os.path.basename(mo.srcpath()).replace('.mo', '') - bld.install_as(os.path.join(bld.env['LOCALEDIR'], lang, 'LC_MESSAGES', I18N_PACKAGE + str(bld.env['MAJOR']) + '.mo'), + bld.install_as(os.path.join(bld.env['LOCALEDIR'], lang, 'LC_MESSAGES', I18N_PACKAGE + bld.env['MAJOR'] + '.mo'), mo) if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'): @@ -592,7 +592,7 @@ def build(bld): else: testcommon.use.extend(['libltc', 'librubberband', 'libfluidsynth']) testcommon.defines = [ - 'PACKAGE="libardour' + str(bld.env['MAJOR']) + 'test"', + 'PACKAGE="libardour' + bld.env['MAJOR'] + 'test"', 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"', 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"', 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"', @@ -668,7 +668,7 @@ def build(bld): load_save_session.target = 'load-save-session' load_save_session.install_path = '' load_save_session.defines = [ - 'PACKAGE="libardour' + str(bld.env['MAJOR']) + 'profile"', + 'PACKAGE="libardour' + bld.env['MAJOR'] + 'profile"', 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"', 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"', 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"', @@ -694,7 +694,7 @@ def build(bld): profilingobj.target = p profilingobj.install_path = '' profilingobj.defines = [ - 'PACKAGE="libardour' + str(bld.env['MAJOR']) + 'profile"', + 'PACKAGE="libardour' + bld.env['MAJOR'] + 'profile"', 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"', 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"', 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"', @@ -712,24 +712,24 @@ def create_ardour_test_program(bld, includes, name, target, sources): # not sure about install path testobj.install_path = bld.env['LIBDIR'] testobj.defines = [ - 'PACKAGE="libardour' + str(bld.env['MAJOR']) + 'test"', + 'PACKAGE="libardour' + bld.env['MAJOR'] + 'test"', 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"', 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"', 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"', ] def i18n(bld): - autowaf.build_i18n(bld, '.', 'libs/ardour', I18N_PACKAGE + str(bld.env['MAJOR']), libardour_sources, + autowaf.build_i18n(bld, '.', 'libs/ardour', I18N_PACKAGE + bld.env['MAJOR'], libardour_sources, 'Paul Davis') def i18n_pot(bld): - autowaf.build_i18n(bld, '.', 'libs/ardour', I18N_PACKAGE + str(bld.env['MAJOR']), libardour_sources, + autowaf.build_i18n(bld, '.', 'libs/ardour', I18N_PACKAGE + bld.env['MAJOR'], libardour_sources, 'Paul Davis') def i18n_po(bld): - autowaf.build_i18n_po(bld, '.', 'libs/ardour', I18N_PACKAGE + str(bld.env['MAJOR']), libardour_sources, + autowaf.build_i18n_po(bld, '.', 'libs/ardour', I18N_PACKAGE + bld.env['MAJOR'], libardour_sources, 'Paul Davis') def i18n_mo(bld): - autowaf.build_i18n_mo(bld, '.', 'libs/ardour', I18N_PACKAGE + str(bld.env['MAJOR']), libardour_sources, + autowaf.build_i18n_mo(bld, '.', 'libs/ardour', I18N_PACKAGE + bld.env['MAJOR'], libardour_sources, 'Paul Davis') diff --git a/libs/auscan/wscript b/libs/auscan/wscript index c77782241a..3564f3c2b2 100644 --- a/libs/auscan/wscript +++ b/libs/auscan/wscript @@ -19,7 +19,7 @@ def build(bld): obj.defines = [ 'AU_SCANNER_APP', 'VERSIONSTRING="' + bld.env['VERSION'] + '"', - 'PACKAGE="' + I18N_PACKAGE + str(bld.env['MAJOR']) + '"', + 'PACKAGE="' + I18N_PACKAGE + bld.env['MAJOR'] + '"', 'LIBARDOUR="' + bld.env['lwrcase_dirname'] + '"', 'LOCALEDIR="' + os.path.join(os.path.normpath(bld.env['DATADIR']), 'locale') + '"', ] diff --git a/libs/fst/wscript b/libs/fst/wscript index dcdad8e4c0..725cd9ec15 100644 --- a/libs/fst/wscript +++ b/libs/fst/wscript @@ -22,7 +22,7 @@ def build(bld): obj.defines = [ 'VST3_SCANNER_APP', 'VERSIONSTRING="' + bld.env['VERSION'] + '"', - 'PACKAGE="' + I18N_PACKAGE + str(bld.env['MAJOR']) + '"', + 'PACKAGE="' + I18N_PACKAGE + bld.env['MAJOR'] + '"', 'LIBARDOUR="' + bld.env['lwrcase_dirname'] + '"', 'LOCALEDIR="' + os.path.join(os.path.normpath(bld.env['DATADIR']), 'locale') + '"', ] @@ -64,7 +64,7 @@ def build(bld): '_POSIX_SOURCE', 'USE_WS_PREFIX', 'VST_SCANNER_APP', - 'PACKAGE="' + I18N_PACKAGE + str(bld.env['MAJOR']) + '"', + 'PACKAGE="' + I18N_PACKAGE + bld.env['MAJOR'] + '"', 'LIBARDOUR="' + bld.env['lwrcase_dirname'] + '"', 'VERSIONSTRING="' + bld.env['VERSION'] + '"', ] diff --git a/luasession/wscript b/luasession/wscript index 578d0bebc5..ec4e540a3b 100644 --- a/luasession/wscript +++ b/luasession/wscript @@ -22,7 +22,7 @@ def build(bld): if bld.env['build_target'] != 'mingw': obj = bld(features = 'subst') obj.source = 'ardour-lua.sh.in' - obj.target = 'ardour' + str (bld.env['MAJOR']) + '-lua' + obj.target = 'ardour' + bld.env['MAJOR'] + '-lua' obj.chmod = Utils.O755 obj.install_path = bld.env['BINDIR'] obj.LIBDIR = os.path.normpath(bld.env['DLLDIR']) @@ -72,6 +72,6 @@ def build(bld): if bld.env['build_target'] == 'mingw': obj.install_path = bld.env['BINDIR'] - obj.target = 'ardour' + str (bld.env['MAJOR']) + '-lua' + obj.target = 'ardour' + bld.env['MAJOR'] + '-lua' else: obj.install_path = bld.env['DLLDIR'] diff --git a/session_utils/wscript b/session_utils/wscript index b33f9b35cc..509181f56c 100644 --- a/session_utils/wscript +++ b/session_utils/wscript @@ -16,7 +16,7 @@ def configure(conf): autowaf.display_msg(conf, 'build session-utils', 'yes') def build_ardour_util(bld, util): - pgmprefix = bld.env['PROGRAM_NAME'].lower() + str(bld.env['MAJOR']) + pgmprefix = bld.env['PROGRAM_NAME'].lower() + bld.env['MAJOR'] # just the normal executable version of the GTK GUI obj = bld (features = 'cxx c cxxprogram') @@ -66,7 +66,7 @@ def build(bld): if not "dummy" in bld.env['BACKENDS']: return - pgmprefix = bld.env['PROGRAM_NAME'].lower() + str(bld.env['MAJOR']) + pgmprefix = bld.env['PROGRAM_NAME'].lower() + bld.env['MAJOR'] utils = bld.path.ant_glob('[a-z]*.cc', excl=['example.cc', 'common.cc']) diff --git a/wscript b/wscript index 7e4e1cc485..b64efdb391 100644 --- a/wscript +++ b/wscript @@ -222,13 +222,14 @@ def set_version (from_file = False): rev, rev_date = fetch_git_revision_date() else: rev, rev_date = fetch_tarball_revision_date() + rev_date = sanitize(rev_date) # # rev is now of the form MAJOR.MINOR[-rcX]-rev-commit # or, if right at the same rev as a release, MAJOR.MINOR[-rcX] # - parts = rev.split ('.', 1) + parts = sanitize(rev).split ('.', 1) MAJOR = parts[0] other = parts[1].split('-', 1) MINOR = other[0] @@ -237,10 +238,8 @@ def set_version (from_file = False): else: MICRO = '0' - V = MAJOR + '.' + MINOR + '.' + MICRO - - VERSION = sanitize(V) - PROGRAM_VERSION = sanitize(MAJOR) + VERSION = MAJOR + '.' + MINOR + '.' + MICRO + PROGRAM_VERSION = MAJOR def fetch_gcc_version (CC): cmd = "%s --version" % CC @@ -1057,7 +1056,7 @@ def configure(conf): if Options.options.lv2dir: conf.env['LV2DIR'] = Options.options.lv2dir else: - conf.env['LV2DIR'] = os.path.join(conf.env['LIBDIR'], 'ardour' + str(conf.env['MAJOR']), 'LV2') + conf.env['LV2DIR'] = os.path.join(conf.env['LIBDIR'], 'ardour' + conf.env['MAJOR'], 'LV2') conf.env['LV2DIR'] = os.path.normpath(conf.env['LV2DIR'])