-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (130 loc) · 6.2 KB
/
Copy pathMakefile
File metadata and controls
153 lines (130 loc) · 6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Convenience wrapper around the CMake build for erpl-rev.
#
# make build configure (if needed) + compile server and tests
# make test build + run the Catch2 unit tests (real DuckDB, no mocks)
# make run build + run the RFC server (registers at the SAP gateway)
# make e2e full end-to-end test against the live A4H docker system
# make start-sap (re)start the A4H trial with the gateway ACL open
# make clean remove the build directory
#
# The SAP NW RFC SDK lives under nwrfcsdk/linux at the repo root (gitignored —
# see README). Override the SDK location if it lives elsewhere:
# make build NWRFC_HOME=/path/to/nwrfcsdk/linux
#
# Portable deps (Catch2) come from vcpkg in manifest mode. Point VCPKG_ROOT at
# an external vcpkg checkout:
# make build VCPKG_ROOT=/path/to/vcpkg
NWRFC_HOME ?= $(CURDIR)/nwrfcsdk/linux
NWRFC_LIB := $(NWRFC_HOME)/lib
BUILD_DIR := build
# DuckDB engine. Built from the pinned `duckdb/` submodule and linked
# statically, so the server is the whole distributable -- no libduckdb beside
# it, no launcher unpacking one at first run.
#
# STATIC_DUCKDB=OFF falls back to the prebuilt distribution in DUCKDB_DIST
# (fetched by `make duckdb-dist`), which builds in seconds instead of minutes
# and is the faster loop when the change has nothing to do with DuckDB.
DUCKDB_VERSION ?= 1.5.5
DUCKDB_DIST ?= $(CURDIR)/vendor/duckdb-$(DUCKDB_VERSION)
STATIC_DUCKDB ?= ON
# Which NW RFC C ABI to build against: `sdk` (SAP's, vendored under nwrfcsdk/)
# or `proto` (erpl-proto's pure-Rust shim, which also supplies sapnwrfc.h, so no
# SAP download is needed at all):
# make build RFC_BACKEND=proto ERPL_PROTO_ROOT=/path/to/erpl-proto
RFC_BACKEND ?= sdk
RFC_LINK ?= shared
ERPL_PROTO_ROOT ?=
# Override DUCKDB_URL/DUCKDB_SHA256 for non-Linux dists (osx-universal / windows-amd64).
DUCKDB_URL ?= https://github.com/duckdb/duckdb/releases/download/v$(DUCKDB_VERSION)/libduckdb-linux-amd64.zip
# Pinned SHA256 of libduckdb-linux-amd64.zip v1.5.4 — verified on download (supply
# DUCKDB_SHA256= for another version).
DUCKDB_SHA256 ?= 838d98a85e697bab9935010c88a8c67d3312ccedcab4cb4a0ba01da65113bb70
DUCKDB_LIB := $(DUCKDB_DIST)
# vcpkg manifest-mode integration (statically links Catch2 via x64-linux).
VCPKG_ROOT ?= $(HOME)/.local/share/vcpkg
VCPKG_TOOLCHAIN := $(VCPKG_ROOT)/scripts/buildsystems/vcpkg.cmake
VCPKG_TRIPLET ?= x64-linux
VCPKG_FLAGS := -DCMAKE_TOOLCHAIN_FILE=$(VCPKG_TOOLCHAIN) \
-DVCPKG_TARGET_TRIPLET=$(VCPKG_TRIPLET) \
-DVCPKG_HOST_TRIPLET=$(VCPKG_TRIPLET)
# libsapnwrfc.so dlopen()s the ICU libs by name at runtime, so the server (and
# anything linking libduckdb.so) needs these dirs on LD_LIBRARY_PATH.
# Under the proto backend the SAP lib dir is deliberately kept OFF the path: if
# anything still reached for libsapnwrfc or ICU the run would fail here rather
# than quietly succeed on a leftover.
ifeq ($(RFC_BACKEND),proto)
RUN_ENV := LD_LIBRARY_PATH=$(ERPL_PROTO_ROOT)/target/release:$(DUCKDB_LIB)
else
RUN_ENV := LD_LIBRARY_PATH=$(NWRFC_LIB):$(DUCKDB_LIB)
endif
# Prefer Ninja when available, else fall back to Make generator.
GENERATOR := $(shell command -v ninja >/dev/null 2>&1 && echo Ninja || echo "Unix Makefiles")
DIST ?= dist
.PHONY: all build configure test run run-mem run-no-quack e2e duckdb-dist submodules start-sap clean bundle
all: build
# The distributable IS the server: DuckDB is linked in, so there is nothing to
# stage, pack or self-extract. Kept as a target so `make bundle` still does the
# expected thing for anyone with it in muscle memory.
bundle: build
mkdir -p $(DIST)
cp $(BUILD_DIR)/erpl_rev_server $(DIST)/erpl-rev
# Fetch the official prebuilt DuckDB distribution (libduckdb.so + duckdb.hpp).
duckdb-dist: $(DUCKDB_DIST)/libduckdb.so
$(DUCKDB_DIST)/libduckdb.so:
mkdir -p $(DUCKDB_DIST)
curl -sL --fail -o $(DUCKDB_DIST)/dist.zip $(DUCKDB_URL)
echo "$(DUCKDB_SHA256) $(DUCKDB_DIST)/dist.zip" | sha256sum -c - \
|| { echo "ERROR: DuckDB download checksum mismatch"; rm -f $(DUCKDB_DIST)/dist.zip; exit 1; }
cd $(DUCKDB_DIST) && unzip -o dist.zip && rm -f dist.zip
CONFIGURE_DEPS := submodules
ifneq ($(STATIC_DUCKDB),ON)
CONFIGURE_DEPS += duckdb-dist # only the prebuilt path needs the zip
endif
ifeq ($(RFC_BACKEND),proto)
CONFIGURE_DEPS += proto-shim
endif
configure: $(CONFIGURE_DEPS)
cmake -S . -B $(BUILD_DIR) -G "$(GENERATOR)" \
-DCMAKE_BUILD_TYPE=Release -DSAPNWRFC_HOME=$(NWRFC_HOME) \
-DERPL_REV_STATIC_DUCKDB=$(STATIC_DUCKDB) \
-DDUCKDB_DIST=$(DUCKDB_DIST) -DDUCKDB_VERSION=$(DUCKDB_VERSION) \
-DRFC_BACKEND=$(RFC_BACKEND) -DRFC_LINK=$(RFC_LINK) \
-DERPL_PROTO_ROOT=$(ERPL_PROTO_ROOT) \
$(VCPKG_FLAGS)
# erpl-proto's nwrfc shim; only needed for RFC_BACKEND=proto. The crate emits
# the shared object and the static archive together, so this serves both links.
proto-shim:
@test -n "$(ERPL_PROTO_ROOT)" || { echo "set ERPL_PROTO_ROOT=<erpl-proto checkout>"; exit 1; }
cargo build --release -p erpl-proto-nwrfc --manifest-path $(ERPL_PROTO_ROOT)/Cargo.toml
# The telemetry lib (third_party/posthog-telemetry) is a git submodule.
submodules:
@git submodule update --init --recursive third_party/posthog-telemetry
ifeq ($(STATIC_DUCKDB),ON)
@git submodule update --init --recursive duckdb
endif
build: configure
cmake --build $(BUILD_DIR)
test: build
$(RUN_ENV) ./$(BUILD_DIR)/erpl_rev_tests
# Run the RFC server WITH the quack network server enabled. Override the bind
# address with QUACK_LISTEN (default loopback; use quack:0.0.0.0:9494 to expose).
QUACK_LISTEN ?= quack:localhost
# File-backed by default (data survives restarts); override the path with DB=,
# or use `make run-mem` for a throwaway in-memory DB.
DB ?= erpl-rev.duckdb
run: build
$(RUN_ENV) ERPL_REV_QUACK_LISTEN=$(QUACK_LISTEN) ERPL_REV_DB_PATH=$(DB) \
./$(BUILD_DIR)/erpl_rev_server --quack
# Same, but a throwaway in-memory DB (no persistence across restarts).
run-mem: build
$(RUN_ENV) ERPL_REV_QUACK_LISTEN=$(QUACK_LISTEN) ERPL_REV_DB_PATH=:memory: \
./$(BUILD_DIR)/erpl_rev_server --quack
# RFC server only, without the quack network server.
run-no-quack: build
$(RUN_ENV) ERPL_REV_DB_PATH=$(DB) ./$(BUILD_DIR)/erpl_rev_server
e2e: build
./scripts/e2e.sh
start-sap:
./scripts/start-sap.sh
clean:
rm -rf $(BUILD_DIR)