Skip to content

Commit

Permalink
fix bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Jul 18, 2024
1 parent 6b1eea5 commit 44ea419
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ if(NANOARROW_BUNDLE)
REQUIRED)

# Set up arguments to the bundler
set(NANOARROW_BUNDLE_ARGS "--with-ipc" "--with-device" "--with-flatcc")
set(NANOARROW_BUNDLE_ARGS "--with-ipc" "--with-device" "--with-testing" "--with-flatcc")

if(NANOARROW_BUNDLE_AS_CPP)
list(APPEND NANOARROW_BUNDLE_ARGS "--cpp")
Expand All @@ -109,6 +109,8 @@ if(NANOARROW_BUNDLE)
set(NANOARROW_BUILD_INCLUDE_DIR "${CMAKE_BINARY_DIR}/bundled/include")
set(NANOARROW_IPC_BUILD_SOURCES "${CMAKE_BINARY_DIR}/bundled/src/nanoarrow_ipc.c")
set(NANOARROW_DEVICE_BUILD_SOURCES "${CMAKE_BINARY_DIR}/bundled/src/nanoarrow_device.c")
set(NANOARROW_TESTING_BUILD_SOURCES
"${CMAKE_BINARY_DIR}/bundled/src/nanoarrow_testing.cc")
set(NANOARROW_FLATCC_BUILD_SOURCES "${CMAKE_BINARY_DIR}/bundled/src/flatcc.c")
else()
# Generate the version information
Expand Down Expand Up @@ -316,10 +318,17 @@ if(NANOARROW_TESTING
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(NOT NANOARROW_BUNDLE)
set(NANOARROW_TESTING_BUILD_SOURCES src/nanoarrow/testing/testing.cc)
endif()

add_subdirectory("thirdparty/nlohmann_json")

add_library(nanoarrow_testing src/nanoarrow/testing/testing.cc)
target_include_directories(nanoarrow_testing PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src)
target_include_directories(nanoarrow_testing
PUBLIC $<BUILD_INTERFACE:${NANOARROW_BUILD_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src>
$<INSTALL_INTERFACE:include>)
target_link_libraries(nanoarrow_testing PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(nanoarrow_testing PUBLIC nanoarrow)
set_target_properties(nanoarrow_testing PROPERTIES POSITION_INDEPENDENT_CODE ON)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ python ci/scripts/bundle.py \
--header-namespace= \
--with-device \
--with-ipc \
--with-testing \
--with-flatcc
```

Expand Down
47 changes: 45 additions & 2 deletions ci/scripts/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ def bundle_nanoarrow(
# Generate files that don't need special handling
for filename in [
"nanoarrow.hpp",
"nanoarrow_testing.hpp",
"nanoarrow_gtest_util.hpp",
]:
content = read_content(src_dir / filename)
content = namespace_nanoarrow_includes(content, header_namespace)
Expand Down Expand Up @@ -213,6 +211,35 @@ def bundle_nanoarrow_ipc(
yield f"{output_source_dir}/nanoarrow_ipc.c", nanoarrow_ipc_c


def bundle_nanoarrow_testing(
root_dir,
header_namespace="nanoarrow/",
output_source_dir="src",
output_include_dir="include",
):
root_dir = pathlib.Path(root_dir)
src_dir = root_dir / "src" / "nanoarrow"

output_source_dir = pathlib.Path(output_source_dir)
output_include_dir = pathlib.Path(output_include_dir) / header_namespace

# Generate headers
for filename in [
"nanoarrow_testing.hpp",
"nanoarrow_gtest_util.hpp",
]:
content = read_content(src_dir / filename)
content = namespace_nanoarrow_includes(content, header_namespace)
yield f"{output_include_dir}/{filename}", content

nanoarrow_testing_cc = concatenate_content(
[
src_dir / "testing" / "testing.cc",
]
)
nanoarrow_testing_cc = namespace_nanoarrow_includes(nanoarrow_testing_cc, header_namespace)
yield f"{output_source_dir}/nanoarrow_testing.cc", nanoarrow_testing_cc

def bundle_flatcc(
root_dir,
output_source_dir="src",
Expand Down Expand Up @@ -309,6 +336,11 @@ def do_bundle(bundler):
help="Include nanoarrow_ipc sources/headers",
action="store_true",
)
parser.add_argument(
"--with-testing",
help="Include nanoarrow_testing sources/headers",
action="store_true",
)
parser.add_argument(
"--with-flatcc",
help="Include flatcc sources/headers",
Expand Down Expand Up @@ -357,6 +389,17 @@ def do_bundle(bundler):
)
)

# Bundle nanoarrow_testing
if args.with_testing:
do_bundle(
bundle_nanoarrow_testing(
root_dir,
header_namespace=args.header_namespace,
output_source_dir=args.source_output_dir,
output_include_dir=args.include_output_dir,
)
)

# Bundle flatcc
if args.with_flatcc:
do_bundle(
Expand Down

0 comments on commit 44ea419

Please sign in to comment.