mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-04 09:42:53 +00:00
feat(darwin): embed grpc libs (#2567)
* debug * feat(makefile): allow to bundle libs into binary * ci: bundle protobuf into single-binary Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * ci: tests Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(assets): correctly reference extract folder Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * bundle also abseil Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * bundle more libs Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
This commit is contained in:
parent
25f45827ab
commit
112d0ffa45
3
.github/workflows/release.yaml
vendored
3
.github/workflows/release.yaml
vendored
@ -268,7 +268,8 @@ jobs:
|
|||||||
export C_INCLUDE_PATH=/usr/local/include
|
export C_INCLUDE_PATH=/usr/local/include
|
||||||
export CPLUS_INCLUDE_PATH=/usr/local/include
|
export CPLUS_INCLUDE_PATH=/usr/local/include
|
||||||
export PATH=$PATH:$GOPATH/bin
|
export PATH=$PATH:$GOPATH/bin
|
||||||
GO_TAGS=p2p make dist
|
|
||||||
|
BACKEND_LIBS="$(ls /opt/homebrew/opt/grpc/lib/*.dylib /opt/homebrew/opt/re2/lib/*.dylib /opt/homebrew/opt/openssl@3/lib/*.dylib /opt/homebrew/opt/protobuf/lib/*.dylib /opt/homebrew/opt/abseil/lib/*.dylib | xargs)" GO_TAGS=p2p make dist
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: LocalAI-MacOS-arm64
|
name: LocalAI-MacOS-arm64
|
||||||
|
7
Makefile
7
Makefile
@ -313,6 +313,10 @@ build: prepare backend-assets grpcs ## Build the project
|
|||||||
$(info ${GREEN}I BUILD_TYPE: ${YELLOW}$(BUILD_TYPE)${RESET})
|
$(info ${GREEN}I BUILD_TYPE: ${YELLOW}$(BUILD_TYPE)${RESET})
|
||||||
$(info ${GREEN}I GO_TAGS: ${YELLOW}$(GO_TAGS)${RESET})
|
$(info ${GREEN}I GO_TAGS: ${YELLOW}$(GO_TAGS)${RESET})
|
||||||
$(info ${GREEN}I LD_FLAGS: ${YELLOW}$(LD_FLAGS)${RESET})
|
$(info ${GREEN}I LD_FLAGS: ${YELLOW}$(LD_FLAGS)${RESET})
|
||||||
|
ifneq ($(BACKEND_LIBS),)
|
||||||
|
$(MAKE) backend-assets/lib
|
||||||
|
cp -r $(BACKEND_LIBS) backend-assets/lib/
|
||||||
|
endif
|
||||||
CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o $(BINARY_NAME) ./
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o $(BINARY_NAME) ./
|
||||||
|
|
||||||
build-minimal:
|
build-minimal:
|
||||||
@ -321,6 +325,9 @@ build-minimal:
|
|||||||
build-api:
|
build-api:
|
||||||
BUILD_GRPC_FOR_BACKEND_LLAMA=true BUILD_API_ONLY=true GO_TAGS=none $(MAKE) build
|
BUILD_GRPC_FOR_BACKEND_LLAMA=true BUILD_API_ONLY=true GO_TAGS=none $(MAKE) build
|
||||||
|
|
||||||
|
backend-assets/lib:
|
||||||
|
mkdir -p backend-assets/lib
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
STATIC=true $(MAKE) backend-assets/grpc/llama-cpp-avx2
|
STATIC=true $(MAKE) backend-assets/grpc/llama-cpp-avx2
|
||||||
ifeq ($(OS),Darwin)
|
ifeq ($(OS),Darwin)
|
||||||
|
@ -61,12 +61,13 @@ func ExtractFiles(content embed.FS, extractDir string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lpathVar := "LD_LIBRARY_PATH"
|
lpathVar := "LD_LIBRARY_PATH"
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
lpathVar = "DYLD_FALLBACK_LIBRARY_PATH" // should it be DYLD_LIBRARY_PATH ?
|
lpathVar = "DYLD_FALLBACK_LIBRARY_PATH" // should it be DYLD_LIBRARY_PATH ?
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, libDir := range []string{filepath.Join(extractDir, "backend_assets", "lib"), filepath.Join(extractDir, "lib")} {
|
for _, libDir := range []string{filepath.Join(extractDir, "backend-assets", "lib"), filepath.Join(extractDir, "lib")} {
|
||||||
if _, err := os.Stat(libDir); err == nil {
|
if _, err := os.Stat(libDir); err == nil {
|
||||||
ldLibraryPath := os.Getenv(lpathVar)
|
ldLibraryPath := os.Getenv(lpathVar)
|
||||||
if ldLibraryPath == "" {
|
if ldLibraryPath == "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user