Skip to content

Commit 92461b4

Browse files
committed
Added windows specific makevars and config scripts for the R package
1 parent a84ce21 commit 92461b4

File tree

3 files changed

+82
-2
lines changed

3 files changed

+82
-2
lines changed

configure.win

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Script used to generate `Makevars.win` from `Makevars.win.in` on Windows
2+
# Adapted from LightGBM https://github.com/microsoft/LightGBM/blob/master/R-package/configure.win
3+
4+
###########################
5+
# find compiler and flags #
6+
###########################
7+
8+
R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R"
9+
CXX17=`"${R_EXE}" CMD config CXX17`
10+
CXX17STD=`"${R_EXE}" CMD config CXX17STD`
11+
CXX="${CXX17} ${CXX17STD}"
12+
CXXFLAGS=`"${R_EXE}" CMD config CXX17FLAGS`
13+
CXX_STD="CXX17"
14+
CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS`
15+
16+
# Stochtree-specific flags
17+
STOCHTREE_CPPFLAGS=""
18+
19+
#########
20+
# Eigen #
21+
#########
22+
23+
STOCHTREE_CPPFLAGS="${STOCHTREE_CPPFLAGS} -DEIGEN_MPL2_ONLY -DEIGEN_DONT_PARALLELIZE"
24+
25+
##########
26+
# OpenMP #
27+
##########
28+
29+
STOCHTREE_CPPFLAGS="${STOCHTREE_CPPFLAGS} -DSTOCHTREE_OPENMP_AVAILABLE"

cran-bootstrap.R

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ if (!dir.exists(cran_dir)) {
6060
src_files <- list.files("src", pattern = ".[^o]$", recursive = TRUE, full.names = TRUE)
6161
pybind_src_files <- list.files("src", pattern = "^(py_)", recursive = TRUE, full.names = TRUE)
6262
r_src_files <- src_files[!(src_files %in% pybind_src_files)]
63-
r_src_files <- r_src_files[!(r_src_files %in% c("src/Makevars"))]
63+
r_src_files <- r_src_files[!(r_src_files %in% c("src/Makevars", "src/Makevars.win"))]
6464
cat(r_src_files)
6565
pkg_core_files <- c(
6666
".Rbuildignore",
6767
"configure",
6868
"configure.ac",
69+
"configure.win",
6970
"cran-comments.md",
7071
"DESCRIPTION",
7172
"inst/COPYRIGHTS",
@@ -139,7 +140,7 @@ if (all(file.exists(pkg_core_files))) {
139140
}
140141
}
141142

142-
# Overwrite PKG_CPPFLAGS in src/Makevars
143+
# Overwrite PKG_CPPFLAGS in src/Makevars.in
143144
cran_makevars <- file.path(cran_dir, "src/Makevars.in")
144145
makevars_lines <- readLines(cran_makevars)
145146
makevars_lines[grep(" -I$(PKGROOT)/include \\", makevars_lines, fixed = T)] <- " -I$(PKGROOT)/src/include \\"
@@ -150,6 +151,17 @@ makevars_lines <- makevars_lines[-c(
150151
)]
151152
writeLines(makevars_lines, cran_makevars)
152153

154+
# Overwrite PKG_CPPFLAGS in src/Makevars.win.in
155+
cran_makevars_win <- file.path(cran_dir, "src/Makevars.win.in")
156+
makevars_win_lines <- readLines(cran_makevars_win)
157+
makevars_win_lines[grep(" -I$(PKGROOT)/include \\", makevars_win_lines, fixed = T)] <- " -I$(PKGROOT)/src/include \\"
158+
makevars_win_lines <- makevars_win_lines[-c(
159+
grep(" -I$(PKGROOT)/deps/eigen \\", makevars_win_lines, fixed = T),
160+
grep(" -I$(PKGROOT)/deps/fmt/include \\", makevars_win_lines, fixed = T),
161+
grep(" -I$(PKGROOT)/deps/fast_double_parser/include \\", makevars_win_lines, fixed = T)
162+
)]
163+
writeLines(makevars_win_lines, cran_makevars_win)
164+
153165
# Remove vignette deps from DESCRIPTION if no vignettes
154166
if (!include_vignettes) {
155167
cran_description <- file.path(cran_dir, "DESCRIPTION")

src/Makevars.win.in

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
CXX_STD = @CXX_STD@
2+
3+
PKGROOT=..
4+
5+
STOCHTREE_CPPFLAGS = \
6+
@STOCHTREE_CPPFLAGS@ \
7+
-DSTOCHTREE_R_BUILD
8+
9+
PKG_CPPFLAGS = \
10+
-I$(PKGROOT)/include \
11+
-I$(PKGROOT)/deps/eigen \
12+
-I$(PKGROOT)/deps/fmt/include \
13+
-I$(PKGROOT)/deps/fast_double_parser/include \
14+
$(STOCHTREE_CPPFLAGS)
15+
16+
PKG_CXXFLAGS = \
17+
${SHLIB_OPENMP_CXXFLAGS} \
18+
${SHLIB_PTHREAD_FLAGS}
19+
20+
PKG_LIBS = \
21+
${SHLIB_OPENMP_CXXFLAGS} \
22+
${SHLIB_PTHREAD_FLAGS}
23+
24+
OBJECTS = \
25+
forest.o \
26+
kernel.o \
27+
R_data.o \
28+
R_random_effects.o \
29+
sampler.o \
30+
serialization.o \
31+
cpp11.o \
32+
container.o \
33+
cutpoint_candidates.o \
34+
data.o \
35+
io.o \
36+
leaf_model.o \
37+
partition_tracker.o \
38+
random_effects.o \
39+
tree.o

0 commit comments

Comments
 (0)