The R Project SVN R

Rev

Rev 38599 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 38599 Rev 38612
Line 35... Line 35...
35
use Text::Wrap;
35
use Text::Wrap;
36
 
36
 
37
## Don't buffer output.
37
## Don't buffer output.
38
$| = 1;
38
$| = 1;
39
 
39
 
40
my $revision = ' $Rev: 38599 $ ';
40
my $revision = ' $Rev: 38612 $ ';
41
my $version;
41
my $version;
42
my $name;
42
my $name;
43
$revision =~ / ([\d\.]*) /;
43
$revision =~ / ([\d\.]*) /;
44
$version = $1;
44
$version = $1;
45
($name = $0) =~ s|.*/||;
45
($name = $0) =~ s|.*/||;
Line 111... Line 111...
111
    &R_getenv("_R_CHECK_WEAVE_VIGNETTES_", "TRUE");
111
    &R_getenv("_R_CHECK_WEAVE_VIGNETTES_", "TRUE");
112
my $R_check_subdirs_strict =
112
my $R_check_subdirs_strict =
113
    &R_getenv("_R_CHECK_SUBDIRS_STRICT_", "default");
113
    &R_getenv("_R_CHECK_SUBDIRS_STRICT_", "default");
114
my $R_check_Rd_xrefs =
114
my $R_check_Rd_xrefs =
115
    &R_getenv("_R_CHECK_RD_XREFS_", "TRUE");
115
    &R_getenv("_R_CHECK_RD_XREFS_", "TRUE");
-
 
116
my $R_check_use_codetools =
-
 
117
    &R_getenv("_R_CHECK_USE_CODETOOLS_", "FALSE");
-
 
118
 
116
 
119
 
117
## Maybe move basic configuration (and documentation) to
120
## Maybe move basic configuration (and documentation) to
118
##   &file_path($R::Vars::R_HOME, "etc", "check.conf")
121
##   &file_path($R::Vars::R_HOME, "etc", "check.conf")
119
## eventually ...
122
## eventually ...
120
for my $file ($opt_rcfile) {
123
for my $file ($opt_rcfile) {
Line 145... Line 148...
145
    &config_val_to_logical($R_check_all_non_ISO_C);
148
    &config_val_to_logical($R_check_all_non_ISO_C);
146
$R_check_weave_vignettes =
149
$R_check_weave_vignettes =
147
    &config_val_to_logical($R_check_weave_vignettes);
150
    &config_val_to_logical($R_check_weave_vignettes);
148
$R_check_Rd_xrefs =
151
$R_check_Rd_xrefs =
149
    &config_val_to_logical($R_check_Rd_xrefs);
152
    &config_val_to_logical($R_check_Rd_xrefs);
-
 
153
$R_check_use_codetools =
-
 
154
    &config_val_to_logical($R_check_use_codetools);
150
 
155
 
151
$opt_subdirs = $R_check_subdirs_strict if $opt_subdirs eq "";
156
$opt_subdirs = $R_check_subdirs_strict if $opt_subdirs eq "";
152
 
157
 
153
my $startdir = R_cwd();
158
my $startdir = R_cwd();
154
$opt_outdir = $startdir unless $opt_outdir;
159
$opt_outdir = $startdir unless $opt_outdir;
Line 1134... Line 1139...
1134
	else {
1139
	else {
1135
	    $log->result("OK");
1140
	    $log->result("OK");
1136
	}
1141
	}
1137
    }
1142
    }
1138
 
1143
 
1139
    ## Check usage of library.dynam (if any).
-
 
1140
 
-
 
1141
    if(!$is_base_pkg && (-d "R")) {
-
 
1142
	## <FIXME>
-
 
1143
	## This really needs to be changed:
-
 
1144
	## * If a package is installed for lazy-loading, we don't really
-
 
1145
	##   check the code.
-
 
1146
	## * We should also take care of library.dynam.unload().
-
 
1147
	## * What if someone used 'foo.so'?
-
 
1148
	## Etc ...
-
 
1149
	## Write an R function for doing this (.check_package_code_shlib
-
 
1150
	## maybe) and move into the "checking R files for possible
-
 
1151
	## problems" section ...
-
 
1152
	## </FIXME>
-
 
1153
	$log->checking("R files for library.dynam");
-
 
1154
	my @R_files;
-
 
1155
	if($opt_install) {
-
 
1156
	    ## Only need to check the installed file (if installed).
-
 
1157
	    @R_files = (&file_path($library, $pkgname, "R", $pkgname));
-
 
1158
	}
-
 
1159
	else {
-
 
1160
	    ## Otherwise (if the package was not installed), we need to
-
 
1161
	    ## check all R code files.
-
 
1162
	    ## <NOTE>
-
 
1163
	    ## We could/should really check all OS specific subdirs here.
-
 
1164
	    @R_files = &list_files_with_type("R", "code");
-
 
1165
	    ## </NOTE>
-
 
1166
	}
-
 
1167
	my $any = 0;
-
 
1168
	my $ext;
-
 
1169
	foreach my $file (@R_files) {
-
 
1170
	    last if $any;
-
 
1171
	    open(FILE, "< $file")
-
 
1172
	      or die "Error: cannot open file '$file' for reading\n";
-
 
1173
	    while(<FILE>) {
-
 
1174
		if(/library.dynam\(\"(.*?)\"/o) {
-
 
1175
		    my $arg = $1;
-
 
1176
		    if($arg =~ /\.(so|sl|dll)$/) {
-
 
1177
			$ext = $1;
-
 
1178
			$any++;
-
 
1179
			last;
-
 
1180
		    }
-
 
1181
		}
-
 
1182
	    }
-
 
1183
	    close(FILE);
-
 
1184
	}
-
 
1185
	if($any == 0) {
-
 
1186
	    $log->result("OK");
-
 
1187
	}
-
 
1188
	else {
-
 
1189
	    $log->error();
-
 
1190
	    $log->print("library.dynam() used with extension '.$ext'.\n");
-
 
1191
	    $log->print(wrap("", "",
-
 
1192
			     ("The system-specific extension for",
-
 
1193
			      "shared libraries should not be added.\n",
-
 
1194
			      "See ?library.dynam\n")));
-
 
1195
	    exit(1);
-
 
1196
	}
-
 
1197
    }
-
 
1198
 
-
 
1199
    ## Check whether methods have all arguments of the corresponding
1144
    ## Check whether methods have all arguments of the corresponding
1200
    ## generic.
1145
    ## generic.
1201
 
1146
 
1202
    if(-d "R") {
1147
    if(-d "R") {
1203
	$log->checking("S3 generic/method consistency");
1148
	$log->checking("S3 generic/method consistency");
Line 1300... Line 1245...
1300
    ## scheduled for integration into base R eventually).
1245
    ## scheduled for integration into base R eventually).
1301
 
1246
 
1302
    ## Activated only via setting the internal environment variable
1247
    ## Activated only via setting the internal environment variable
1303
    ## _R_CHECK_USE_CODETOOLS_ to something "true".
1248
    ## _R_CHECK_USE_CODETOOLS_ to something "true".
1304
 
1249
 
1305
    my $R_check_use_codetools =
1250
    ## Also do the library.dynam() tests here.
1306
	&R_getenv("_R_CHECK_USE_CODETOOLS_", "FALSE");
-
 
1307
    $R_check_use_codetools =
-
 
1308
	&config_val_to_logical($R_check_use_codetools);
-
 
1309
 
1251
 
1310
    if($R_check_use_codetools && $opt_install && (-d "R")) {
1252
    if(-d "R") {
1311
	$log->checking("R code for possible problems");
1253
	$log->checking("R code for possible problems");
1312
 
1254
 
-
 
1255
	my $any;
-
 
1256
 
1313
	my $Rcmd = "options(warn=1)\n";
1257
	if(!$is_base_pkg) {
1314
	$Rcmd .= "tools:::.check_code_usage_in_package(package = \"${pkgname}\")\n";
1258
	    my $Rcmd = "tools:::.check_package_code_shlib(\"R\")";
1315
	my @out = R_runR($Rcmd, "${R_opts} --quiet",
1259
	    my @out = R_runR($Rcmd, "${R_opts} --quiet");
1316
                         "R_DEFAULT_PACKAGES='utils,grDevices,graphics,stats'");
-
 
1317
	@out = grep(!/^\>/, @out);
1260
	    @out = grep(!/^\>/, @out);
1318
	if(scalar(@out) > 0) {
1261
	    if(scalar(@out) > 0) {
1319
	    $log->warning();
1262
		$log->error();
-
 
1263
		$log->print(wrap("", "",
-
 
1264
				 "Incorrect (un)loading of package",
-
 
1265
				 "shared libraries.\n"));
1320
	    $log->print(join("\n", @out) . "\n");
1266
		$log->print(join("\n", @out) . "\n");
-
 
1267
		$log->print(wrap("", "",
-
 
1268
				 ("The system-specific extension for",
-
 
1269
				  "shared libraries must not be added.\n",
-
 
1270
				  "See ?library.dynam.\n")));
-
 
1271
		
-
 
1272
		exit(1);
-
 
1273
	    }
1321
	}
1274
	}
-
 
1275
 
-
 
1276
	if($R_check_use_codetools && $opt_install) {
-
 
1277
	    my $Rcmd = "options(warn=1)\n";
-
 
1278
	    $Rcmd .= "tools:::.check_code_usage_in_package(package = \"${pkgname}\")\n";
-
 
1279
	    my @out = R_runR($Rcmd, "${R_opts} --quiet",
-
 
1280
			     "R_DEFAULT_PACKAGES='utils,grDevices,graphics,stats'");
-
 
1281
	    @out = grep(!/^\>/, @out);
-
 
1282
	    if(scalar(@out) > 0) {
1322
	else {
1283
		$any++;
1323
	    $log->result("OK");
1284
		$log->warning();
-
 
1285
		$log->print(join("\n", @out) . "\n");
-
 
1286
	    }
1324
	}
1287
	}
-
 
1288
	
-
 
1289
	$log->result("OK") unless $any;
1325
    }
1290
    }
1326
 
1291
 
1327
    ## Check R documentation files.
1292
    ## Check R documentation files.
1328
 
1293
 
1329
    my @msg_writing_Rd
1294
    my @msg_writing_Rd