ComputationalProteomicsUnit / maker

Makefile for R packages
GNU General Public License v3.0
31 stars 5 forks source link

Setting default PKG #19

Closed lbraglia closed 9 years ago

lbraglia commented 9 years ago

Hi,

in this Makefile

https://github.com/lbraglia/ProjectMake

which works on data-analysis projects (with Rnw and knitr) in a similar way to maker, i adopted a "trick" to set a default Project (PRJ, the equivalent of PKG for maker).

Eg after

make set-default-prj PRJ=Foobar

i avoid specifying PRJ=Foobar each time, eg with

make pdf-analysis

(say .. it's a way to produce the pdf of the final step of the analysis) i avoid the longer

make pdf-analysis PRJ=Foobar

It does it by setting/modifying the variable PRJ in .ProjectMake (the equivalent of .makerrc) with a minimal amount of regex.

I've tested for a few month in daily usage: it works fine and speeds up things a lot to me, especially if i have to work on the same project for many make commands (that is usually the case). Furthermore it'is perfectly "backward compatible" (aka the user could continue to specify PRJ on command line)

Could you be interested in similar stuff for PKG? @lgatto @sgibb

lgatto commented 9 years ago

I think that's a nice feature.

To remove a default PRJ, would I remove the corresponding line from my .makerrc file or call make set-default-prj?

lbraglia commented 9 years ago

To remove the default project you can do

make set-default-prj PRJ=

or remove the corresponding line from the equivalent of .makerrc.

The cons i see now (i always work with a default project and never thought about) is that in the rare (i guess) case

the PRJ used is "". With many commands (those with cd ${PRJ} && ...) this is equivalent to work on the project/package in ~ (because of cd && ...) that is not what the user expect...

So maybe a fix is needed to prevent make start doing things :)

sgibb commented 9 years ago

I really like this idea. Thanks for sharing it. I will add the relevant targets to maker in the next days (a PR would be very welcome, too).

Maybe you are looking for something like the following to fix the mentioned problem with an empty PRJ?:

ifndef PRJ
  $(error PRJ is missing!)
endif
lbraglia commented 9 years ago

@sgibb definitely that! thanks