File: bundle_data_files.pl

package info (click to toggle)
kde-dev-scripts 4%3A18.08.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,496 kB
  • sloc: perl: 15,466; lisp: 5,627; sh: 4,157; python: 3,892; ruby: 2,158; makefile: 16; sed: 9
file content (73 lines) | stat: -rwxr-xr-x 2,241 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/perl -w

# Changes from installing xmlgui5 files to bundling them into the resource.

use strict;
my $file = "CMakeLists.txt";
my $xmlgui_files;
my %qrc_files;
my %filesForApp = ();
my $modified = 0;
open(my $FILE1, "<", $file) || die;
while (<$FILE1>) {
    if (/qt5_add_resources\s*\(.*([\w]+\.qrc)/i) {
        $qrc_files{$1} = 1; # TODO the key should be the app name, and $1 should be the value
    }
}
close($FILE1);

open(my $FILE, "<", $file) || die;
my @l = map {
  my $orig = $_;

  if (/install\s*\(\s*FILES \s*([\w\-\/\s]*\.rc)\s*DESTINATION \s*\$\{KDE_INSTALL_KXMLGUI5DIR\}\/(\w+)/i) {
      $xmlgui_files = $1;
      my $appname = $2;
      print STDERR "Found xmlgui files " . $xmlgui_files . " in $appname\n";
      $filesForApp{$appname} = $xmlgui_files;
      $_ = ""; # delete line

      # while here, insert line about new qrc
      my $qrc_file = "$appname.qrc";
      if (not defined $qrc_files{$qrc_file}) {
          $qrc_files{$qrc_file} = 1;
          $_ = "qt5_add_resources(${appname}_SRCS $qrc_file) #TODO move this to the right place, check the name of the variable\n";
      }
  }

  $modified ||= $orig ne $_;
  $_;
} <$FILE>;

if ($modified) {
    open (my $OUT, ">", $file);
    print $OUT @l;
    close ($OUT);
}

if (defined $xmlgui_files) {
    foreach my $appname (keys(%filesForApp)) {
        my $qrc_file = "$appname.qrc";
        if (not -e $qrc_file) {
            open (my $QRC, ">", $qrc_file);
            print $QRC "<RCC>\n";
            print $QRC "<qresource prefix=\"/kxmlgui5/$appname\">\n";
            foreach my $xmlguifile (split(/ /, $filesForApp{$appname})) {
                print $QRC "<file>$xmlguifile</file>\n";
            }
            print $QRC "</qresource>\n";
            print $QRC "</RCC>\n";
            close($QRC);
            system("git add $qrc_file");
        } else {
            print STDERR "TODO: add these lines into $qrc_file, under prefix /xmlgui5/$appname\n";

            print STDERR "<qresource prefix=\"/kxmlgui5/$appname\">\n";
            foreach my $xmlguifile (split(/ /, $filesForApp{$appname})) {
                print STDERR "<file>$xmlguifile</file>\n";
            }
            print STDERR "</qresource>\n";
        }
    }
}