Skip to content

Commit 65616c1

Browse files
committed
add vcpkg, ninja
1 parent 4891496 commit 65616c1

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DuckDB C/C++ extension template
2-
This is an **experimental** template for C or C++ based extensions based on the C Extension API of DuckDB. Note that this
3-
is a different template from
2+
This is an **experimental** template for C/C++ based extensions that link with the **C Extension API** of DuckDB. Note that this
3+
is different from https://github.com/duckdb/extension-template, which links against the C++ API of DuckDB.
44

55
Features:
66
- No DuckDB build required
@@ -23,6 +23,7 @@ tooling to make life a little easier and to be able to share CI/CD infrastructur
2323
- [Make](https://www.gnu.org/software/make)
2424
- CMake
2525
- Git
26+
- (Optional) Ninja + ccache
2627

2728
Installing these dependencies will vary per platform:
2829
- For Linux, these come generally pre-installed or are available through the distro-specific package manager.
@@ -47,6 +48,14 @@ to the `build/debug` directory.
4748

4849
To create optimized release binaries, simply run `make release` instead.
4950

51+
### Faster builds
52+
We recommend to install Ninja and Ccache for building as this can have a significant speed boost during development. After installing, ninja can be used
53+
by running:
54+
```shell
55+
make clean
56+
GEN=ninja make debug
57+
```
58+
5059
## Testing
5160
This extension uses the DuckDB Python client for testing. This should be automatically installed in the `make configure` step.
5261
The tests themselves are written in the SQLLogicTest format, just like most of DuckDB's tests. A sample test can be found in

duckdb_capi/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DuckDB C API Headers
2-
This directory contains the C API headers of DuckDB. These headers should be of the same
3-
DuckDB version as is specified in `Makefile`. Note that these headers can be updated automatically
2+
This directory contains the C API headers of DuckDB. These headers should generally match the `MINIMUM_DUCKDB_VERSION`
3+
that is specified in the `Makefile`. Note that these headers can be updated automatically
44
to match the `MINIMUM_DUCKDB_VERSION` makefile variable by running (assuming the default makefile setup):
55

66
```shell

duckdb_extension_c.Makefile

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,44 @@
88
# MINIMUM_DUCKDB_VERSION_MINOR : minor version
99
# MINIMUM_DUCKDB_VERSION_PATCH : patch version
1010
# CMAKE_EXTRA_BUILD_FLAGS : additional CMake flags to pass
11+
# VCPKG_TOOLCHAIN_PATH : path to vcpkg toolchain
12+
# VCPKG_TARGET_TRIPLET : vcpkg triplet to override
13+
# GEN : allow specifying ninja as generator
1114

1215

1316
.PHONY: build_extension_library_debug build_extension_library_release update_duckdb_headers
1417

18+
#############################################
19+
### Base config
20+
#############################################
21+
1522
# Create build params to pass name and version
1623
CMAKE_VERSION_PARAMS = -DEXTENSION_NAME=$(EXTENSION_NAME)
17-
CMAKE_VERSION_PARAMS += -DMINIMUM_DUCKDB_VERSION=$(MINIMUM_DUCKDB_VERSION_MAJOR)
24+
CMAKE_VERSION_PARAMS += -DMINIMUM_DUCKDB_VERSION_MAJOR=$(MINIMUM_DUCKDB_VERSION_MAJOR)
1825
CMAKE_VERSION_PARAMS += -DMINIMUM_DUCKDB_VERSION_MINOR=$(MINIMUM_DUCKDB_VERSION_MINOR)
1926
CMAKE_VERSION_PARAMS += -DMINIMUM_DUCKDB_VERSION_PATCH=$(MINIMUM_DUCKDB_VERSION_PATCH)
2027

2128
CMAKE_BUILD_FLAGS = $(CMAKE_VERSION_PARAMS) $(CMAKE_EXTRA_BUILD_FLAGS)
2229

30+
#############################################
31+
### Vcpkg
32+
#############################################
33+
34+
ifneq ("${VCPKG_TOOLCHAIN_PATH}", "")
35+
CMAKE_BUILD_FLAGS += -DCMAKE_TOOLCHAIN_FILE='${VCPKG_TOOLCHAIN_PATH}'
36+
endif
37+
ifneq ("${VCPKG_TARGET_TRIPLET}", "")
38+
CMAKE_BUILD_FLAGS += -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}'
39+
endif
40+
41+
#############################################
42+
### Ninja
43+
#############################################
44+
45+
ifeq ($(GEN),ninja)
46+
CMAKE_BUILD_FLAGS += -G "Ninja"
47+
endif
48+
2349
#############################################
2450
### Rust Build targets
2551
#############################################

src/capi_quack.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "duckdb_extension.h"
2+
23
#include "add_numbers.h"
34

45
DUCKDB_EXTENSION_ENTRYPOINT(duckdb_connection connection, duckdb_extension_info info, duckdb_extension_access *access) {

0 commit comments

Comments
 (0)