Add Build Commands (e.g. make) to existing set of build tools?

rstudio
ide

#1

Hi

I would like to add make to the existing built tools for an R package, so that I can run “make …” via keyboard shortcut.

Is this possible, or is tere a different way of running a shell script from a keyboard shortcut in RStudio IDE?

Thanks,

Rainer


#2

Take a look at this section of the STAT545 site:
http://stat545.com/automation03_make-test-drive.html

(Adding a little screenshot, since it doesn’t do a preview)

Additionally, RStudio now has a terminal pane internally (a change since that post was written, though that doesn’t mean its inaccurate), which will likely make for an easier workflow:
https://blog.rstudio.com/2017/08/11/rstudio-v1-1-preview-terminal/

Edit: Re. keyboard shortcuts, you can always access a guide to the keyboard shortcuts in RStudio either by going to Tools >> Keyboard Shortcut Help, or by using the keyboard shortcut K


#3

Thanks - I did exactly that, until I realized that all package build options were disabled (e.g. CMD-SHIFT - L to reload the package).

I would like to have standard keyboard accessible build actions (and other shortcuts) from the package build tools, and also add the possibility to use a make file.

I am using the terminal pane at the moment to run make, but still - it would be much easier to have it as an additional build tool in the package environment.


#4

Are you not using a package project? If you’re making a package, the build pane shouldn’t be disabled.

You can also customize your key bindings/shortcuts by going to Preferences >> Code >> Editing.

I’d also recommend recategorizing this question into Package Development (I think package-builders will be able to help you out, and might miss this post in the IDE category, as it’s usually targeted at the IDE devs). You won’t lose anything. The thread stays the same. All you need to do is hit the pencil icon next to the post title, and then you can use the dropdown to select a different category. (I have access because I’m an admin, but I’ll leave the decision up to you! :slight_smile:


#5

A couple other options that might be worth exploring, to complement @mara’s suggestions:

  1. You could define your own commands + keyboard shortcuts for executing the requisite code, using an RStudio addin. See https://rstudio.github.io/rstudioaddins/ for some documentation as to how that could be accomplished.

  2. You could add a configure or cleanup script to your package, whose own job is to invoke make as required during the configure or cleanup phase of package installation. R-exts provides some documentation on this topic at https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Configure-and-cleanup, although it focuses on the use of autoconf.

One thing that’s not clear to me is when you would like make to be invoked – is this something that needs to be done at build time for the package (when a source tarball is prepared)? Or before installing the package / preparing a binary build?


#6

Haven’t thought about that - will look into it, as it sounds interesting and useful.

This doesn’t work for me, as I am mis-using the package structure - see below.

I am (mis)using the package structure to do reproducible research and to make the archiving, sharing and versioning easier (on github).

I am using the R folder for function definitions, data for input data, and R notebooks stored is inst/Reports for doing the import, processing, analysis, and graphing of the results. E.g, one import notebook imports data, processes ot and writes it into the data folder, so that when I load the package again via devtools::load_all() the new data is loaded.

So the idea is not that much install it, but to use it with devtools to do analysis.

Following that, I am using Makefiles to automate the knitting of the reports, i.e. importing and processing the data, creating graphs, … So it has nothing to do with the actual building of the package (which is done in the usual R way), but with the actual analysis.


#7

Well - it not only effects package development, but rather how one can customize the build functions - at the moment it seems that I can only switch between different build targets. It would be nice, if one could define a keyboard shortcut to execute a script easily, which is effectively what I would like to do (invoking make).


#8

@kevinushey

Following the RStudio addin suggestion - can I call make in the same way that that the build tool “Makefile” is doing it, i.e. with the viewer of the output in the top-right? This would be the perfect solution.


#9

That’s not currently possible, but it is a good idea. Would you mind filing this as a feature request at https://github.com/rstudio/rstudioapi/issues?


#10

@kevinushey done - https://github.com/rstudio/rstudioapi/issues/83