feat: enhance Makefile and README with LanceDB build options
This commit is contained in:
@@ -10,6 +10,7 @@ GOARCH ?= $(shell $(GO) env GOARCH)
|
|||||||
DEV_SERVER_URL ?= http://127.0.0.1:8083
|
DEV_SERVER_URL ?= http://127.0.0.1:8083
|
||||||
LANCEDB_VERSION ?= v0.1.2
|
LANCEDB_VERSION ?= v0.1.2
|
||||||
LANCEDB_DOWNLOAD_SCRIPT ?= https://raw.githubusercontent.com/lancedb/lancedb-go/main/scripts/download-artifacts.sh
|
LANCEDB_DOWNLOAD_SCRIPT ?= https://raw.githubusercontent.com/lancedb/lancedb-go/main/scripts/download-artifacts.sh
|
||||||
|
LANCEDB ?= 0
|
||||||
|
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
UNAME_M := $(shell uname -m)
|
UNAME_M := $(shell uname -m)
|
||||||
@@ -20,7 +21,17 @@ else
|
|||||||
APP_EXT :=
|
APP_EXT :=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BUILD_OUTPUT := $(DIST_DIR)/$(APP)$(APP_EXT)
|
ifeq ($(LANCEDB),1)
|
||||||
|
BUILD_NAME_SUFFIX := -lancedb
|
||||||
|
BUILD_TAGS := -tags lancedb
|
||||||
|
BUILD_CGO_ENABLED := 1
|
||||||
|
else
|
||||||
|
BUILD_NAME_SUFFIX :=
|
||||||
|
BUILD_TAGS :=
|
||||||
|
BUILD_CGO_ENABLED :=
|
||||||
|
endif
|
||||||
|
|
||||||
|
BUILD_OUTPUT := $(DIST_DIR)/$(APP)$(BUILD_NAME_SUFFIX)$(APP_EXT)
|
||||||
|
|
||||||
ifeq ($(UNAME_M),x86_64)
|
ifeq ($(UNAME_M),x86_64)
|
||||||
LANCEDB_ARCH := amd64
|
LANCEDB_ARCH := amd64
|
||||||
@@ -65,13 +76,17 @@ LANCEDB_CGO_LDFLAGS := $(LANCEDB_NATIVE_LIB) $(LANCEDB_SYSTEM_LDFLAGS)
|
|||||||
.DEFAULT_GOAL := build
|
.DEFAULT_GOAL := build
|
||||||
|
|
||||||
.PHONY: help dev build release generator enums \
|
.PHONY: help dev build release generator enums \
|
||||||
_web-build-spa _web-dev _prepare-dist _lancedb-artifacts _lancedb-check
|
_web-build-spa _web-dev _prepare-dist _lancedb-artifacts _lancedb-check _lancedb-release-check
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Available targets:"
|
@echo "Available targets:"
|
||||||
@echo " make dev Start backend and frontend development servers"
|
@echo " make dev Start backend and frontend development servers"
|
||||||
@echo " make build Build the current system into dist/"
|
@echo " make build Build the current system into dist/"
|
||||||
|
@echo " make build LANCEDB=1"
|
||||||
|
@echo " Build the current-platform LanceDB binary into dist/"
|
||||||
@echo " make release Build linux/darwin/windows release binaries into dist/"
|
@echo " make release Build linux/darwin/windows release binaries into dist/"
|
||||||
|
@echo " make release LANCEDB=1"
|
||||||
|
@echo " Build LanceDB release binaries into dist/"
|
||||||
@echo " make generator Run code generation"
|
@echo " make generator Run code generation"
|
||||||
@echo " make enums Generate frontend enums"
|
@echo " make enums Generate frontend enums"
|
||||||
@echo " make help Show this help"
|
@echo " make help Show this help"
|
||||||
@@ -92,17 +107,59 @@ dev: _lancedb-check
|
|||||||
echo "Server is ready; starting web dev server..."; \
|
echo "Server is ready; starting web dev server..."; \
|
||||||
$(MAKE) _web-dev
|
$(MAKE) _web-dev
|
||||||
|
|
||||||
|
ifeq ($(LANCEDB),1)
|
||||||
|
build: _lancedb-check _prepare-dist _web-build-spa
|
||||||
|
else
|
||||||
build: _prepare-dist _web-build-spa
|
build: _prepare-dist _web-build-spa
|
||||||
|
endif
|
||||||
@echo "Building $(BUILD_OUTPUT)..."
|
@echo "Building $(BUILD_OUTPUT)..."
|
||||||
|
ifeq ($(LANCEDB),1)
|
||||||
|
@CGO_ENABLED=$(BUILD_CGO_ENABLED) CGO_CFLAGS="$(LANCEDB_CGO_CFLAGS)" CGO_LDFLAGS="$(LANCEDB_CGO_LDFLAGS)" \
|
||||||
|
$(GO) build $(BUILD_TAGS) -v -o $(BUILD_OUTPUT) $(MAIN)
|
||||||
|
else
|
||||||
@$(GO) build -v -o $(BUILD_OUTPUT) $(MAIN)
|
@$(GO) build -v -o $(BUILD_OUTPUT) $(MAIN)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(LANCEDB),1)
|
||||||
|
release: _lancedb-release-check _prepare-dist _web-build-spa
|
||||||
|
else
|
||||||
release: _prepare-dist _web-build-spa
|
release: _prepare-dist _web-build-spa
|
||||||
|
endif
|
||||||
@echo "Building release binaries in $(DIST_DIR)..."
|
@echo "Building release binaries in $(DIST_DIR)..."
|
||||||
@GOOS=linux GOARCH=amd64 $(GO) build -v -o $(DIST_DIR)/$(APP)-linux-amd64 $(MAIN)
|
@if [ "$(LANCEDB)" = "1" ]; then \
|
||||||
@GOOS=linux GOARCH=arm64 $(GO) build -v -o $(DIST_DIR)/$(APP)-linux-arm64 $(MAIN)
|
set -e; \
|
||||||
@GOOS=darwin GOARCH=amd64 $(GO) build -v -o $(DIST_DIR)/$(APP)-darwin-amd64 $(MAIN)
|
if [ ! -f "$(CURDIR)/include/lancedb.h" ]; then \
|
||||||
@GOOS=darwin GOARCH=arm64 $(GO) build -v -o $(DIST_DIR)/$(APP)-darwin-arm64 $(MAIN)
|
echo "Missing LanceDB header: $(CURDIR)/include/lancedb.h"; \
|
||||||
@GOOS=windows GOARCH=amd64 $(GO) build -v -o $(DIST_DIR)/$(APP)-windows-amd64.exe $(MAIN)
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
build_lancedb() { \
|
||||||
|
platform="$$1"; \
|
||||||
|
arch="$$2"; \
|
||||||
|
ext="$$3"; \
|
||||||
|
system_ldflags="$$4"; \
|
||||||
|
native_lib="$(CURDIR)/lib/$${platform}_$${arch}/liblancedb_go.a"; \
|
||||||
|
output="$(DIST_DIR)/$(APP)-lancedb-$${platform}-$${arch}$${ext}"; \
|
||||||
|
if [ ! -f "$$native_lib" ]; then \
|
||||||
|
echo "Missing LanceDB native library for $${platform}/$${arch}: $$native_lib"; \
|
||||||
|
echo "LanceDB release builds require matching native artifacts and a CGO-capable toolchain for each target platform."; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
echo "Building $$output..."; \
|
||||||
|
CGO_ENABLED=1 CGO_CFLAGS="-I$(CURDIR)/include" CGO_LDFLAGS="$$native_lib $$system_ldflags" \
|
||||||
|
GOOS="$$platform" GOARCH="$$arch" $(GO) build -tags lancedb -v -o "$$output" $(MAIN); \
|
||||||
|
}; \
|
||||||
|
build_lancedb linux amd64 "" "-lm -ldl -lpthread"; \
|
||||||
|
build_lancedb linux arm64 "" "-lm -ldl -lpthread"; \
|
||||||
|
build_lancedb darwin amd64 "" "-framework Security -framework CoreFoundation"; \
|
||||||
|
build_lancedb darwin arm64 "" "-framework Security -framework CoreFoundation"; \
|
||||||
|
build_lancedb windows amd64 ".exe" ""; \
|
||||||
|
else \
|
||||||
|
GOOS=linux GOARCH=amd64 $(GO) build -v -o $(DIST_DIR)/$(APP)-linux-amd64 $(MAIN); \
|
||||||
|
GOOS=linux GOARCH=arm64 $(GO) build -v -o $(DIST_DIR)/$(APP)-linux-arm64 $(MAIN); \
|
||||||
|
GOOS=darwin GOARCH=amd64 $(GO) build -v -o $(DIST_DIR)/$(APP)-darwin-amd64 $(MAIN); \
|
||||||
|
GOOS=darwin GOARCH=arm64 $(GO) build -v -o $(DIST_DIR)/$(APP)-darwin-arm64 $(MAIN); \
|
||||||
|
GOOS=windows GOARCH=amd64 $(GO) build -v -o $(DIST_DIR)/$(APP)-windows-amd64.exe $(MAIN); \
|
||||||
|
fi
|
||||||
|
|
||||||
generator:
|
generator:
|
||||||
@$(GO) run ./cmd/generator/generator.go
|
@$(GO) run ./cmd/generator/generator.go
|
||||||
@@ -140,3 +197,21 @@ _lancedb-check: _lancedb-artifacts
|
|||||||
echo "Missing LanceDB header: $(CURDIR)/include/lancedb.h"; \
|
echo "Missing LanceDB header: $(CURDIR)/include/lancedb.h"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
_lancedb-release-check:
|
||||||
|
@if [ ! -f "$(CURDIR)/include/lancedb.h" ]; then \
|
||||||
|
echo "Missing LanceDB header: $(CURDIR)/include/lancedb.h"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
@missing=0; \
|
||||||
|
for target in linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 windows_amd64; do \
|
||||||
|
native_lib="$(CURDIR)/lib/$${target}/liblancedb_go.a"; \
|
||||||
|
if [ ! -f "$$native_lib" ]; then \
|
||||||
|
echo "Missing LanceDB native library: $$native_lib"; \
|
||||||
|
missing=1; \
|
||||||
|
fi; \
|
||||||
|
done; \
|
||||||
|
if [ "$$missing" = "1" ]; then \
|
||||||
|
echo "LanceDB release builds require matching native artifacts and a CGO-capable toolchain for each target platform."; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|||||||
@@ -188,7 +188,9 @@ Default development URLs:
|
|||||||
```bash
|
```bash
|
||||||
make dev # start backend and frontend development servers
|
make dev # start backend and frontend development servers
|
||||||
make build # build the frontend SPA and current-platform Go binary into dist/
|
make build # build the frontend SPA and current-platform Go binary into dist/
|
||||||
|
make build LANCEDB=1 # build the current-platform LanceDB binary into dist/
|
||||||
make release # build linux/darwin/windows release binaries into dist/
|
make release # build linux/darwin/windows release binaries into dist/
|
||||||
|
make release LANCEDB=1 # build LanceDB release binaries into dist/
|
||||||
make generator # run code generation
|
make generator # run code generation
|
||||||
make enums # generate frontend enums
|
make enums # generate frontend enums
|
||||||
make help # show available make targets
|
make help # show available make targets
|
||||||
|
|||||||
Reference in New Issue
Block a user