From 7f30707eb60aae302981841ec0a554feb6321b11 Mon Sep 17 00:00:00 2001 From: Jeroen Ooms Date: Mon, 17 Jan 2022 20:22:29 +0100 Subject: [PATCH] Windows: build against nlopt 2.7.1 --- .github/workflows/check-standard.yaml | 1 + configure.win | 35 --------------------------- src/Makevars.ucrt | 2 ++ src/Makevars.win | 14 +++++++++-- tools/winlibs.R | 7 ++++++ 5 files changed, 22 insertions(+), 37 deletions(-) delete mode 100644 configure.win create mode 100644 src/Makevars.ucrt create mode 100644 tools/winlibs.R diff --git a/.github/workflows/check-standard.yaml b/.github/workflows/check-standard.yaml index 0374941b..38e42d3a 100644 --- a/.github/workflows/check-standard.yaml +++ b/.github/workflows/check-standard.yaml @@ -20,6 +20,7 @@ jobs: config: - {os: macOS-latest, r: 'release'} - {os: windows-latest, r: 'release'} + - {os: windows-2022, r: 'devel'} - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - {os: ubuntu-latest, r: 'release'} - {os: ubuntu-latest, r: 'oldrel-1'} diff --git a/configure.win b/configure.win deleted file mode 100644 index 61a71153..00000000 --- a/configure.win +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh - -RSCRIPT_BIN=${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe -NCORES=`${RSCRIPT_BIN} -e "cat(parallel::detectCores(logical = FALSE))"` - -cd src - -#### CMAKE CONFIGURATION #### -. ./scripts/cmake_config.sh - -# Compile NLOpt from source -sh ./scripts/nlopt_download.sh ${RSCRIPT_BIN} -for ARCH in "/x64" "/i386"; do - dot() { file=$1; shift; . "$file"; } - dot ./scripts/r_config.sh ${ARCH} - "${CMAKE_BIN}" \ - -G "MSYS Makefiles" \ - -D BUILD_SHARED_LIBS=OFF \ - -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_AR=${AR} \ - -D CMAKE_RANLIB=${RANLIB} \ - -D NLOPT_CXX=ON \ - -D NLOPT_GUILE=OFF \ - -D NLOPT_MATLAB=OFF \ - -D NLOPT_OCTAVE=OFF \ - -D NLOPT_PYTHON=OFF \ - -D NLOPT_SWIG=OFF \ - -D NLOPT_TESTS=OFF \ - -S nlopt-src \ - -B nlopt${ARCH}-build - sh ./scripts/nlopt_install.sh "${CMAKE_BIN}" ${NCORES} ${ARCH} -done - -# Cleanup -sh ./scripts/nlopt_cleanup.sh diff --git a/src/Makevars.ucrt b/src/Makevars.ucrt new file mode 100644 index 00000000..1a2e1013 --- /dev/null +++ b/src/Makevars.ucrt @@ -0,0 +1,2 @@ +CRT=-ucrt +include Makevars.win diff --git a/src/Makevars.win b/src/Makevars.win index ee2f6705..f085ef03 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1,3 +1,13 @@ CXX_STD = CXX11 -PKG_CPPFLAGS = -I../inst/include -PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -Lnlopt$(R_ARCH)/lib -lnlopt +VERSION = 2.7.1 +WINLIBS = ../windows/nlopt-2.7.1 +PKG_CPPFLAGS = -I../inst/include -I$(WINLIBS)/include +PKG_LIBS = -L$(WINLIBS)/lib${R_ARCH}${CRT} -lnlopt + +all: clean winlibs + +winlibs: + "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" + +clean: + rm -f $(SHLIB) $(OBJECTS) diff --git a/tools/winlibs.R b/tools/winlibs.R new file mode 100644 index 00000000..1efad652 --- /dev/null +++ b/tools/winlibs.R @@ -0,0 +1,7 @@ +# Build against mingw-w64 build of nlopt +if(!file.exists("../windows/nlopt-2.7.1/include/nlopt.hpp")){ + download.file("https://github.com/rwinlib/nlopt/archive/v2.7.1.zip", "lib.zip", quiet = TRUE) + dir.create("../windows", showWarnings = FALSE) + unzip("lib.zip", exdir = "../windows") + unlink("lib.zip") +}