From 9c3fc65c5ab22bccc44f1887c397ccaa955d0c8d Mon Sep 17 00:00:00 2001 From: Jeroen Ooms Date: Sun, 15 Dec 2024 22:18:19 +0000 Subject: [PATCH] Windows: use libxml2 from Rtools if found --- .github/workflows/R-CMD-check.yaml | 4 +++- NEWS.md | 2 ++ src/Makevars.win | 30 ++++++++++++++++++------------ tools/winlibs.R | 6 ++---- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 064677b4..cd88fc94 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -27,7 +27,9 @@ jobs: - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - # use 4.0 or 4.1 to check with rtools40's older compiler + - {os: windows-latest, r: 'oldrel-1'} + - {os: windows-latest, r: 'oldrel-2'} + - {os: windows-latest, r: 'oldrel-3'} - {os: windows-latest, r: 'oldrel-4'} - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} diff --git a/NEWS.md b/NEWS.md index 3da2add0..6bee4e2d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # xml2 (development version) +* Windows: use libxml2 from Rtools if found + # xml2 1.3.6 * Now compatible with libxml2 2.12.0 and later (@KNnut). diff --git a/src/Makevars.win b/src/Makevars.win index badc575d..49d9e77c 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1,18 +1,24 @@ -VERSION=2.10.3 -RWINLIB=../windows/libxml2-$(VERSION) -PKG_CPPFLAGS=-I../inst/include -I$(RWINLIB)/include/libxml2 \ - -DLIBXML_STATIC +PKG_CONFIG_NAME = libxml-2.0 +PKG_CONFIG ?= $(BINPREF)pkg-config +PKG_LIBS := $(shell $(PKG_CONFIG) --libs $(PKG_CONFIG_NAME)) +STATIC_CFLAGS = -DLIBXML_STATIC -I../inst/include +ifneq ($(PKG_LIBS),) +$(info using $(PKG_CONFIG_NAME) from Rtools) +PKG_CPPFLAGS := $(shell $(PKG_CONFIG) --cflags $(PKG_CONFIG_NAME)) $(STATIC_CFLAGS) +else +RWINLIB = ../windows/libxml2-2.10.3 +PKG_CPPFLAGS = -I$(RWINLIB)/include -I$(RWINLIB)/include/libxml2 $(STATIC_CFLAGS) PKG_LIBS = -L$(RWINLIB)/lib${subst gcc,,$(COMPILED_BY)}$(R_ARCH) \ - -L$(RWINLIB)/lib$(R_ARCH)\ - -lxml2 -llzma -liconv -lz -lws2_32 + -L$(RWINLIB)/lib$(R_ARCH) -lxml2 -llzma -liconv -lz -lws2_32 +endif -all: clean winlibs +all: $(SHLIB) -clean: - rm -f $(OBJECTS) $(SHLIB) +$(OBJECTS): $(RWINLIB) -winlibs: - "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" $(VERSION) +$(RWINLIB): + "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" -.PHONY: all winlibs clean +clean: + rm -f $(SHLIB) $(OBJECTS) diff --git a/tools/winlibs.R b/tools/winlibs.R index c327922f..36cf6b81 100644 --- a/tools/winlibs.R +++ b/tools/winlibs.R @@ -1,8 +1,6 @@ # Build against static libraries from rwinlib -VERSION <- commandArgs(TRUE) -if(!file.exists(sprintf("../windows/libxml2-%s/include/libxml2/libxml/parser.h", VERSION))){ - if(getRversion() < "3.3.0") setInternet2() - download.file(sprintf("https://github.com/rwinlib/libxml2/archive/v%s.zip", VERSION), "lib.zip", quiet = TRUE) +if(!file.exists("../windows/libxml2-2.10.3/include/libxml2/libxml/parser.h")){ + download.file("https://github.com/rwinlib/libxml2/archive/v2.10.3.zip", "lib.zip", quiet = TRUE) dir.create("../windows", showWarnings = FALSE) unzip("lib.zip", exdir = "../windows") unlink("lib.zip")