[R-pkg-devel] Multiple architectures on Windows

Dirk Eddelbuettel edd at debian.org
Tue Jan 24 23:20:30 CET 2017


Sean,

You could look at the packages Rblpapi and x13binary both of which do
something a little nonstandard, but arch dependent.  You can either 'hit it'
in the configure or the make step.  I can detail if needed.

x13binary is smaller. It just pulls the Census binary in, for Windows that is
precompiled.  Here is its configure.win:

-----------------------------------------------------------------------------
#!/bin/sh
cwd=$(pwd)
cd inst

r_script="${R_HOME}/bin${R_ARCH_BIN}/Rscript"
set_internet2=`"${r_script}" -e "cat(ifelse(compareVersion(paste(R.Version()['major'], R.Version()['minor'], sep = '.'), '3.2.2') > 0, '', 'setInternet2();'))"`

"${r_script}" -e "${set_internet2} download.file('https://github.com/x13org/x13prebuilt/raw/master/v1.1.26/windows/x13ashtml.zip', 'x13ashtml.zip', quiet = TRUE, mode = \"wb\")"
unzip -u x13ashtml.zip
cp x13ashtml/x13ashtml.exe bin
rm x13ashtml.zip
rm -R x13ashtml
cd ${cwd}

exit 0
-----------------------------------------------------------------------------


Similarly, here is src/Makevars.win for Rblpapi -- it needs a library we
fetch from Bloomberg (in configure.win) but unpack as needed:

-----------------------------------------------------------------------------
## -*- mode: Makefile; tab-width: 8 -*-
##
##  Makefile.win -- Windows build system
##
##  Copyright (C) 2015  Whit Armstrong and Dirk Eddelbuettel
##
##  This file is part of Rblpapi
##
##  Rblpapi is free software: you can redistribute it and/or modify
##  it under the terms of the GNU General Public License as published by
##  the Free Software Foundation, either version 2 of the License, or
##  (at your option) any later version.
##
##  Rblpapi is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with Rblpapi.  If not, see <http://www.gnu.org/licenses/>.


## Distinguish between 32 and 64 bit windows
ifeq "$(WIN)" "64"
    FLV = x64
else
    FLV = i386
endif

## Standard compiler / linker flags including windows flavor
CXX_STD = CXX11
PKG_CPPFLAGS = -I../inst/include -I.
PKG_LIBS = -lblpapi3_${WIN} -L${FLV}


## SHLIB target is built by R, blpLibrary is a target we use to expand the tar.gz
all:    	blpLibrary $(SHLIB)

## target to ensure tar.gz files get unpacked
## the opening '@' ensures operations are executed 'quietly'
## in order to see commands as they happens add a 'v' to the tar and cp commands
## curl has '-k' flag to suppress certificate warnings
blpLibrary:
		@if [ ! -d ../inst ]; then mkdir -p ../inst; fi
		@if [ ! -d ../blp/win/${FLV} ]; then mkdir -p ../blp/win/${FLV}; fi
		@if [ ! -f ../blp/win/${FLV}/blpHeaders.tar.gz ]; then curl -s -k -L -O https://github.com/Rblp/blp/raw/master/headers/windows/blpHeaders.tar.gz; mv blpHeaders.tar.gz ../blp/win/${FLV}; tar xfz ../blp/win/${FLV}/blpHeaders.tar.gz -C ../inst; fi
		@if [ ! -f ../blp/win/${FLV}/blpLibrary.tar.gz ]; then curl -s -k -L -O https://github.com/Rblp/blp/raw/master/win${WIN}/blpLibrary.tar.gz; mv blpLibrary.tar.gz ../blp/win/${FLV}; tar xfz ../blp/win/${FLV}/blpLibrary.tar.gz; fi
		@if [ ! -d ${FLV} ]; then mkdir -p ${FLV}; fi
		@cp blpapi3_${WIN}.dll ${FLV}
		@if [ ! -d ../inst/libs/${FLV} ]; then mkdir -p ../inst/libs/${FLV}; fi
		@cp blpapi3_${WIN}.dll ../inst/libs/${FLV}

## Ensure the blpLibrary target is always executed
.Phony:		blpLibrary

-----------------------------------------------------------------------------

Hth,  Dirk


-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-package-devel mailing list