~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to scripts/cmakelint.pl

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-06-19 11:45:17 UTC
  • mto: This revision was merged to the branch mainline in revision 40.
  • Revision ID: james.westby@ubuntu.com-20080619114517-ve7244weow3tvtjg
Tags: upstream-4.0.83
ImportĀ upstreamĀ versionĀ 4.0.83

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
use Cwd 'abs_path';
34
34
 
35
35
my($Prog) = 'cmakelint.pl';
36
 
my($Version) = '1.8';
 
36
my($Version) = '1.10';
37
37
 
38
38
my($help) = '';
39
39
my($version) = '';
73
73
  $top_of_module=1 if ($apath =~ m+/kdereview/CMakeLists.txt+);
74
74
  $top_of_module=1 if ($apath =~ m+/playground/[a-zA-Z_1-9]*/CMakeLists.txt+);
75
75
  $top_of_module=1 if ($apath =~ m+/extragear/[a-zA-Z_1-9]*/CMakeLists.txt+);
76
 
  $top_of_module=1 if ($apath =~ m+/kde(libs|pimlibs|base|accessibility|addons|admin|artwork|bindings|edu|games|graphics|multimedia|network|pim|sdk|toys|utils|develop|devplatform|webdev)/CMakeLists.txt+);
 
76
  $top_of_module=1 if ($apath =~ m+/kdebase/(apps|runtime|workspace)/CMakeLists.txt+);
 
77
  $top_of_module=1 if ($apath =~ m+/kde(libs|pimlibs|base|base-apps|base-runtime|base-workspace|accessibility|addons|admin|artwork|bindings|edu|games|graphics|multimedia|network|pim|sdk|toys|utils|develop|devplatform|webdev|plasmoids)/CMakeLists.txt+);
77
78
 
78
79
  my($top_of_project)=0;
79
80
  $top_of_project=1 if ($apath =~ m+/koffice/[a-zA-Z_1-9]*/CMakeLists.txt+);
80
81
  $top_of_project=1 if ($apath =~ m+/kdereview/[a-zA-Z_1-9]*/CMakeLists.txt+);
81
82
  $top_of_project=1 if ($apath =~ m+/playground/[a-zA-Z_1-9]*/[a-zA-Z_1-9]*/CMakeLists.txt+);
82
83
  $top_of_project=1 if ($apath =~ m+/extragear/[a-zA-Z_1-9]*/[a-zA-Z_1-9]*/CMakeLists.txt+);
83
 
  $top_of_project=1 if ($apath =~ m+/kde(libs|pimlibs|base|accessibility|addons|admin|artwork|bindings|edu|games|graphics|multimedia|network|pim|sdk|toys|utils|develop|devplatform|webdev)/[a-zA-Z_1-9]*/CMakeLists.txt+);
 
84
  $top_of_project=1 if ($apath =~ m+/kde(libs|pimlibs|base|accessibility|addons|admin|artwork|bindings|edu|games|graphics|multimedia|network|pim|sdk|toys|utils|develop|devplatform|webdev|plasmoids)/[a-zA-Z_1-9]*/CMakeLists.txt+);
84
85
  $top_of_project=0 if ($apath =~ m+/(cmake|pics)/+);
85
86
 
86
87
  my(@lines) = <IN>;
125
126
      }
126
127
      if ($line =~ m/macro_log_feature\(\s*([A-Z0-9_]*).*\)/i) {
127
128
        $pack = lc($1);
128
 
        $pack = "libxslt" if ($pack eq "xsltproc_executable");
129
 
        if ($pack !~ m/^(have|pcre|boost|gpgme|x11|strigiqtdbusclient)_/) {
 
129
        if ($pack !~ m/^(have|pcre|boost|gpgme|x11|strigiqtdbusclient|xsltproc)_/ &&
 
130
            $pack !~ m/true/i && $pack !~ m/false/i) {
130
131
          $pack =~ s/_found//;
 
132
          $pack =~ s/_video//;
131
133
          if (!defined($optpacks{$pack}{'name'})) {
132
134
            $issues++;
133
135
            &printIssue($line,$linecnt,"macro_log_feature($pack) used without macro_optional_find_package()");
145
147
                          '[[^:print:]]{\$',
146
148
                          'non-printable characters detected');
147
149
 
148
 
    if (!$top_of_module && $in !~ m+kdebase/[a-z]*/CMakeLists.txt+ && $in !~ m+/doc/CMakeLists.txt+) {
149
 
      $issues +=
150
 
        &checkLine($line,$linecnt,
151
 
                   '[Mm][Aa][Cc][Rr][Oo]_[Oo][Pp][Tt][Ii][Oo][Nn][Aa][Ll]_[Aa][Dd][Dd]_[Ss][Uu][Bb][Dd][Ii][Rr][Ee][Cc][Tt][Oo][Rr][Yy]',
152
 
                   'replace macro_optional_add_subdirectory with add_subdirectory');
153
 
    }
154
 
 
155
150
    $issues += &checkLine($line,$linecnt,
156
151
                          '[Kk][Dd][Ee]4_[Aa][Uu][Tt][Oo][Mm][Oo][Cc]',
157
152
                          'KDE4_AUTOMOC() is obsolete. Remove it.');
179
174
    $issues += &checkLine($line,$linecnt,
180
175
                          'DESTINATION[[:space:]]/lib/kde[[:digit:]]',
181
176
                          'replace /lib/kde" with "${PLUGIN_INSTALL_DIR}"');
182
 
    $issues += &checkLine($line,$linecnt,
183
 
                          'DESTINATION[[:space:]]lib',
184
 
                          'replace "lib" with "${LIB_INSTALL_DIR}"');
 
177
 
 
178
    if ($line !~ m/kdeinit/) {
 
179
      $issues += &checkLine($line,$linecnt,
 
180
                            'DESTINATION[[:space:]]\$\{LIB_INSTALL_DIR\}\s*\)',
 
181
                            'replace "DESTINATION ${LIB_INSTALL_DIR}" with "${INSTALL_TARGETS_DEFAULT_ARGS}"');
 
182
      $issues += &checkLine($line,$linecnt,
 
183
                            'DESTINATION[[:space:]]lib',
 
184
                            'replace "DESTINATION lib" with "${INSTALL_TARGETS_DEFAULT_ARGS}"');
 
185
    }
 
186
 
185
187
    $issues += &checkLine($line,$linecnt,
186
188
                          'DESTINATION[[:space:]]\${LIB_INSTALL_DIR}/\$',
187
189
                          'replace "${LIB_INSTALL_DIR}/${...}" with "${LIB_INSTALL_DIR}/realname"');
193
195
                          'DESTINATION[[:space:]]\${INCLUDE_INSTALL_DIR}/\$',
194
196
                          'replace "${INCLUDE_INSTALL_DIR}/${...}" with "${INCLUDE_INSTALL_DIR}/realname"');
195
197
 
196
 
    $issues += &checkLine($line,$linecnt,
197
 
                          'DESTINATION[[:space:]]/*bin/*',
198
 
                          'replace "bin" or "/bin" with "${BIN_INSTALL_DIR}"');
 
198
    if ($line !~ m/PROGRAMS/ && $line !~ m/FILES/ &&
 
199
        $line !~ m/PERMISSIONS/ &&
 
200
        $line !~ m/OWNER/ && $line !~ m/GROUP/ && $line !~ m/WORLD/) {
 
201
      $issues += &checkLine($line,$linecnt,
 
202
                            'DESTINATION[[:space:]]\$\{BIN_INSTALL_DIR\}\s*\)',
 
203
                            'replace "DESTINATION ${BIN_INSTALL_DIR}" with "${INSTALL_TARGETS_DEFAULT_ARGS}"');
 
204
 
 
205
      $issues += &checkLine($line,$linecnt,
 
206
                            'DESTINATION[[:space:]]/*bin/*',
 
207
                            'replace "DESTINATION bin" or "/bin" with "${INSTALL_TARGETS_DEFAULT_ARGS}"');
 
208
    }
 
209
 
199
210
    $issues += &checkLine($line,$linecnt,
200
211
                          'DESTINATION[[:space:]]\${BIN_INSTALL_DIR}/\$',
201
212
                          'replace "${BIN_INSTALL_DIR}/${...}" with "${BIN_INSTALL_DIR}/realname"');
265
276
                          'INSTALL_FILES[[:space:]]*\(',
266
277
                          'replace "install_files" with "install(FILES...)');
267
278
    $issues += &checkLine($line,$linecnt,
268
 
                          'FILES[[:space:]]DESTINATION',
 
279
                          '\sFILES\sDESTINATION',
269
280
                          'missing list of files between FILES and DESTINATION');
270
281
    $issues += &checkLine($line,$linecnt,
271
282
                          'TARGETS[[:space:]]DESTINATION',
272
283
                          'missing list of files between TARGETS and DESTINATION');
273
284
 
274
285
    $issues += &checkLine($line,$linecnt,
 
286
                          'DESTINATION\s\$\{INSTALL_TARGETS_DEFAULT_ARGS\}',
 
287
                          'remove DESTINATION keyword before ${INSTALL_TARGETS_DEFAULT_ARGS}');
 
288
 
 
289
    $issues += &checkLine($line,$linecnt,
275
290
                          'macro_bool_to_01[[:space:]]*\(.*[[:space:]][[:digit:]][[:space:]]*\)',
276
291
                          'do not use a digit as a variable');
277
292
    $issues += &checkLine($line,$linecnt,
575
590
                   '^\s*[Ff][Ii][Nn][Dd]_[Pp][Aa][Cc][Kk][Aa][Gg][Ee]\s*\(\s*[A-Za-z0-9_]*\s*\)',
576
591
                   'Use the REQUIRED keyword with find_package()');
577
592
    }
 
593
 
 
594
    my($subdir);
 
595
    if ($line =~ m+macro_optional_add_subdirectory\s*\(\s*(\S*)\s*\)+) {
 
596
      $subdir = $1;
 
597
      if (!&canBeOptional($subdir) || ($top_of_module && ($in_kdelibs || $in_kdepimlibs))) {
 
598
        if (!&mustBeOptional($subdir)) {
 
599
          $issues++;
 
600
          &printIssue($line,$linecnt,"Replace macro_optional_add_subdirectory($subdir) with add_subdirectory($subdir)");
 
601
        }
 
602
      }
 
603
    }
 
604
    if ($line =~ m+^\s*add_subdirectory\s*\(\s*(\S*)\s*\)+) {
 
605
      $subdir = $1;
 
606
      if (&mustBeOptional($subdir)) {
 
607
        $issues++;
 
608
        &printIssue($line,$linecnt,"Replace add_subdirectory($subdir) with macro_optional_add_subdirectory($subdir)");
 
609
      }
 
610
    }
578
611
  }
579
612
 
580
613
  #look for "missing" stuff
646
679
  }
647
680
}
648
681
 
 
682
sub canBeOptional {
 
683
  my($guy) = @_;
 
684
 
 
685
  my($ret) = 1;
 
686
  $ret = 0
 
687
    if ($guy =~ m/^lib/ ||
 
688
        $guy =~ m/lib$/ ||
 
689
        $guy =~ m/^cmake$/
 
690
       );
 
691
  return $ret;
 
692
}
 
693
 
 
694
sub mustBeOptional {
 
695
  my($guy) = @_;
 
696
 
 
697
  my($ret) = 0;
 
698
  $ret = 1
 
699
    if ($guy =~ m/^doc$/);
 
700
  return $ret;
 
701
}
 
702
 
649
703
#==============================================================================
650
704
# Help function: print help message and exit.
651
705
sub Help {