Travis CI无法在R package子目录中找到头文件

问题描述 投票:0回答:1

我正在尝试建立Travis-CI来构建this R包。该包使用以下步骤在本地构建,这些步骤与Travis(构建here失败)的构建过程密切相关:

git clone --depth=50 --branch=master https://github.com/weinstockj/htslibr.git weinstockj/htslibr
cd weinstockj/htslibr/
git submodule update --init --recursive
cd htslibr/
R -e 'install.packages("Rcpp")'
R CMD build .

Travis失败并显示错误,表明它无法找到htslibr/src子目录中的头文件。为什么R CMD构建无法在Travis上找到标题(再次,本地没有问题)?

特拉维斯设置是here,在本地我也使用Ubuntu 16.04。

r travis-ci r-package
1个回答
0
投票

这里是失败的构建日志的摘录:

mkdir -p /tmp/Rtmpy1bhv4/Rinst23036acf1e4/htslibr/inst/include
cp htslib/htslib/*.h /tmp/Rtmpy1bhv4/Rinst23036acf1e4/htslibr/inst/include
g++ -std=gnu++11 -I"/home/travis/R-bin/lib/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include" -I/home/travis/R-bin/include   -fpic  -g -O2 -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/home/travis/R-bin/lib/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include" -I/home/travis/R-bin/include   -fpic  -g -O2 -c util.cpp -o util.o
util.cpp:2:24: fatal error: htslib/hts.h: No such file or directory

我们看到,当标题被复制到/tmp/Rtmpy1bhv4/Rinst23036acf1e4/htslibr/inst/include时,此目录不在包含路径中。您可以通过添加来解决此问题

PKG_CPPFLAGS = -I../inst/include -DSTRICT_R_HEADERS

MakevarsSTRICT_R_HEADERS不需要,但"best practice")和在#include <hts.h>使用util.cpp。但是,我不相信将头文件首先复制到inst/include是正确的。毕竟,这些头文件不代表您的packge提供给其他包的API。相反,它是您在内部打包使用的库的API。因此我建议不要复制头文件并使用

PKG_CPPFLAGS = -Ihtslib -DSTRICT_R_HEADERS

Makevars

顺便说一句,Writing R Extensions提出了针对目标的不同使用模式:

all: $(SHLIB)
$(SHLIB): <any other needed targets>

虽然如果你按照我的建议不要复制标题,这一点就无关紧要了。

© www.soinside.com 2019 - 2024. All rights reserved.