Skip to content

Commit

Permalink
Windows: update to protobuf 21.12
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Sep 19, 2023
1 parent c800273 commit dcabf1c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: '3.6'}
- {os: windows-latest, r: '4.1'}
- {os: windows-latest, r: '4.2'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
Expand All @@ -31,7 +31,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: cld3
Type: Package
Title: Google's Compact Language Detector 3
Version: 1.5.0
Version: 1.6.0
Authors@R: c(
person("Jeroen", "Ooms", ,"[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-4035-0289")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.6.0
- Windows: update to protobuf 21.12

1.5.0
- Windows: upgrade to libprotobuf 3.19.4
- No longer force CXX11 (use local C++ default std)
Expand Down
15 changes: 4 additions & 11 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# ProtoBuf Version
VERSION = 3.19.4

# Need older build for R < 4.0
ifeq ($(R_COMPILED_BY),gcc 4.9.3)
VERSION = 3.12.4
endif

RWINLIB = ../windows/protobuf-${VERSION}
RWINLIB = ../windows/protobuf
PKG_CPPFLAGS = -I. -I$(RWINLIB)/include -DUSENEWAPI
PKG_LIBS = -Llibcld3 -lstatcld3 \
-L$(RWINLIB)/lib${subst gcc,,${COMPILED_BY}}${R_ARCH} \
-L$(RWINLIB)/lib${R_ARCH} \
-L$(RWINLIB)/lib \
-lprotobuf-lite
BINDIR=$(RWINLIB)/bin$(subst 64,,$(WIN))

STATLIB = libcld3/libstatcld3.a
LIBCLD3 = \
Expand Down Expand Up @@ -52,7 +45,7 @@ $(STATLIB): $(LIBCLD3)

winlibs:
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" $(VERSION)
"$(RWINLIB)/bin$(WIN)/protoc" cld_3/protos/*.proto --cpp_out=.
"$(BINDIR)/protoc" cld_3/protos/*.proto --cpp_out=.

clean:
rm -f $(OBJECTS) $(SHLIB) $(LIBCLD3) $(STATLIB) cld_3/protos/*.pb.cc cld_3/protos/*.pb.h
Expand Down
22 changes: 15 additions & 7 deletions tools/winlibs.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Build against protobuf libs compiled with Rtools
VERSION <- commandArgs(TRUE)
if (!file.exists(sprintf("../windows/protobuf-%s/include/google/protobuf/descriptor.h", VERSION))) {
if (getRversion() < "3.3.0") setInternet2()
download.file(sprintf("https://github.com/rwinlib/protobuf/archive/%s.zip", VERSION), "lib.zip", quiet = TRUE)
if(!file.exists("../windows/protobuf/include/google/protobuf/descriptor.h")){
unlink("../windows", recursive = TRUE)
url <- if(grepl("aarch", R.version$platform)){
"https://github.com/r-windows/bundles/releases/download/protobuf-21.12/protobuf-21.12-clang-aarch64.tar.xz"
} else if(getRversion() >= "4.3") {
# NB: does not work with rtools42
"https://github.com/r-windows/bundles/releases/download/protobuf-21.12/protobuf-21.12-ucrt-x86_64.tar.xz"
} else {
"https://github.com/rwinlib/protobuf/archive/v3.19.4-2.tar.gz"
}
download.file(url, basename(url), quiet = TRUE)
dir.create("../windows", showWarnings = FALSE)
unzip("lib.zip", exdir = "../windows")
unlink("lib.zip")
untar(basename(url), exdir = "../windows", tar = 'internal')
unlink(basename(url))
setwd("../windows")
file.rename(list.files(), 'protobuf')
}

0 comments on commit dcabf1c

Please sign in to comment.