Skip to content

Commit

Permalink
Add support for Rtools42
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Feb 11, 2022
1 parent 7d49005 commit 18ab426
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
config:
- {os: macOS-latest, r: 'release'}

- {os: windows-latest, r: 'devel', rtools-version: '42'}
- {os: windows-latest, r: 'devel' }
- {os: windows-latest, r: 'release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
Expand All @@ -48,6 +50,7 @@ jobs:
- uses: r-lib/actions/setup-r@v2-branch
with:
r-version: ${{ matrix.config.r }}
rtools-version: ${{ matrix.config.rtools-version }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

Expand Down
6 changes: 4 additions & 2 deletions setup-r/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ This action sets up an R environment for use in actions by:
- **r-version** (`'release'`) - Version range or exact version of an R
version to use.
- **rtools-version** (`''`) - Exact version of Rtools to use. Default
uses latest suitable rtools for the given version of R.
uses latest suitable rtools for the given version of R. Set it to
“42” for Rtools42.
- **Ncpus** (`'1'`) - Value to set the R option `Ncpus` to.
- **remove-openmp-macos** (`true`) - If true, remove `-fopenmp` from
the default compilation flags, e.g. `SHLIB_OPENMP_CFLAGS`, as the
Expand All @@ -44,7 +45,8 @@ This action sets up an R environment for use in actions by:
setup. If “false” use the existing installation in the GitHub Action
image.
- **windows-path-include-mingw** (`true`) - If “true” put the 64 bit
mingw directory from Rtools on the PATH for Windows builds.
mingw directory from Rtools on the PATH for Windows builds. This
argument is now defunct on Rtools40 and later.
- **update-rtools** (`false`) - Update rtools40 compilers and
libraries to the latest builds.
- **use-public-rspm** (`false`) - Use the public version of RStudio
Expand Down
4 changes: 2 additions & 2 deletions setup-r/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
default: 'release'
rtools-version:
description: 'Exact version of Rtools to use. Default uses latest suitable
rtools for the given version of R.'
rtools for the given version of R. Set it to "42" for Rtools42.'
default: ''
Ncpus:
description: 'Value to set the R option `Ncpus` to.'
Expand All @@ -30,7 +30,7 @@ inputs:
default: true
windows-path-include-mingw:
description: 'If "true" put the 64 bit mingw directory from Rtools on the
PATH for Windows builds.'
PATH for Windows builds. This argument is now defunct on Rtools40 and later.'
default: true
update-rtools:
description: 'Update rtools40 compilers and libraries to the latest builds.'
Expand Down
36 changes: 27 additions & 9 deletions setup-r/lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,31 @@ function acquireRWindows(version) {
}
function acquireRtools(version) {
return __awaiter(this, void 0, void 0, function* () {
const rtools4 = version.charAt(0) == "4";
let fileName = util.format(rtools4 ? "rtools%s-x86_64.exe" : "Rtools%s.exe", version);
const versionNumber = parseInt(version.substring(0, 2));
const rtools42 = versionNumber >= 41;
const rtools40 = !rtools42 && versionNumber >= 40;
const rtools3x = !rtools42 && !rtools40;
var downloadUrl, fileName;
if (rtools42) {
fileName = util.format("rtools%s-x86_64.exe", version);
downloadUrl = util.format("http://cloud.r-project.org/bin/windows/Rtools/%s", fileName);
}
else if (rtools40) {
fileName = "rtools42-5038-4926.exe";
downloadUrl = util.format("http://cloud.r-project.org/bin/windows/Rtools/%s", fileName);
}
else {
fileName = util.format("Rtools%s.exe", version);
downloadUrl = "https://github.com/gaborcsardi/Rtools42/releases/download/5038-4926/rtools42-5038-4926.exe";
}
// If Rtools is already installed just return, as there is a message box
// which hangs the build otherwise.
if ((!rtools4 && fs.existsSync("C:\\Rtools")) ||
(rtools4 && fs.existsSync("C:\\rtools40"))) {
if ((rtools42 && fs.existsSync("C:\\Rtools42")) ||
(rtools40 && fs.existsSync("C:\\rtools40")) ||
(rtools3x && fs.existsSync("C:\\Rtools"))) {
core.debug("Skipping Rtools installation as a suitable Rtools is already installed");
}
else {
let downloadUrl = util.format("http://cloud.r-project.org/bin/windows/Rtools/%s", fileName);
console.log(`Downloading ${downloadUrl}...`);
let downloadPath = null;
try {
Expand All @@ -395,11 +410,14 @@ function acquireRtools(version) {
throw `Failed to install Rtools: ${error}`;
}
}
if (rtools4) {
if (rtools42) {
core.addPath(`C:\\rtools42\\usr\\bin`);
core.addPath(`C:\\rtools42\\x86_64-w64-mingw32.static.posix\\bin`);
}
else if (rtools40) {
if (core.getInput("windows-path-include-mingw") === "true") {
core.addPath(`C:\\rtools40\\mingw64\\bin`);
core.warning("windows-path-include-mingw is now defunct for Rtools40");
}
core.addPath(`C:\\rtools40\\usr\\bin`);
if (core.getInput("r-version").match("devel")) {
core.addPath(`C:\\rtools40\\ucrt64\\bin`);
core.exportVariable("_R_INSTALL_TIME_PATCHES_", "no");
Expand All @@ -418,7 +436,7 @@ function acquireRtools(version) {
}
}
}
else {
else { // rtools3x
core.addPath(`C:\\Rtools\\bin`);
if (core.getInput("windows-path-include-mingw") === "true") {
core.addPath(`C:\\Rtools\\mingw_64\\bin`);
Expand Down
46 changes: 31 additions & 15 deletions setup-r/src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,26 +346,37 @@ async function acquireRWindows(version: string): Promise<string> {
}

async function acquireRtools(version: string) {
const rtools4 = version.charAt(0) == "4";
let fileName: string = util.format(
rtools4 ? "rtools%s-x86_64.exe" : "Rtools%s.exe",
version
);
const versionNumber = parseInt(version.substring(0, 2));
const rtools42 = versionNumber >= 41;
const rtools40 = !rtools42 && versionNumber >= 40;
const rtools3x = !rtools42 && !rtools40;
var downloadUrl, fileName;
if (rtools42) {
fileName = util.format("rtools%s-x86_64.exe", version);
downloadUrl = util.format(
"http://cloud.r-project.org/bin/windows/Rtools/%s",
fileName)
} else if (rtools40) {
fileName = "rtools42-5038-4926.exe";
downloadUrl = util.format(
"http://cloud.r-project.org/bin/windows/Rtools/%s",
fileName)
} else {
fileName = util.format("Rtools%s.exe", version);
downloadUrl = "https://github.com/gaborcsardi/Rtools42/releases/download/5038-4926/rtools42-5038-4926.exe";
}

// If Rtools is already installed just return, as there is a message box
// which hangs the build otherwise.
if (
(!rtools4 && fs.existsSync("C:\\Rtools")) ||
(rtools4 && fs.existsSync("C:\\rtools40"))
(rtools42 && fs.existsSync("C:\\Rtools42")) ||
(rtools40 && fs.existsSync("C:\\rtools40")) ||
(rtools3x && fs.existsSync("C:\\Rtools"))
) {
core.debug(
"Skipping Rtools installation as a suitable Rtools is already installed"
);
} else {
let downloadUrl: string = util.format(
"http://cloud.r-project.org/bin/windows/Rtools/%s",
fileName
);
console.log(`Downloading ${downloadUrl}...`);
let downloadPath: string | null = null;
try {
Expand All @@ -388,11 +399,16 @@ async function acquireRtools(version: string) {
throw `Failed to install Rtools: ${error}`;
}
}
if (rtools4) {
if (rtools42) {
core.addPath(`C:\\rtools42\\usr\\bin`);
core.addPath(`C:\\rtools42\\x86_64-w64-mingw32.static.posix\\bin`);

} else if (rtools40) {
if (core.getInput("windows-path-include-mingw") === "true") {
core.addPath(`C:\\rtools40\\mingw64\\bin`);
core.warning(
"windows-path-include-mingw is now defunct for Rtools40"
);
}
core.addPath(`C:\\rtools40\\usr\\bin`);
if (core.getInput("r-version").match("devel")) {
core.addPath(`C:\\rtools40\\ucrt64\\bin`);
core.exportVariable("_R_INSTALL_TIME_PATCHES_", "no");
Expand All @@ -409,7 +425,7 @@ async function acquireRtools(version: string) {
throw `Failed to update rtools40 libraries: ${error}`;
}
}
} else {
} else { // rtools3x
core.addPath(`C:\\Rtools\\bin`);
if (core.getInput("windows-path-include-mingw") === "true") {
core.addPath(`C:\\Rtools\\mingw_64\\bin`);
Expand Down

0 comments on commit 18ab426

Please sign in to comment.