Skip to content

Commit 4498a89

Browse files
committed
add changes from #5503
1 parent 3be05d4 commit 4498a89

File tree

5 files changed

+43
-10
lines changed

5 files changed

+43
-10
lines changed

.ci/test_r_package_windows.ps1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ Remove-From-Path ".*PostgreSQL.*"
5454
Remove-From-Path ".*\\R\\.*"
5555
Remove-From-Path ".*R Client.*"
5656
Remove-From-Path ".*rtools40.*"
57+
Remove-From-Path ".*rtools42.*"
5758
Remove-From-Path ".*shells.*"
5859
Remove-From-Path ".*Strawberry.*"
5960
Remove-From-Path ".*tools.*"
6061

6162
Remove-Item C:\rtools40 -Force -Recurse -ErrorAction Ignore
63+
Remove-Item C:\rtools42 -Force -Recurse -ErrorAction Ignore
6264

6365
# Get details needed for installing R components
6466
#
@@ -74,11 +76,11 @@ if ($env:R_MAJOR_VERSION -eq "3") {
7476
$env:RTOOLS_EXE_FILE = "rtools35-x86_64.exe"
7577
$env:R_WINDOWS_VERSION = "3.6.3"
7678
} elseif ($env:R_MAJOR_VERSION -eq "4") {
77-
$RTOOLS_INSTALL_PATH = "C:\rtools40"
79+
$RTOOLS_INSTALL_PATH = "C:\rtools42"
7880
$env:RTOOLS_BIN = "$RTOOLS_INSTALL_PATH\usr\bin"
79-
$env:RTOOLS_MINGW_BIN = "$RTOOLS_INSTALL_PATH\mingw64\bin"
80-
$env:RTOOLS_EXE_FILE = "rtools40v2-x86_64.exe"
81-
$env:R_WINDOWS_VERSION = "4.1.3"
81+
$env:RTOOLS_MINGW_BIN = "$RTOOLS_INSTALL_PATH\x86_64-w64-mingw32.static.posix\bin"
82+
$env:RTOOLS_EXE_FILE = "rtools42-5253-5107.exe"
83+
$env:R_WINDOWS_VERSION = "4.2.1"
8284
} else {
8385
Write-Output "[ERROR] Unrecognized R version: $env:R_VERSION"
8486
Check-Output $false
@@ -147,7 +149,7 @@ Write-Output "Building R package"
147149
# R CMD check is not used for MSVC builds
148150
if ($env:COMPILER -ne "MSVC") {
149151

150-
$PKG_FILE_NAME = "lightgbm_*.tar.gz"
152+
$PKG_FILE_NAME = "lightgbm_$env:LGB_VER.tar.gz"
151153
$LOG_FILE_NAME = "lightgbm.Rcheck/00check.log"
152154

153155
if ($env:R_BUILD_TYPE -eq "cmake") {

.github/workflows/r_package.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
task: r-package
8484
compiler: MINGW
8585
toolchain: MSYS
86-
r_version: 4.1
86+
r_version: 4.2
8787
build_type: cmake
8888
# Visual Studio 2019
8989
- os: windows-2019
@@ -97,7 +97,7 @@ jobs:
9797
task: r-package
9898
compiler: MSVC
9999
toolchain: MSVC
100-
r_version: 4.1
100+
r_version: 4.2
101101
build_type: cmake
102102
###############
103103
# CRAN builds #
@@ -112,7 +112,7 @@ jobs:
112112
task: r-package
113113
compiler: MINGW
114114
toolchain: MSYS
115-
r_version: 4.1
115+
r_version: 4.2
116116
build_type: cran
117117
- os: ubuntu-latest
118118
task: r-package
@@ -166,6 +166,7 @@ jobs:
166166
shell: pwsh -command ". {0}"
167167
run: |
168168
$env:BUILD_SOURCESDIRECTORY = $env:GITHUB_WORKSPACE
169+
$env:LGB_VER = (Get-Content -TotalCount 1 $env:BUILD_SOURCESDIRECTORY\VERSION.txt).trim().replace('rc', '-')
169170
$env:TOOLCHAIN = "${{ matrix.toolchain }}"
170171
$env:R_VERSION = "${{ matrix.r_version }}"
171172
$env:R_BUILD_TYPE = "${{ matrix.build_type }}"

R-package/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,18 @@ After installing `Rtools` and `CMake`, be sure the following paths are added to
9494
- If you have `Rtools` 4.0, example:
9595
- `C:\rtools40\mingw64\bin`
9696
- `C:\rtools40\usr\bin`
97+
- If you have `Rtools` 4.2, example:
98+
- `C:\rtools42\x86_64-w64-mingw32.static.posix\bin`
99+
- `C:\rtools42\usr\bin`
97100
* `CMake`
98101
- example: `C:\Program Files\CMake\bin`
99102
* `R`
100103
- example: `C:\Program Files\R\R-3.6.1\bin`
101104

102105
NOTE: Two `Rtools` paths are required from `Rtools` 4.0 onwards because paths and the list of included software was changed in `Rtools` 4.0.
103106

107+
NOTE: `Rtools42` takes a very different approach to the compiler toolchain than previous releases, and how you install it changes what is required to build packages. See ["Howto: Building R 4.2 and packages on Windows"](https://cran.r-project.org/bin/windows/base/howto-R-4.2.html).
108+
104109
#### Windows Toolchain Options
105110

106111
A "toolchain" refers to the collection of software used to build the library. The R package can be built with three different toolchains.

R-package/configure.win

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,31 @@ then
6666
LGB_CPPFLAGS="${LGB_CPPFLAGS} -DMM_MALLOC=1"
6767
fi
6868

69+
#############
70+
# INET_PTON #
71+
#############
72+
73+
ac_inet_pton="no"
74+
75+
cat > conftest.cpp <<EOL
76+
#include <ws2tcpip.h>
77+
int main() {
78+
int (*fptr)(int, const char*, void*);
79+
fptr = &inet_pton;
80+
return 0;
81+
}
82+
EOL
83+
84+
${CXX} ${CXXFLAGS} ${CPPFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_inet_pton="yes"
85+
rm -f ./conftest
86+
rm -f ./conftest.cpp
87+
echo "checking whether INET_PTON works...${ac_inet_pton}"
88+
89+
if test "${ac_inet_pton}" = "yes";
90+
then
91+
LGB_CPPFLAGS="${LGB_CPPFLAGS} -DWIN_HAS_INET_PTON=1"
92+
fi
93+
6994
# Generate Makevars.win from Makevars.win.in
7095
sed -e \
7196
"s/@LGB_CPPFLAGS@/$LGB_CPPFLAGS/" \

R-package/tests/testthat/test_dataset.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ test_that("lgb.Dataset: Dataset should be able to construct from matrix and retu
248248

249249
test_that("cpp errors should be raised as proper R errors", {
250250
testthat::skip_if(
251-
Sys.getenv("COMPILER", "") == "MSVC" && as.integer(R.Version()[["major"]]) < 4L
252-
, message = "Skipping on R 3.x and Visual Studio"
251+
Sys.getenv("COMPILER", "") == "MSVC"
252+
, message = "Skipping on Visual Studio"
253253
)
254254
data(agaricus.train, package = "lightgbm")
255255
train <- agaricus.train

0 commit comments

Comments
 (0)