Skip to content

Commit

Permalink
build gs pb file as static as well since dll cause numerous runtime e…
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejiang committed Jan 23, 2021
1 parent 6fd8eed commit 29a60f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pbLdFlags <- function() {
pb <- pbLibPath(suffix)
gs <- gsLibPath()
# res <- asBuildPath(pb)
res <- paste("-L", asBuildPath(dirname(pb)), " -lprotobuf -lGatingSet.pb", sep = "")
res <- paste(asBuildPath(gs), " -L", asBuildPath(dirname(pb)), " -lprotobuf ", sep = "")
} else {
res <- ""
}
Expand Down Expand Up @@ -85,7 +85,7 @@ gsLibPath <- function(suffix = "") {
libDir <- "lib/"
if (sysname == "Windows")
libDir <- paste(libDir, .Platform$r_arch, "/", sep="")
system.file(paste(libDir, pbSupported[[sysname]], sep = ""),
system.file(paste(libDir, "GatingSet.pb.o", sep = ""),
package = "RProtoBufLib")
} else {
NULL
Expand Down
2 changes: 1 addition & 1 deletion R/hooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dllInfo <- NULL
}

gs <- gsLibPath()
if (!is.null(gs)) {
if (!is.null(gs)&&Sys.info()['sysname']!="Windows") {
if (!file.exists(gs)) {
warning(paste("libGatingSet.pb library", gs, "not found."))
} else {
Expand Down
12 changes: 5 additions & 7 deletions src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,22 @@ USER_LIB_DIR=${R_PACKAGE_DIR}/lib$(R_ARCH)
CXX_STD = CXX11
PKG_CPPFLAGS =-I../inst/include/ -I$(RWINLIB)/include


#expose compiled object of GatingSet pb API for cytolib to link to
GS_LIB=libGatingSet.pb${DYLIB_EXT}
GS_LIB_DIR = GatingSet_pb_lib
GS_LIB = GatingSet_pb_lib/GatingSet.pb.o

all: copying

$(GS_LIB): winlibs
${SHLIB_CXXLD} ${SHLIB_CXXLDFLAGS} ${CXXPICFLAGS} ${PKG_CPPFLAGS} -o ${GS_LIB_DIR}/${GS_LIB} ${GS_LIB_DIR}/GatingSet.pb.cc $(RWINLIB)/lib$(R_ARCH)/libprotobuf.a



#copy pb library headers to package include
copying: $(GS_LIB)
mkdir -p ${USER_INCLUDE}
cp -r $(RWINLIB)/include/google ${USER_INCLUDE}
mkdir -p "${USER_LIB_DIR}"
cp $(RWINLIB)/lib$(R_ARCH)/libprotobuf.a "${USER_LIB_DIR}/libprotobuf.a"
cp ${GS_LIB_DIR}/$(GS_LIB) "${USER_LIB_DIR}/${GS_LIB}"
cp $(GS_LIB) "${USER_LIB_DIR}/GatingSet.pb.o"

$(GS_LIB): winlibs

#download prebuilt lib
winlibs:
Expand Down

0 comments on commit 29a60f9

Please sign in to comment.