Skip to content

feat: Introduce C FFI for iceberg rust #966

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

Closed
wants to merge 11 commits into from
Closed
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
55 changes: 55 additions & 0 deletions .github/workflows/bindings_c_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Bindings C CI

on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
paths:
- "bindings/c/**"
- "core/**"
- ".github/workflows/ci_bindings_c.yml"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build C binding
working-directory: "bindings/c"
run: |
mkdir build && cd build
cmake ..

- name: Check diff
run: git diff --exit-code
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ members = [
"crates/sqllogictest",
"crates/test_utils",
]
exclude = ["bindings/python"]
exclude = ["bindings/c", "bindings/python"]

[workspace.package]
version = "0.4.0"
Expand Down
18 changes: 18 additions & 0 deletions bindings/c/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

build/
61 changes: 61 additions & 0 deletions bindings/c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

cmake_minimum_required(VERSION 3.24)
cmake_policy(SET CMP0135 NEW)

project(iceberg-c)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()

# force the compiler to support these standards
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CARGO_DIST_DIR "${PROJECT_SOURCE_DIR}/target/debug")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CARGO_BUILD_TYPE "--release")
set(CARGO_DIST_DIR "${PROJECT_SOURCE_DIR}/target/release")
endif()

set(ICEBERG_STATIC_LIB "${CARGO_DIST_DIR}/libiceberg_c${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(ICEBERG_SHARED_LIB "${CARGO_DIST_DIR}/libiceberg_c${CMAKE_SHARED_LIBRARY_SUFFIX}")
message(NOTICE "-- Iceberg C static lib: ${ICEBERG_STATIC_LIB}")
message(NOTICE "-- Iceberg C shared lib: ${ICEBERG_SHARED_LIB}")

# custom target for cargo build
add_custom_target(cargo_build
COMMAND cargo build ${CARGO_BUILD_TYPE}
BYPRODUCTS ${ICEBERG_STATIC_LIB} ${ICEBERG_SHARED_LIB}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)

# cmake target for static lib
add_library(iceberg_c_static INTERFACE)
target_link_libraries(iceberg_c_static INTERFACE ${ICEBERG_STATIC_LIB})
target_include_directories(iceberg_c_static INTERFACE include)
add_dependencies(iceberg_c_static cargo_build)

# cmake target for shared lib
add_library(iceberg_c_shared INTERFACE)
target_link_libraries(iceberg_c_shared INTERFACE ${ICEBERG_SHARED_LIB})
target_include_directories(iceberg_c_shared INTERFACE include)
add_dependencies(iceberg_c_shared cargo_build)
Loading
Loading