Skip to content

Commit 5534df8

Browse files
committed
Keep Makeconf functions cacheable
1 parent 8851898 commit 5534df8

2 files changed

Lines changed: 45 additions & 3 deletions

File tree

R/aaa-utils.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,7 @@ quickr_makevars_has_uncached_functions <- function(config_name = "") {
734734

735735
paths <- unique(c(
736736
quickr_active_makevars_all_paths(config_name),
737-
quickr_makefiles_all_paths(config_name),
738-
quickr_makeconf_paths(config_name)
737+
quickr_makefiles_all_paths(config_name)
739738
))
740739
paths <- paths[vapply(paths, quickr_regular_file_exists, logical(1))]
741740
if (!length(paths)) {
@@ -760,6 +759,8 @@ quickr_makefiles_has_uncached_functions <- function(config_name = "") {
760759

761760
quickr_file_has_makevars_uncached_function <- function(path) {
762761
lines <- readLines(path, warn = FALSE)
762+
lines <- quickr_join_makevars_continuations(lines)
763+
lines <- vapply(lines, quickr_strip_make_comment, character(1))
763764
quickr_text_has_makevars_uncached_function(lines)
764765
}
765766

tests/testthat/test-compiler-cache.R

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,39 @@ test_that("quickr_cached_r_cmd_config_value keys on Makeconf env refs", {
16411641
expect_equal(calls, 2L)
16421642
})
16431643

1644-
test_that("quickr_cached_r_cmd_config_value retries dynamic Makeconf inputs", {
1644+
test_that("quickr_cached_r_cmd_config_value caches Makeconf make functions", {
1645+
cache <- new.env(parent = emptyenv())
1646+
makeconf <- withr::local_tempfile()
1647+
writeLines(
1648+
c(
1649+
"USE_LLVM =",
1650+
"CCBASE = $(if $(USE_LLVM),clang,gcc)",
1651+
"FC = $(CCBASE)"
1652+
),
1653+
makeconf
1654+
)
1655+
calls <- 0L
1656+
local_mocked_bindings(
1657+
quickr_makeconf_path = function() makeconf,
1658+
quickr_r_cmd_config_probe = function(name) {
1659+
calls <<- calls + 1L
1660+
list(value = paste0("value-", calls), ok = TRUE)
1661+
},
1662+
.package = "quickr"
1663+
)
1664+
1665+
expect_identical(
1666+
quickr_cached_r_cmd_config_value("FC", cache = cache),
1667+
"value-1"
1668+
)
1669+
expect_identical(
1670+
quickr_cached_r_cmd_config_value("FC", cache = cache),
1671+
"value-1"
1672+
)
1673+
expect_equal(calls, 1L)
1674+
})
1675+
1676+
test_that("quickr_cached_r_cmd_config_value keys on dynamic Makeconf content", {
16451677
cache <- new.env(parent = emptyenv())
16461678
root <- withr::local_tempdir()
16471679
makeconf <- file.path(root, "Makeconf")
@@ -1664,6 +1696,15 @@ test_that("quickr_cached_r_cmd_config_value retries dynamic Makeconf inputs", {
16641696
)
16651697

16661698
writeLines("flang", compiler_file)
1699+
expect_identical(
1700+
quickr_cached_r_cmd_config_value("FC", cache = cache),
1701+
"value-1"
1702+
)
1703+
1704+
writeLines(
1705+
paste("FC = $(shell cat", compiler_file, ") # changed"),
1706+
makeconf
1707+
)
16671708
expect_identical(
16681709
quickr_cached_r_cmd_config_value("FC", cache = cache),
16691710
"value-2"

0 commit comments

Comments
 (0)