| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/makevars.R |
| 3 |
\name{with_makevars} |
| 4 |
\alias{with_makevars} |
| 5 |
\alias{local_makevars} |
| 6 |
\title{Makevars variables} |
| 7 |
\usage{ |
| 8 |
with_makevars( |
| 9 |
new, |
| 10 |
code, |
| 11 |
path = makevars_user(), |
| 12 |
assignment = c("=", ":=", "?=", "+=") |
| 13 |
) |
| 14 |
|
| 15 |
local_makevars( |
| 16 |
.new = list(), |
| 17 |
..., |
| 18 |
.path = makevars_user(), |
| 19 |
.assignment = c("=", ":=", "?=", "+="), |
| 20 |
.local_envir = parent.frame() |
| 21 |
) |
| 22 |
} |
| 23 |
\arguments{ |
| 24 |
\item{new, .new}{\verb{[named character]}\cr New variables and their values} |
| 25 |
|
| 26 |
\item{code}{\code{[any]}\cr Code to execute in the temporary environment} |
| 27 |
|
| 28 |
\item{path, .path}{\verb{[character(1)]}\cr location of existing \code{Makevars} file to modify.} |
| 29 |
|
| 30 |
\item{assignment, .assignment}{\verb{[character(1)]}\cr assignment type to use.} |
| 31 |
|
| 32 |
\item{...}{Additional new variables and their values.} |
| 33 |
|
| 34 |
\item{.local_envir}{\verb{[environment]}\cr The environment to use for scoping.} |
| 35 |
} |
| 36 |
\value{ |
| 37 |
\code{[any]}\cr The results of the evaluation of the \code{code} |
| 38 |
argument. |
| 39 |
} |
| 40 |
\description{ |
| 41 |
Temporarily change contents of an existing \code{Makevars} file. |
| 42 |
} |
| 43 |
\details{ |
| 44 |
If no \code{Makevars} file exists or the fields in \code{new} do |
| 45 |
not exist in the existing \code{Makevars} file then the fields are added to |
| 46 |
the new file. Existing fields which are not included in \code{new} are |
| 47 |
appended unchanged. Fields which exist in \code{Makevars} and in \code{new} |
| 48 |
are modified to use the value in \code{new}. |
| 49 |
} |
| 50 |
\examples{ |
| 51 |
writeLines("void foo(int* bar) { *bar = 1; }\n", "foo.c") |
| 52 |
system("R CMD SHLIB --preclean -c foo.c") |
| 53 |
with_makevars(c(CFLAGS = "-O3"), system("R CMD SHLIB --preclean -c foo.c")) |
| 54 |
unlink(c("foo.c", "foo.so")) |
| 55 |
} |
| 56 |
\seealso{ |
| 57 |
\code{\link{withr}} for examples |
| 58 |
} |