@@ -309,13 +309,12 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
309309 descFile <- file.path(pkgdir ," DESCRIPTION" )
310310 if (! file.exists(descFile ))
311311 stop(" pkgdir must refer to the directory containing an R package" )
312-
313- pkgInfo <- tools ::: .split_description(tools ::: .read_description(descFile ))
314- pkgname <- as.character(pkgInfo $ DESCRIPTION [" Package" ])
315- depends <- unique(names(pkgInfo $ Depends ))
316- if (is.null(depends ))
317- depends <- character ()
318-
312+ pkgDesc <- read.dcf(descFile )[1 ,]
313+ pkgname = .readPkgDescField(pkgDesc , " Package" )
314+ depends <- .readPkgDescField(pkgDesc , " Depends" , character ())
315+ depends <- unique(.splitDepends(depends ))
316+ depends <- depends [depends != " R" ]
317+
319318 # determine source directory
320319 srcDir <- file.path(pkgdir , " src" )
321320 if (! file.exists(srcDir ))
@@ -330,15 +329,15 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
330329 cppFiles <- list.files(srcDir , pattern = glob2rx(" *.c*" ))
331330
332331 # derive base names (will be used for modules)
333- cppFileBasenames <- tools ::: file_path_sans_ext(cppFiles )
332+ cppFileBasenames <- tools :: file_path_sans_ext(cppFiles )
334333
335334 # expend them to their full paths
336335 cppFiles <- file.path(srcDir , cppFiles )
337336 cppFiles <- normalizePath(cppFiles , winslash = " /" )
338337
339338 # generate the includes list based on LinkingTo. Specify plugins-only
340339 # because we only need as/wrap declarations
341- linkingTo <- as.character( pkgInfo $ DESCRIPTION [ " LinkingTo" ] )
340+ linkingTo <- .readPkgDescField( pkgDesc , " LinkingTo" )
342341 includes <- .linkingToIncludes(linkingTo , TRUE )
343342
344343 # if a master include file is defined for the package then include it
@@ -450,6 +449,24 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
450449 }
451450}
452451
452+ # Split the depends field of a package description
453+ .splitDepends <- function (x ) {
454+ if (! length(x ))
455+ return (character ())
456+ x <- unlist(strsplit(x , " ," ))
457+ x <- sub(" [[:space:]]+$" , " " , x )
458+ x <- unique(sub(" ^[[:space:]]*(.*)" , " \\ 1" , x ))
459+ sub(" ^([[:alnum:].]+).*$" , " \\ 1" , x )
460+ }
461+
462+ # read a field from a named package description character vector
463+ .readPkgDescField <- function (pkgDesc , name , default = NULL ) {
464+ if (name %in% names(pkgDesc ))
465+ pkgDesc [[name ]]
466+ else
467+ default
468+ }
469+
453470
454471# Get the inline plugin for the specified package (return NULL if none found)
455472.getInlinePlugin <- function (package ) {
0 commit comments