Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: only build _ext and kernels #2813

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 14 additions & 37 deletions awkward-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@ Please check https://github.com/scikit-hep/awkward#installation-for-developers t
endif()

# Setup the RPATH for built libraries
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
message(STATUS "Using Emscripten")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
elseif(APPLE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path")
else()
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
jpivarski marked this conversation as resolved.
Show resolved Hide resolved
endif()

# Three tiers: [cpu-kernels (extern "C" interface), cuda-kernels (extern "C" interface)],
Expand All @@ -54,31 +50,21 @@ target_include_directories(awkward-parent INTERFACE rapidjson/include)
add_subdirectory(header-only EXCLUDE_FROM_ALL)
target_link_libraries(awkward-parent INTERFACE awkward::growable-buffer)

# First tier: cpu-kernels (object files, static library, and dynamic library).
add_library(awkward-cpu-kernels-objects OBJECT ${CPU_KERNEL_SOURCES})
set_target_properties(awkward-cpu-kernels-objects PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(awkward-cpu-kernels-objects PUBLIC awkward-parent)
# First tier: cpu-kernels
add_library(awkward-cpu-kernels SHARED ${CPU_KERNEL_SOURCES})
target_link_libraries(awkward-cpu-kernels PUBLIC awkward-parent)
set_target_properties(
awkward-cpu-kernels-objects
awkward-cpu-kernels
PROPERTIES CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
CXX_EXTENSIONS NO)

add_library(awkward-cpu-kernels-static STATIC $<TARGET_OBJECTS:awkward-cpu-kernels-objects>)
set_property(TARGET awkward-cpu-kernels-static PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(awkward-cpu-kernels-static PUBLIC awkward-parent)

add_library(awkward-cpu-kernels SHARED $<TARGET_OBJECTS:awkward-cpu-kernels-objects>)
target_link_libraries(awkward-cpu-kernels PUBLIC awkward-parent)

# Second tier: libawkward (object files, static library, and dynamic library).
add_library(awkward-objects OBJECT ${LIBAWKWARD_SOURCES})
set_target_properties(awkward-objects PROPERTIES POSITION_INDEPENDENT_CODE 1)
target_compile_definitions(awkward-objects PRIVATE LIBAWKWARD_EXPORT_SYMBOL=EXPORT_SYMBOL)
jpivarski marked this conversation as resolved.
Show resolved Hide resolved
# Second tier: libawkward
add_library(awkward SHARED ${LIBAWKWARD_SOURCES})
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
# Avoid emitting vtables in the dependent libraries
target_compile_options(
awkward-objects
awkward
PRIVATE -Werror=weak-vtables
-Wweak-vtables
-Wshorten-64-to-32
Expand All @@ -90,30 +76,21 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
-Wconversion
-Wunused)
endif()
target_link_libraries(awkward-objects PUBLIC awkward-parent)
target_link_libraries(awkward PUBLIC awkward-parent)
set_target_properties(
awkward-objects
awkward
PROPERTIES CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
CXX_EXTENSIONS NO)

add_library(awkward-static STATIC $<TARGET_OBJECTS:awkward-objects>)
set_property(TARGET awkward-static PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(awkward-static PRIVATE awkward-cpu-kernels-static ${CMAKE_DL_LIBS})
target_link_libraries(awkward-static PUBLIC awkward-parent)

add_library(awkward SHARED $<TARGET_OBJECTS:awkward-objects>)
target_link_libraries(awkward PRIVATE awkward-cpu-kernels-static ${CMAKE_DL_LIBS})
target_link_libraries(awkward PUBLIC awkward-parent)

# Third tier: Python modules.
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)

# Install python bindings
file(GLOB LAYOUT_SOURCES "src/python/*.cpp")
pybind11_add_module(_ext ${LAYOUT_SOURCES})
target_link_libraries(_ext PRIVATE awkward-static)
pybind11_add_module(_ext MODULE ${LAYOUT_SOURCES})
target_link_libraries(_ext PRIVATE awkward)
set_target_properties(
_ext
PROPERTIES CXX_VISIBILITY_PRESET hidden
Expand Down
50 changes: 25 additions & 25 deletions awkward-cpp/include/awkward/builder/ArrayBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace awkward {
/// @brief User interface to the Builder system: the ArrayBuilder is a
/// fixed reference while the Builder subclass instances change in
/// response to accumulating data.
class LIBAWKWARD_EXPORT_SYMBOL ArrayBuilder {
class EXPORT_SYMBOL ArrayBuilder {
public:
/// @brief Creates an ArrayBuilder from a full set of parameters.
///
Expand Down Expand Up @@ -244,131 +244,131 @@ namespace awkward {

extern "C" {
/// @brief C interface to {@link awkward::ArrayBuilder#length ArrayBuilder::length}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_length(void* arraybuilder,
int64_t* result);
/// @brief C interface to {@link awkward::ArrayBuilder#clear ArrayBuilder::clear}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_clear(void* arraybuilder);

/// @brief C interface to {@link awkward::ArrayBuilder#null ArrayBuilder::null}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_null(void* arraybuilder);

/// @brief C interface to {@link awkward::ArrayBuilder#boolean ArrayBuilder::boolean}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_boolean(void* arraybuilder,
bool x);

/// @brief C interface to {@link awkward::ArrayBuilder#integer ArrayBuilder::integer}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_integer(void* arraybuilder,
int64_t x);

/// @brief C interface to {@link awkward::ArrayBuilder#real ArrayBuilder::real}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_real(void* arraybuilder,
double x);

/// @brief C interface to {@link awkward::ArrayBuilder#complex ArrayBuilder::complex}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_complex(void* arraybuilder,
double real,
double imag);

/// @brief C interface to {@link awkward::ArrayBuilder#datetime ArrayBuilder::datetime}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_datetime(void* arraybuilder,
int64_t x,
const char* unit);

/// @brief C interface to {@link awkward::ArrayBuilder#timedelta ArrayBuilder::timedelta}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_timedelta(void* arraybuilder,
int64_t x,
const char* unit);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#bytestring ArrayBuilder::bytestring}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_bytestring(void* arraybuilder,
const char* x);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#bytestring ArrayBuilder::bytestring}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_bytestring_length(void* arraybuilder,
const char* x,
int64_t length);

/// @brief C interface to {@link awkward::ArrayBuilder#string ArrayBuilder::string}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_string(void* arraybuilder,
const char* x);

/// @brief C interface to {@link awkward::ArrayBuilder#string ArrayBuilder::string}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_string_length(void* arraybuilder,
const char* x,
int64_t length);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#beginlist ArrayBuilder::beginlist}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_beginlist(void* arraybuilder);

/// @brief C interface to {@link awkward::ArrayBuilder#endlist ArrayBuilder::endlist}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_endlist(void* arraybuilder);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#begintuple ArrayBuilder::begintuple}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_begintuple(void* arraybuilder,
int64_t numfields);

/// @brief C interface to {@link awkward::ArrayBuilder#index ArrayBuilder::index}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_index(void* arraybuilder,
int64_t index);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#endtuple ArrayBuilder::endtuple}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_endtuple(void* arraybuilder);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#beginrecord ArrayBuilder::beginrecord}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_beginrecord(void* arraybuilder);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#beginrecord_fast ArrayBuilder::beginrecord_fast}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_beginrecord_fast(void* arraybuilder,
const char* name);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#beginrecord_check ArrayBuilder::beginrecord_check}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_beginrecord_check(void* arraybuilder,
const char* name);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#field_fast ArrayBuilder::field_fast}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_field_fast(void* arraybuilder,
const char* key);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#field_check ArrayBuilder::field_check}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_field_check(void* arraybuilder,
const char* key);

/// @brief C interface to
/// {@link awkward::ArrayBuilder#endrecord ArrayBuilder::endrecord}.
LIBAWKWARD_EXPORT_SYMBOL uint8_t
EXPORT_SYMBOL uint8_t
awkward_ArrayBuilder_endrecord(void* arraybuilder);
}

Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/BoolBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace awkward {
/// @class BoolBuilder
///
/// @brief Builder node that accumulates boolean values.
class LIBAWKWARD_EXPORT_SYMBOL BoolBuilder: public Builder {
class EXPORT_SYMBOL BoolBuilder: public Builder {
public:
/// @brief Create an empty BoolBuilder.
/// @param options Configuration options for building an array;
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace awkward {
///
/// @brief Abstract base class for nodes within an ArrayBuilder that
/// cumulatively discover an array's type and fill it.
class LIBAWKWARD_EXPORT_SYMBOL Builder: public std::enable_shared_from_this<Builder> {
class EXPORT_SYMBOL Builder: public std::enable_shared_from_this<Builder> {
public:
/// @brief Virtual destructor acts as a first non-inline virtual function
/// that determines a specific translation unit in which vtable shall be
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/Complex128Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace awkward {
/// @class Complex128Builder
///
/// @brief Builder node that accumulates real numbers (`double`).
class LIBAWKWARD_EXPORT_SYMBOL Complex128Builder: public Builder {
class EXPORT_SYMBOL Complex128Builder: public Builder {
public:
/// @brief Create an empty Complex128Builder.
/// @param options Configuration options for building an array;
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/DatetimeBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace awkward {
/// @class DatetimeBuilder
///
/// @brief Builder node that accumulates integers (`int64_t`).
class LIBAWKWARD_EXPORT_SYMBOL DatetimeBuilder: public Builder {
class EXPORT_SYMBOL DatetimeBuilder: public Builder {
public:
/// @brief Create an empty DatetimeBuilder.
/// @param options Configuration options for building an array;
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/Float64Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace awkward {
/// @class Float64Builder
///
/// @brief Builder node that accumulates real numbers (`double`).
class LIBAWKWARD_EXPORT_SYMBOL Float64Builder: public Builder {
class EXPORT_SYMBOL Float64Builder: public Builder {
public:
/// @brief Create an empty Float64Builder.
/// @param options Configuration options for building an array;
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/Int64Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace awkward {
/// @class Int64Builder
///
/// @brief Builder node that accumulates integers (`int64_t`).
class LIBAWKWARD_EXPORT_SYMBOL Int64Builder: public Builder {
class EXPORT_SYMBOL Int64Builder: public Builder {
public:
/// @brief Create an empty Int64Builder.
/// @param options Configuration options for building an array;
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/ListBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace awkward {
/// @class ListBuilder
///
/// @brief Builder node that accumulates lists.
class LIBAWKWARD_EXPORT_SYMBOL ListBuilder: public Builder {
class EXPORT_SYMBOL ListBuilder: public Builder {
public:
/// @brief Create an empty ListBuilder.
/// @param options Configuration options for building an array;
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/OptionBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace awkward {
/// @class OptionBuilder
///
/// @brief Builder node that accumulates data with missing values (`None`).
class LIBAWKWARD_EXPORT_SYMBOL OptionBuilder: public Builder {
class EXPORT_SYMBOL OptionBuilder: public Builder {
public:
/// @brief Create an OptionBuilder from a number of nulls (all missing).
/// @param options Configuration options for building an array;
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/RecordBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace awkward {
/// @class RecordBuilder
///
/// @brief Builder node for accumulated records.
class LIBAWKWARD_EXPORT_SYMBOL RecordBuilder: public Builder {
class EXPORT_SYMBOL RecordBuilder: public Builder {
public:
/// @brief Create an empty RecordBuilder.
/// @param options Configuration options for building an array;
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/StringBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace awkward {
/// @class StringBuilder
///
/// @brief Builder node that accumulates strings.
class LIBAWKWARD_EXPORT_SYMBOL StringBuilder: public Builder {
class EXPORT_SYMBOL StringBuilder: public Builder {
public:
/// @brief Create an empty StringBuilder.
/// @param options Configuration options for building an array;
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/TupleBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace awkward {
/// @class TupleBuilder
///
/// @brief Builder node for accumulated tuples.
class LIBAWKWARD_EXPORT_SYMBOL TupleBuilder: public Builder {
class EXPORT_SYMBOL TupleBuilder: public Builder {
public:
/// @brief Create an empty TupleBuilder.
/// @param options Configuration options for building an array;
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/UnionBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace awkward {
/// @class UnionBuilder
///
/// @brief Builder node for accumulated heterogeneous data.
class LIBAWKWARD_EXPORT_SYMBOL UnionBuilder: public Builder {
class EXPORT_SYMBOL UnionBuilder: public Builder {
public:
static const BuilderPtr
fromsingle(const BuilderOptions& options,
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/include/awkward/builder/UnknownBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace awkward {
/// @class UnknownBuilder
///
/// @brief Builder node for accumulated data whose type is not yet known.
class LIBAWKWARD_EXPORT_SYMBOL UnknownBuilder: public Builder {
class EXPORT_SYMBOL UnknownBuilder: public Builder {
public:
/// @brief Create an empty UnknownBuilder.
/// @param options Configuration options for building an array;
Expand Down
6 changes: 1 addition & 5 deletions awkward-cpp/include/awkward/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
#define EXPORT_TEMPLATE_INST EXPORT_SYMBOL
#endif

#ifndef LIBAWKWARD_EXPORT_SYMBOL
#define LIBAWKWARD_EXPORT_SYMBOL
#endif

#include <iostream>
#include <algorithm>
#include <map>
Expand All @@ -53,7 +49,7 @@
#include <cstring>

extern "C" {
struct LIBAWKWARD_EXPORT_SYMBOL Error {
struct EXPORT_SYMBOL Error {
const char* str;
const char* filename;
int64_t identity;
Expand Down
Loading
Loading