| makefile | R Documentation |
job).In the (GNU) make jargon, a rule is a sequence of commands to build a result. In this package, a rule
should be understood similarly: It is a command or a sequence of commands that optionally produces some
files and depends on some other files (such as data files or scripts) or other rules. Moreover, a rule
contains a command for cleanup, i.e., for removal of generated files.
makefile(
job = list(),
fileName = NULL,
makeScript = "Makefile.R",
vars = NULL,
all = TRUE,
tasks = TRUE,
clean = TRUE,
makefile = TRUE,
depends = NULL
)
job |
A list of rules (i.e., instances of the S3 class |
fileName |
A file to write to. If |
makeScript |
The name of the file that calls this function (used to generate
the |
vars |
A named character vector of shell variables that will be declared in the resulting Makefile
(in addition to |
all |
|
tasks |
|
clean |
|
makefile |
|
depends |
A character vector of file names that the makefile generating script depends on |
The makefile() function takes a list of rules (see rule()) and generates a Makefile from them.
Additionally, all and clean rules are optionally generated too, which can be executed from the shell
by issuing the make all or make clean command, respectively, to build everything or erase all
generated files.
If there is a need to group some rules together, it can be done either via dependencies or by using
the task mechanism. Each rule may be assigned one or more tasks (see task in rule()). Each
task is then created as a standalone rule depending on the assigned rules. That way, executing make task_name
will build all rules with the assigned task task_name. By default, all rules are assigned to task all,
which allows make all to build everything.
If fileName is NULL, the function returns a character vector with the contents of the
Makefile. Otherwise, the content is written to the given fileName.
Michal Burda
rule(), rmakeSkeleton()
# create some jobs
job <- list(
rRule('dataset.rds', 'preprocess.R', 'dataset.csv'),
markdownRule('report.pdf', 'report.Rmd', 'dataset.rds'),
markdownRule('details.pdf', 'details.Rmd', 'dataset.rds'))
# generate Makefile (output as a character vector)
makefile(job)
# generate to file
tmp <- tempdir()
makefile(job, file.path(tmp, "Makefile"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.