Skip to contents

Instead of building the target, this rule simply issues the given error message. This rule is useful for cases where the target target depends on depends but must be updated by some manual process. So if target is older than any of its dependencies, make will throw an error until the user manually updates the target.

Usage

offlineRule(target, message, depends = NULL, task = "all")

Arguments

target

A character vector of target file names of the manual (offline) build command

message

An error message to be issued if targets are older than dependencies in depends

depends

A character vector of file names the targets depend on

task

A character vector of parent task names. The mechanism of tasks allows grouping rules. Anything different from 'all' will cause the creation of a new task depending on the given rule. Executing make taskname will then force building this rule.

Value

Instance of S3 class rmake.rule

See also

Author

Michal Burda

Examples

r <- offlineRule(target='offlinedata.csv',
                 message='Please re-generate manually offlinedata.csv',
                 depends=c('source1.csv', 'source2.csv'))

# generate the content of a makefile (as character vector)
makefile(list(r))
#>  [1] "# This file is generated by rmake - do not edit by hand"                                                       
#>  [2] "ifeq ($(origin .FEATURES),undefined)"                                                                          
#>  [3] "$(error This Makefile requires GNU Make. Please install it and use 'gmake' or 'make' depending on your system)"
#>  [4] "endif"                                                                                                         
#>  [5] "REQUIRED_VERSION := 3.82"                                                                                      
#>  [6] "ifeq ($(filter $(REQUIRED_VERSION),$(firstword $(sort $(MAKE_VERSION) $(REQUIRED_VERSION)))),)"                
#>  [7] "$(error GNU Make $(REQUIRED_VERSION) or higher is required. You are using $(MAKE_VERSION))"                    
#>  [8] "endif"                                                                                                         
#>  [9] "SHELL=/bin/sh"                                                                                                 
#> [10] "R=\"$(R_HOME)/bin$(R_ARCH)/Rscript\""                                                                          
#> [11] "RM=rm"                                                                                                         
#> [12] "CP=cp"                                                                                                         
#> [13] ".ONESHELL:"                                                                                                    
#> [14] ""                                                                                                              
#> [15] ".PHONY: all"                                                                                                   
#> [16] "all: Makefile offlinedata.csv"                                                                                 
#> [17] "\t"                                                                                                            
#> [18] "offlinedata.csv: source1.csv source2.csv"                                                                      
#> [19] "\t$(R) - <<'EOFrmake'"                                                                                         
#> [20] "\t{"                                                                                                           
#> [21] "\t    stop(\"Please re-generate manually offlinedata.csv\")"                                                   
#> [22] "\t}"                                                                                                           
#> [23] "\tEOFrmake"                                                                                                    
#> [24] ".PHONY: clean"                                                                                                 
#> [25] "clean: "                                                                                                       
#> [26] "\t$(RM) offlinedata.csv"                                                                                       
#> [27] "Makefile: Makefile.R"                                                                                          
#> [28] "\t$(R) - <<'EOFrmake'"                                                                                         
#> [29] "\t{"                                                                                                           
#> [30] "\t    params <- list(.target = \"Makefile\", .script = \"Makefile.R\", .depends = NULL, .task = \"all\")"      
#> [31] "\t    source(\"Makefile.R\")"                                                                                  
#> [32] "\t}"                                                                                                           
#> [33] "\tEOFrmake"                                                                                                    

# generate to file
tmp <- tempdir()
makefile(list(r), file.path(tmp, "Makefile"))