Skip to content

Commit a1628f6

Browse files
committed
add new configure
1 parent de0e2ef commit a1628f6

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

.github/workflows/R-CMD-check.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ jobs:
4848
extra-packages: any::rcmdcheck
4949
needs: check
5050

51+
- name: Install cpp11armadillo
52+
run: |
53+
options(warn = 2)
54+
pak::local_install_dev_deps("cpp11armadillo", dependencies = TRUE)
55+
install.packages(".", repos = NULL, type = "source")
56+
shell: Rscript {0}
57+
5158
- name: Install cpp11armadillotest
5259
if: matrix.config.custom != 'no-cpp11armadillotest'
5360
run: |

configure

+19-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# We make sure that the R and Armadillo bindings are compatible (i.e., messages)
44
# this is why we add the R and cpp11 path
55
CXX=`${R_HOME}/bin/R CMD config CXX`
6-
R_INCLUDE_PATH=`${R_HOME}/bin/R CMD config --cflags`
6+
R_INCLUDE_PATH=`${R_HOME}/bin/R CMD config --cppflags`
7+
R_LDFLAGS=`${R_HOME}/bin/R CMD config --ldflags`
78
CPP11_INCLUDE_PATH=`${R_HOME}/bin/Rscript -e "cat(system.file('include', package = 'cpp11'))"`
89

910
# Check if CPP11_INCLUDE_PATH is empty
@@ -12,18 +13,23 @@ if [ -z "$CPP11_INCLUDE_PATH" ]; then
1213
exit 1
1314
fi
1415

15-
# Manually specify the R include path if --cflags does not provide it
16-
if [ "$R_INCLUDE_PATH" = "ERROR: no information for variable '--cflags'" ]; then
17-
R_INCLUDE_PATH="-I/usr/share/R/include"
18-
fi
16+
# Get the absolute path to the inst/include directory
17+
INST_INCLUDE_PATH=$(cd "$(dirname "$0")/inst/include" && pwd)
1918

20-
PKG_CFLAGS="-I./inst/include ${R_INCLUDE_PATH} -I${CPP11_INCLUDE_PATH}"
19+
PKG_CFLAGS="${R_INCLUDE_PATH} -I${CPP11_INCLUDE_PATH} -I${INST_INCLUDE_PATH}"
20+
PKG_LDFLAGS="${R_LDFLAGS}"
2121

2222
# Debugging: Print the values of the variables
23+
echo "=================================="
24+
echo " Compiler Configuration Variables "
25+
echo " "
2326
echo "CXX: ${CXX}"
2427
echo "R_INCLUDE_PATH: ${R_INCLUDE_PATH}"
28+
echo "R_LDFLAGS: ${R_LDFLAGS}"
2529
echo "CPP11_INCLUDE_PATH: ${CPP11_INCLUDE_PATH}"
30+
echo "INST_INCLUDE_PATH: ${INST_INCLUDE_PATH}"
2631
echo "PKG_CFLAGS: ${PKG_CFLAGS}"
32+
echo "PKG_LDFLAGS: ${PKG_LDFLAGS}"
2733

2834
# Create a temporary C++ file to test the compatibility with Armadillo
2935
cat <<EOF> conftest.cpp
@@ -35,13 +41,16 @@ int main() {
3541
}
3642
EOF
3743
38-
# Test Armadillo using R CMD SHLIB
39-
if ! ${R_HOME}/bin/R CMD SHLIB conftest.cpp ${PKG_CFLAGS}
44+
# Test Armadillo using g++
45+
echo "==================================="
46+
echo " Testing minimal Armadillo example "
47+
echo " "
48+
if ! ${CXX} ${PKG_CFLAGS} conftest.cpp ${PKG_LDFLAGS} -o conftest
4049
then
4150
echo "Armadillo is not compatible with the C++ compiler used by R."
42-
rm -f conftest.cpp conftest.o conftest.so
51+
rm -f conftest.cpp conftest.o conftest
4352
exit 1
4453
else
4554
echo "Armadillo is compatible with the C++ compiler used by R."
46-
rm -f conftest.cpp conftest.o conftest.so
55+
rm -f conftest.cpp conftest.o conftest
4756
fi

0 commit comments

Comments
 (0)