Skip to content

Commit

Permalink
GDV-71:[C++]Made Gandiva JNI a packagable library. (apache#42)
Browse files Browse the repository at this point in the history
Modified the build to package the gandiva jni as a stand alone library that
can be packaged in the Gandiva JAR.

Also producing two versions of gandiva core - a static and a shared one.

Fixed LLVM dependencies to be target based.
  • Loading branch information
praveenbingo authored Jul 4, 2018
1 parent 8ce06fc commit d3cc004
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 47 deletions.
62 changes: 25 additions & 37 deletions cpp/src/gandiva/codegen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,55 @@ project(gandiva)
# Find arrow
find_package(ARROW)

find_package(Boost REQUIRED)
find_package(Boost COMPONENTS system regex filesystem REQUIRED)

set(BC_FILE_PATH_CC "${CMAKE_CURRENT_BINARY_DIR}/bc_file_path.cc")
configure_file(bc_file_path.cc.in ${BC_FILE_PATH_CC})

add_library(gandiva SHARED
annotator.cc
bitmap_accumulator.cc
configuration.cc
engine.cc
expr_decomposer.cc
expr_validator.cc
function_registry.cc
llvm_generator.cc
llvm_types.cc
projector.cc
status.cc
tree_expr_builder.cc
${BC_FILE_PATH_CC})
set(SRC_FILES annotator.cc
engine.cc
bitmap_accumulator.cc
configuration.cc
expr_decomposer.cc
expr_validator.cc
function_registry.cc
llvm_generator.cc
llvm_types.cc
projector.cc
status.cc
tree_expr_builder.cc
${BC_FILE_PATH_CC})

add_library(gandiva_obj_lib OBJECT ${SRC_FILES})

# set PIC so that object library can be included in shared libs.
set_target_properties(gandiva_obj_lib PROPERTIES POSITION_INDEPENDENT_CODE 1)

# For users of gandiva library (including integ tests), include-dir is :
# /usr/**/include dir after install,
# cpp/include during build
# For building gandiva library itself, include-dir (in addition to above) is :
# cpp/src
target_include_directories(gandiva
target_include_directories(gandiva_obj_lib
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
PRIVATE
${CMAKE_SOURCE_DIR}/src
$<TARGET_PROPERTY:LLVM::LLVM_INTERFACE,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:ARROW::ARROW_SHARED,INTERFACE_INCLUDE_DIRECTORIES>
)

# ARROW is a public dependency i.e users of gandiva also will have a dependency on arrow.
target_link_libraries(gandiva
PUBLIC
ARROW::ARROW
PRIVATE
Boost::boost)
build_gandiva_lib("shared")

# LLVM is a private dependency i.e users of gandiva will not need to include llvm headers
# or link with llvm libraries.
target_link_llvm(gandiva PRIVATE)

# Set version for the library.
set(GANDIVA_VERSION_MAJOR 0)
set(GANDIVA_VERSION_MINOR 1)
set(GANDIVA_VERSION_PATCH 0)
set(GANDIVA_VERSION ${GANDIVA_VERSION_MAJOR}.${GANDIVA_VERSION_MINOR}.${GANDIVA_VERSION_PATCH})

set_target_properties(gandiva PROPERTIES
VERSION ${GANDIVA_VERSION}
SOVERSION ${GANDIVA_VERSION_MAJOR}
)
build_gandiva_lib("static")

# install for gandiva
include(GNUInstallDirs)

# install libgandiva
install(
TARGETS gandiva
TARGETS gandiva_shared gandiva_static
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

Expand Down
17 changes: 9 additions & 8 deletions cpp/src/gandiva/integ/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

project(gandiva)

add_gandiva_integ_test(projector_test.cc)
add_gandiva_integ_test(if_expr_test.cc)
add_gandiva_integ_test(boolean_expr_test.cc)
add_gandiva_integ_test(literal_test.cc)
add_gandiva_integ_test(date_time_test.cc)
add_gandiva_integ_test(projector_build_validation_test.cc)
add_gandiva_integ_test(utf8_test.cc)
add_gandiva_integ_test(binary_test.cc)
foreach(lib_type "shared" "static")
add_gandiva_integ_test(projector_test.cc gandiva_${lib_type})
add_gandiva_integ_test(if_expr_test.cc gandiva_${lib_type})
add_gandiva_integ_test(literal_test.cc gandiva_${lib_type})
add_gandiva_integ_test(projector_build_validation_test.cc gandiva_${lib_type})
add_gandiva_integ_test(boolean_expr_test.cc gandiva_${lib_type})
add_gandiva_integ_test(utf8_test.cc gandiva_${lib_type})
add_gandiva_integ_test(binary_test.cc gandiva_${lib_type})
endforeach(lib_type)
4 changes: 2 additions & 2 deletions cpp/src/gandiva/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ target_include_directories(gandiva_jni
${CMAKE_SOURCE_DIR}/src
)

# PROTOBUF is a public dependency i.e users of gandiva also will have a dependency on arrow.
# PROTOBUF is a private dependency i.e users of gandiva also will not have a dependency on protobuf.
target_link_libraries(gandiva_jni
PRIVATE
protobuf::libprotobuf
gandiva
gandiva_static
)

0 comments on commit d3cc004

Please sign in to comment.