Skip to content

Commit

Permalink
Enable colored compiler diagnostics with the background process as we…
Browse files Browse the repository at this point in the history
…ll (#102)
  • Loading branch information
jimhester authored Oct 15, 2020
1 parent 64ce3d9 commit 3e31f39
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# pkgbuild (development version)

* `pkgbuild_process()` and `build()` now use colored compiler diagnostics if supported (#102)

# pkgbuild 1.1.0

* `compile_dll()` now supports automatic cpp11 registration if the package links to cpp11.
Expand Down
16 changes: 13 additions & 3 deletions R/build-bg.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ pkgbuild_process <- R6Class(
manual, clean_doc, args, needs_compilation, compile_attributes,
register_routines),

finalize = function() super$kill(),
finalize = function() {
unlink(private$makevars_file)
super$kill()
},

is_incomplete_error = function() FALSE,
read_all_error = function() "",
Expand All @@ -83,14 +86,18 @@ pkgbuild_process <- R6Class(
private$out_file
},

kill = function(...) super$kill(...)
kill = function(...) {
unlink(private$makevars_file)
super$kill(...)
}
),

private = list(
path = NULL,
dest_path = NULL,
out_dir = NULL,
out_file = NULL
out_file = NULL,
makevars_file = NULL
)
)

Expand All @@ -107,9 +114,12 @@ rcb_init <- function(self, private, super, path, dest_path, binary,
private$path <- options$path
private$dest_path <- options$dest_path
private$out_dir <- options$out_dir
private$makevars_file <- tempfile()

## Build tools already checked in setup

withr::set_makevars(compiler_flags(debug = FALSE), new_path = private$makevars_file, assignment = "+=")
withr::local_envvar("R_MAKEVARS_USER" = private$makevars_file)
options <- rcmd_process_options(
cmd = options$cmd,
cmdargs = c(options$path, options$args),
Expand Down
1 change: 1 addition & 0 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ build <- function(path = ".", dest_path = NULL, binary = FALSE, vignettes = TRUE
needs_compilation, compile_attributes, register_routines, quiet)
on.exit(unlink(options$out_dir, recursive = TRUE), add = TRUE)

withr::local_makevars(compiler_flags(debug = FALSE), .assignment = "+=")
withr::with_temp_libpaths(
rcmd_build_tools(
options$cmd,
Expand Down
2 changes: 1 addition & 1 deletion R/with-debug.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ without_compiler <- function(code) {
flags <- c(
CC = "test",
CXX = "test",
CXX1X = "test",
CXX11 = "test",
FC = "test"
)

Expand Down

0 comments on commit 3e31f39

Please # to comment.