Skip to content

Commit 62e2f7a

Browse files
committed
configure Makevars vs. Makevars.win
1 parent b7ad4f6 commit 62e2f7a

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

R/config/configure.R

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ enumerate <- function(x, f, ...) {
130130
read_file <- function(path) {
131131
paste(readLines(path, warn = FALSE), collapse = "\n")
132132
}
133+
133134
trim_whitespace <- function(x) {
134135
gsub("^[[:space:]]*|[[:space:]]*$", "", x)
135136
}
@@ -145,6 +146,10 @@ trim_whitespace <- function(x) {
145146
#' @export
146147
use_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-
200206
fmt <- "* successfully configured package '%s'"
201207
message(sprintf(fmt, DESCRIPTION$Package))
202208

R/config/scripts/variables.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
configure <- function() {
22

3+
if (Sys.info()[["sysname"]] == "Windows") {
4+
configure_file("src/Makevars.in", "src/Makevars.win")
5+
} else {
6+
configure_file("src/Makevars.in", "src/Makevars")
7+
}
8+
39
if (getRversion() < "3.4.0") {
410
config <- list(
511
CC = "$(CC)",

src/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.dll
44

55
Makevars
6+
Makevars.win

0 commit comments

Comments
 (0)