Skip to content

Commit

Permalink
support unstable c api
Browse files Browse the repository at this point in the history
  • Loading branch information
samansmink committed Dec 4, 2024
1 parent 6764e09 commit 1c17757
Show file tree
Hide file tree
Showing 6 changed files with 453 additions and 260 deletions.
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ cmake_minimum_required(VERSION 2.8)
###
# Configuration
###
if(NOT DEFINED MINIMUM_DUCKDB_VERSION_MAJOR OR
NOT DEFINED MINIMUM_DUCKDB_VERSION_MINOR OR
NOT DEFINED MINIMUM_DUCKDB_VERSION_PATCH)
message(FATAL_ERROR "DuckDB minimum version is required")
if(NOT DEFINED TARGET_DUCKDB_VERSION_MAJOR OR
NOT DEFINED TARGET_DUCKDB_VERSION_MINOR OR
NOT DEFINED TARGET_DUCKDB_VERSION_PATCH)
message(FATAL_ERROR "DuckDB target version is required")

Check failure on line 9 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / Build extension binaries / Windows (windows_amd64, x64-windows-static-md)

DuckDB target version is required

Check failure on line 9 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / Build extension binaries / MacOS (osx_amd64, x86_64, x64-osx)

DuckDB target version is required

Check failure on line 9 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / Build extension binaries / MacOS (osx_amd64, x86_64, x64-osx)

DuckDB target version is required

Check failure on line 9 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / Build extension binaries / Windows (windows_amd64, x64-windows-static-md)

DuckDB target version is required
endif()
if(NOT DEFINED EXTENSION_NAME)
message(FATAL_ERROR "DuckDB extension name is required")
endif()
add_definitions(-DDUCKDB_EXTENSION_API_VERSION_MAJOR=${MINIMUM_DUCKDB_VERSION_MAJOR})
add_definitions(-DDUCKDB_EXTENSION_API_VERSION_MINOR=${MINIMUM_DUCKDB_VERSION_MINOR})
add_definitions(-DDUCKDB_EXTENSION_API_VERSION_PATCH=${MINIMUM_DUCKDB_VERSION_PATCH})
add_definitions(-DDUCKDB_EXTENSION_API_VERSION_MAJOR=${TARGET_DUCKDB_VERSION_MAJOR})
add_definitions(-DDUCKDB_EXTENSION_API_VERSION_MINOR=${TARGET_DUCKDB_VERSION_MINOR})
add_definitions(-DDUCKDB_EXTENSION_API_VERSION_PATCH=${TARGET_DUCKDB_VERSION_PATCH})
add_definitions(-DDUCKDB_EXTENSION_NAME=${EXTENSION_NAME})

if (DEFINED DUCKDB_EXTENSION_API_VERSION_UNSTABLE)
add_definitions(-DDUCKDB_EXTENSION_API_VERSION_UNSTABLE=${DUCKDB_EXTENSION_API_VERSION_UNSTABLE})
endif()

###
# Build
###
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

# Main extension configuration
EXTENSION_NAME=capi_quack
MINIMUM_DUCKDB_VERSION_MAJOR=0
MINIMUM_DUCKDB_VERSION_MINOR=0
MINIMUM_DUCKDB_VERSION_PATCH=1
MINIMUM_DUCKDB_VERSION=v$(MINIMUM_DUCKDB_VERSION_MAJOR).$(MINIMUM_DUCKDB_VERSION_MINOR).$(MINIMUM_DUCKDB_VERSION_PATCH)
TARGET_DUCKDB_VERSION_MAJOR=1
TARGET_DUCKDB_VERSION_MINOR=2
TARGET_DUCKDB_VERSION_PATCH=0
TARGET_DUCKDB_VERSION=v$(TARGET_DUCKDB_VERSION_MAJOR).$(TARGET_DUCKDB_VERSION_MINOR).$(TARGET_DUCKDB_VERSION_PATCH)

# Set to 1 to target the unstable C API.
USE_UNSTABLE_C_API=0

all: configure release

Expand Down
8 changes: 4 additions & 4 deletions duckdb_capi/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# DuckDB C API Headers
This directory contains the C API headers of DuckDB. These headers should generally match the `MINIMUM_DUCKDB_VERSION`
This directory contains the C API headers of DuckDB. These headers should generally match the `TARGET_DUCKDB_VERSION`
that is specified in the `Makefile`. Note that these headers can be updated automatically
to match the `MINIMUM_DUCKDB_VERSION` makefile variable by running (assuming the default makefile setup):
to match the `TARGET_DUCKDB_VERSION` makefile variable by running (assuming the default makefile setup):

```shell
make update_duckdb_headers
```

Of course manually updating the headers is also fine, just make sure that the headers are always from the same
DuckDB version and that they are not from a later release of DuckDB than is specified in the `MINIMUM_DUCKDB_VERSION`
build variable. Using headers from an older version than `MINIMUM_DUCKDB_VERSION` is allowed, but you probably don't want
DuckDB version and that they are not from a later release of DuckDB than is specified in the `TARGET_DUCKDB_VERSION`
build variable. Using headers from an older version than `TARGET_DUCKDB_VERSION` is allowed, but you probably don't want
that.
Loading

0 comments on commit 1c17757

Please sign in to comment.