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