Skip to content

Commit acb8081

Browse files
committed
Initial extraction from web4
Lifts sdk/cgo to a standalone module that produces libpilot.{dylib,so,dll} via 'make build' (go build -buildmode=c-shared). - bindings.go: //export C functions (pilot_init/send/recv/close/...) - embedded.go: in-process daemon construction with all standard plugins - Makefile: cross-platform build target - 1000 LOC of Go that becomes a 10MB shared library Consumers (Node, Python SDKs) link via FFI to the dylib + libpilot.h header pair the build emits.
0 parents  commit acb8081

7 files changed

Lines changed: 1130 additions & 0 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
libpilot.dylib
2+
libpilot.so
3+
libpilot.dll
4+
libpilot.h

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.PHONY: build clean test
2+
3+
# Detect platform → extension
4+
UNAME_S := $(shell uname -s)
5+
ifeq ($(UNAME_S),Darwin)
6+
EXT := dylib
7+
endif
8+
ifeq ($(UNAME_S),Linux)
9+
EXT := so
10+
endif
11+
ifeq ($(OS),Windows_NT)
12+
EXT := dll
13+
endif
14+
15+
LIB := libpilot.$(EXT)
16+
17+
build:
18+
go build -buildmode=c-shared -o $(LIB) .
19+
@echo "built $(LIB) + libpilot.h"
20+
21+
clean:
22+
rm -f libpilot.* libpilot
23+
24+
test:
25+
go test ./...

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# libpilot
2+
3+
Pilot Protocol C ABI. Builds a shared library
4+
(`libpilot.dylib` / `libpilot.so` / `libpilot.dll`) that other
5+
language SDKs link against via FFI:
6+
7+
- **pilot-protocol/sdk-node** — Node.js via `koffi`
8+
- **pilot-protocol/sdk-python** — Python via `ctypes`
9+
- (future) Swift, Rust, etc.
10+
11+
The library embeds a full pilot daemon plus all the standard plugins
12+
(handshake, policy, runtime, skillinject, trustedagents, dataexchange,
13+
eventstream, webhook). FFI clients get a single in-process pilot node.
14+
15+
## Layout
16+
17+
| File | What it does |
18+
|---|---|
19+
| `bindings.go` | The exported `//export` C functions: `pilot_init`, `pilot_send`, `pilot_recv`, `pilot_close`, etc. |
20+
| `embedded.go` | In-process daemon construction (runtime + plugins). |
21+
22+
## Build
23+
24+
```bash
25+
make build # produces libpilot.<ext> + libpilot.h
26+
make clean
27+
```
28+
29+
The output `libpilot.h` is the C header consumers include or generate
30+
bindings against. The `.dylib`/`.so`/`.dll` is the runtime library.
31+
32+
## Releasing
33+
34+
Release workflow builds binaries for `linux/{amd64,arm64}`,
35+
`darwin/{amd64,arm64}`, `windows/amd64` and attaches them to the
36+
GitHub release. SDK repos pull the matching artifacts in their own
37+
release pipelines.
38+
39+
## Why a separate repo
40+
41+
CGo binaries don't compose well with pure-Go modules — putting the
42+
`cgo` blob in the protocol repo's main module would force every
43+
consumer onto a CGo-capable toolchain. Splitting it out keeps the
44+
protocol modules pure-Go.

0 commit comments

Comments
 (0)