@@ -130,6 +130,7 @@ enumerate <- function(x, f, ...) {
130130read_file <- function (path ) {
131131 paste(readLines(path , warn = FALSE ), collapse = " \n " )
132132}
133+
133134trim_whitespace <- function (x ) {
134135 gsub(" ^[[:space:]]*|[[:space:]]*$" , " " , x )
135136}
@@ -145,6 +146,10 @@ trim_whitespace <- function(x) {
145146# ' @export
146147use_configure <- function (package = " ." ) {
147148
149+ # preserve working directory
150+ owd <- getwd()
151+ on.exit(setwd(owd ), add = TRUE )
152+
148153 # find resources
149154 package <- normalizePath(package , winslash = " /" )
150155 resources <- system.file(" resources" , package = " configure" )
@@ -157,12 +162,20 @@ use_configure <- function(package = ".") {
157162 file.copy(resources , dir , recursive = TRUE )
158163
159164 # rename resources directory
160- owd <- setwd(dir )
161- on.exit(setwd(owd ), add = TRUE )
165+ setwd(dir )
162166 file.rename(basename(resources ), basename(package ))
163167
164168 # now, copy these files back into the target directory
165169 file.copy(basename(package ), dirname(package ), recursive = TRUE )
170+
171+ # ensure DESCRIPTION contains 'Biarch: TRUE' for Windows
172+ setwd(package )
173+ DESCRIPTION <- read_file(" DESCRIPTION" )
174+ if (! grepl(" (?:^|\n )Biarch:" , DESCRIPTION )) {
175+ DESCRIPTION <- paste(DESCRIPTION , " Biarch: TRUE" , sep = " \n " )
176+ DESCRIPTION <- gsub(" \n {2,}" , " \n " , DESCRIPTION )
177+ cat(DESCRIPTION , file = " DESCRIPTION" , sep = " \n " )
178+ }
166179}
167180
168181
@@ -190,13 +203,6 @@ if (exists("configure", envir = envir, inherits = FALSE)) {
190203 config <- configure()
191204}
192205
193- # configure .in files
194- inputs <- getOption(" configure.inputs" , default = {
195- list.files(c(" R" , " src" ), pattern = " [.]in$" , full.names = TRUE )
196- })
197- for (input in inputs )
198- configure_file(input , config = config , verbose = TRUE )
199-
200206fmt <- " * successfully configured package '%s'"
201207message(sprintf(fmt , DESCRIPTION $ Package ))
202208
0 commit comments