[kde-dev-scripts] kf5: Add script to convert to new KDEInstallDirs variable names.

Alex Merry alex.merry at kde.org
Sat Jan 10 16:26:06 UTC 2015


Git commit 98d6363ad17559b87e8b203954381727ebd305d8 by Alex Merry.
Committed on 10/01/2015 at 16:23.
Pushed by alexmerry into branch 'master'.

Add script to convert to new KDEInstallDirs variable names.

This is a separate script to adapt_cmakelists_file.pl, because it
produces CMakeLists.txt files that depend on e-c-m 1.6.0 or later, and
that may not be acceptable for all projects.

CCMAIL: kde-buildsystem at kde.org
CCMAIL: kde-frameworks-devel at kde.org

M  +1    -1    kf5/adapt_cmakelists_file.pl
A  +98   -0    kf5/cmakelists_install_vars.pl

http://commits.kde.org/kde-dev-scripts/98d6363ad17559b87e8b203954381727ebd305d8

diff --git a/kf5/adapt_cmakelists_file.pl b/kf5/adapt_cmakelists_file.pl
index 0834d4e..4f4cb76 100755
--- a/kf5/adapt_cmakelists_file.pl
+++ b/kf5/adapt_cmakelists_file.pl
@@ -492,7 +492,7 @@ my @l = map {
      if (my ($begin, $end) = $_ =~ $regexp) {
         $_ = $begin . "\${KNOTIFYRC_INSTALL_DIR}" . $end . "\n";
         $modified = 1;
-     } elsif (not /KNOTIFYRC_INSTALL_DIR/) {
+     } elsif (not /KNOTIFYRC_INSTALL_DIR/ and not /_INSTALL_KNOTIFY5RCDIR/) {
         my $line = $_;
         $line =~ s/\s*$//;
         print "Could not fix a .notifyrc file installation call ($line)\n"
diff --git a/kf5/cmakelists_install_vars.pl b/kf5/cmakelists_install_vars.pl
new file mode 100755
index 0000000..8926048
--- /dev/null
+++ b/kf5/cmakelists_install_vars.pl
@@ -0,0 +1,98 @@
+#!/usr/bin/perl -w
+
+# Alex Merry <alex.merry at kde.org> 2015
+#
+# Modifies CMakeLists.txt in current directory to use the new (as of
+# extra-cmake-modules 1.6.0) install variables.
+#
+# Do not use unless your project depends on extra-cmake-modules 1.6.0
+# or later.
+
+use strict;
+my $file = "CMakeLists.txt";
+
+my %old_var_map = (
+    BUNDLE_INSTALL_DIR => 'BUNDLEDIR',
+    EXEC_INSTALL_PREFIX => 'EXECROOTDIR',
+    BIN_INSTALL_DIR => 'BINDIR',
+    SBIN_INSTALL_DIR => 'SBINDIR',
+    LIB_INSTALL_DIR => 'LIBDIR',
+    LIBEXEC_INSTALL_DIR => 'LIBEXECDIR',
+    KF5_LIBEXEC_INSTALL_DIR => 'LIBEXECDIR_KF5',
+    CMAKECONFIG_INSTALL_PREFIX => 'CMAKEPACKAGEDIR',
+    QT_PLUGIN_INSTALL_DIR => 'QTPLUGINDIR',
+    PLUGIN_INSTALL_DIR => 'PLUGINDIR',
+    IMPORTS_INSTALL_DIR => 'QTQUICKIMPORTSDIR',
+    QML_INSTALL_DIR => 'QMLDIR',
+    INCLUDE_INSTALL_DIR => 'INCLUDEDIR',
+    KF5_INCLUDE_INSTALL_DIR => 'INCLUDEDIR_KF5',
+    DATA_INSTALL_DIR => 'DATADIR',
+    KF5_DATA_INSTALL_DIR => 'DATADIR_KF5',
+    HTML_INSTALL_DIR => 'DOCBUNDLEDIR',
+    KCFG_INSTALL_DIR => 'KCFGDIR',
+    KCONF_UPDATE_INSTALL_DIR => 'KCONFUPDATEDIR',
+    SERVICES_INSTALL_DIR => 'KSERVICES5DIR',
+    SERVICETYPES_INSTALL_DIR => 'KSERVICETYPES5DIR',
+    KXMLGUI_INSTALL_DIR => 'KXMLGUI5DIR',
+    KNOTIFYRC_INSTALL_DIR => 'KNOTIFY5RCDIR',
+    ICON_INSTALL_DIR => 'ICONDIR',
+    LOCALE_INSTALL_DIR => 'LOCALEDIR',
+    SOUND_INSTALL_DIR => 'SOUNDDIR',
+    TEMPLATES_INSTALL_DIR => 'TEMPLATEDIR',
+    WALLPAPER_INSTALL_DIR => 'WALLPAPERDIR',
+    XDG_APPS_INSTALL_DIR => 'APPDIR',
+    XDG_DIRECTORY_INSTALL_DIR => 'DESKTOPDIR',
+    XDG_MIME_INSTALL_DIR => 'MIMEDIR',
+    MAN_INSTALL_DIR => 'MANDIR',
+    DBUS_INTERFACES_INSTALL_DIR => 'DBUSINTERFACEDIR',
+    DBUS_SERVICES_INSTALL_DIR => 'DBUSSERVICEDIR',
+    DBUS_SYSTEM_SERVICES_INSTALL_DIR => 'DBUSSYSTEMSERVICEDIR',
+    SYSCONF_INSTALL_DIR => 'SYSCONFDIR',
+    CONFIG_INSTALL_DIR => 'CONFDIR',
+    AUTOSTART_INSTALL_DIR => 'AUTOSTARTDIR',
+    SHARE_INSTALL_PREFIX => 'DATAROOTDIR',
+);
+
+my @new_var_suffixes = (
+    'METAINFODIR',
+    'INFODIR',
+    'DBUSDIR',
+    'LOCALSTATEDIR',
+    'SHAREDSTATEDIR',
+    'LIBEXECDIR_KF5',
+);
+push(@new_var_suffixes, values %old_var_map);
+
+my %extra_changes = (
+    INSTALL_TARGETS_DEFAULT_ARGS => 'KDE_INSTALL_TARGETS_DEFAULT_ARGS'
+);
+
+open(my $FILE, "<", $file) || die;
+my $modified = 0;
+my @l = map {
+    my $orig = $_;
+    my $updated = $_;
+
+    # all variables we care about have "INSTALL" in their name
+    if (/INSTALL/) {
+        while (my ($oldvar,$suffix) = each(%old_var_map)) {
+            $updated =~ s/\b$oldvar\b/KDE_INSTALL_$suffix/;
+        }
+        foreach (@new_var_suffixes) {
+            $updated =~ s/\bCMAKE_INSTALL_$_\b/KDE_INSTALL_$_/;
+        }
+        while (my ($oldvalue,$newvalue) = each(%extra_changes)) {
+            $updated =~ s/\b$oldvalue\b/$newvalue/;
+        }
+    }
+
+    $modified ||= $orig ne $updated;
+    $updated;
+} <$FILE>;
+
+if ($modified) {
+    open (my $OUT, ">", $file);
+    print $OUT @l;
+    close ($OUT);
+}
+# vi:et:sts=4:sw=4


More information about the Kde-frameworks-devel mailing list