Title: | Mock the Unix Make Utility |
---|---|
Description: | Use R as a minimal build system. This might come in handy if you are developing R packages and can not use a proper build system. Stay away if you can (use a proper build system). |
Authors: | Andreas Dominik Cullmann [aut, cre] |
Maintainer: | Andreas Dominik Cullmann <[email protected]> |
License: | BSD_2_clause + file LICENSE |
Version: | 1.11.1.9000 |
Built: | 2025-02-06 04:27:51 UTC |
Source: | https://gitlab.com/fvafrcu/fakemake |
Use R as a minimal build system. This might come in handy if you are developing R packages and can not use a proper build system. Stay away if you can (use a proper build system).
You will find the details invignette("An_Introduction_to_fakemake", package = "fakemake")
.
Add a target to an existing makelist
.
add_target( makelist, target, code, prerequisites = NULL, prerequisite_to = NULL, sink = NULL, alias = sub("\\.(Rout|log)$", "", basename(target)) )
add_target( makelist, target, code, prerequisites = NULL, prerequisite_to = NULL, sink = NULL, alias = sub("\\.(Rout|log)$", "", basename(target)) )
makelist |
A list for
|
target |
The target to remove from |
code |
The code for the new target. |
prerequisites |
The prerequisites for the new target. |
prerequisite_to |
The targets the new target is a prerequisite to.
Set to |
sink |
The sink for the new target. |
alias |
The alias for the new target. |
A list for
make
.
Other functions to manipulate makelists:
get_target()
,
remove_target()
Get a single target from a makelist
by
alias.
get_target(makelist, alias)
get_target(makelist, alias)
makelist |
A list for
|
alias |
The alias of the target in question. |
A list (the target requested).
Other functions to manipulate makelists:
add_target()
,
remove_target()
ml <- provide_make_list() visualize(ml, root = "all.Rout") i <- which(sapply(ml, "[[", "target") == "b1.Rout") ml[[i]]["alias"] <- "b1" t <- get_target(ml, "b1") ml <- remove_target(ml, t[["target"]]) visualize(ml) ml <- add_target(ml, target = t[["target"]], code = t[["code"]], sink = t[["sink"]], prerequisite_to = "a1.Rout", alias = NULL) all.equal(ml, provide_make_list())
ml <- provide_make_list() visualize(ml, root = "all.Rout") i <- which(sapply(ml, "[[", "target") == "b1.Rout") ml[[i]]["alias"] <- "b1" t <- get_target(ml, "b1") ml <- remove_target(ml, t[["target"]]) visualize(ml) ml <- add_target(ml, target = t[["target"]], code = t[["code"]], sink = t[["sink"]], prerequisite_to = "a1.Rout", alias = NULL) all.equal(ml, provide_make_list())
Mock the Unix Make Utility
make( name, make_list, force = FALSE, recursive = force, verbose = FALSE, verbosity = 2, dry_run = FALSE, unconditionally = FALSE, stop_on_warning = FALSE )
make( name, make_list, force = FALSE, recursive = force, verbose = FALSE, verbosity = 2, dry_run = FALSE, unconditionally = FALSE, stop_on_warning = FALSE )
name |
The name or alias of a make target. |
make_list |
The |
force |
Force the target to be build? See Details. |
recursive |
Force the target to be build recursively? See Details. |
verbose |
Be verbose? |
verbosity |
Give the level of verbosity. |
dry_run |
Run dry? Mock GNU |
unconditionally |
Force the target's code to be evaluated unconditionally to any prerequisites? See Details. |
stop_on_warning |
|
force, recursive
Forcing a target mocks adding .PHONY to a GNU Makefile
if you
set recursive to FALSE. If recursive is TRUE, then the whole make chain will
be forced.
unconditionally
Setting unconditionally
to TRUE
allows you to fool
make
similarily to using GNU make
's –touch option.
Invisibly
a character vector
containing the targets made during the current run.
str(make_list <- provide_make_list("minimal")) # build all withr::with_dir(tempdir(), print(make("all.Rout", make_list))) # nothing to be done withr::with_dir(tempdir(), print(make("all.Rout", make_list))) # forcing all.Rout withr::with_dir(tempdir(), print(make("all.Rout", make_list, force = TRUE, recursive = FALSE))) # forcing all.Rout recursively withr::with_dir(tempdir(), print(make("all.Rout", make_list, force = TRUE))) # show files dir(tempdir(), pattern = ".*\\.Rout") # dry run file.remove(dir(tempdir(), pattern = ".*\\.Rout", full.names = TRUE)) withr::with_dir(tempdir(), print(make("all.Rout", make_list, dry_run = TRUE))) dir(tempdir(), pattern = ".*\\.Rout") # make unconditionally dir(tempdir(), pattern = ".*\\.Rout") withr::with_dir(tempdir(), print(make("all.Rout", make_list, unconditionally = TRUE))) dir(tempdir(), pattern = ".*\\.Rout")
str(make_list <- provide_make_list("minimal")) # build all withr::with_dir(tempdir(), print(make("all.Rout", make_list))) # nothing to be done withr::with_dir(tempdir(), print(make("all.Rout", make_list))) # forcing all.Rout withr::with_dir(tempdir(), print(make("all.Rout", make_list, force = TRUE, recursive = FALSE))) # forcing all.Rout recursively withr::with_dir(tempdir(), print(make("all.Rout", make_list, force = TRUE))) # show files dir(tempdir(), pattern = ".*\\.Rout") # dry run file.remove(dir(tempdir(), pattern = ".*\\.Rout", full.names = TRUE)) withr::with_dir(tempdir(), print(make("all.Rout", make_list, dry_run = TRUE))) dir(tempdir(), pattern = ".*\\.Rout") # make unconditionally dir(tempdir(), pattern = ".*\\.Rout") withr::with_dir(tempdir(), print(make("all.Rout", make_list, unconditionally = TRUE))) dir(tempdir(), pattern = ".*\\.Rout")
Makelist
Provided by fakemake.Load an Example Makelist
Provided by fakemake.
provide_make_list( type = c("minimal", "testing"), prune = TRUE, clean_sink = FALSE )
provide_make_list( type = c("minimal", "testing"), prune = TRUE, clean_sink = FALSE )
type |
The type of |
prune |
Prune the |
clean_sink |
Remove sinks identical to corresponding targets from the
list? Since |
A makelist
.
str(provide_make_list("minimal")) visualize(provide_make_list("minimal"))
str(provide_make_list("minimal")) visualize(provide_make_list("minimal"))
Remove a target and all its appearances as
other targets' dependencies from a makelist
.
remove_target(makelist, target)
remove_target(makelist, target)
makelist |
A list for
|
target |
The target to remove from |
A list for
make
.
Other functions to manipulate makelists:
add_target()
,
get_target()
Parse a makelist
, convert it into an igraph
and plot it.
visualize(make_list, root = NULL)
visualize(make_list, root = NULL)
make_list |
The |
root |
The root of a tree. |
Invisibly an igraph representation of the makelist
.
str(ml <- provide_make_list()) visualize(ml) visualize(ml, root = "all.Rout")
str(ml <- provide_make_list()) visualize(ml) visualize(ml, root = "all.Rout")