mirror of
https://github.com/mudler/LocalAI.git
synced 2026-05-08 03:41:13 -05:00
chore(ci): Build some Go based backends on Darwin (#6164)
* chore(ci): Build Go based backends on Darwin Signed-off-by: Richard Palethorpe <io@richiejp.com> * chore(stablediffusion-ggml): Fixes for building on Darwin Signed-off-by: Richard Palethorpe <io@richiejp.com> * chore(whisper): Build on Darwin Signed-off-by: Richard Palethorpe <io@richiejp.com> --------- Signed-off-by: Richard Palethorpe <io@richiejp.com>
This commit is contained in:
committed by
GitHub
parent
969922ffec
commit
976c159fdb
@@ -230,7 +230,7 @@ jobs:
|
|||||||
runs-on: 'ubuntu-latest'
|
runs-on: 'ubuntu-latest'
|
||||||
base-image: "ubuntu:22.04"
|
base-image: "ubuntu:22.04"
|
||||||
skip-drivers: 'false'
|
skip-drivers: 'false'
|
||||||
backend: "diffusers"
|
backend: "diffusers"
|
||||||
dockerfile: "./backend/Dockerfile.python"
|
dockerfile: "./backend/Dockerfile.python"
|
||||||
context: "./backend"
|
context: "./backend"
|
||||||
# CUDA 12 additional backends
|
# CUDA 12 additional backends
|
||||||
@@ -957,53 +957,38 @@ jobs:
|
|||||||
backend: "kitten-tts"
|
backend: "kitten-tts"
|
||||||
dockerfile: "./backend/Dockerfile.python"
|
dockerfile: "./backend/Dockerfile.python"
|
||||||
context: "./backend"
|
context: "./backend"
|
||||||
diffusers-darwin:
|
backend-jobs-darwin:
|
||||||
uses: ./.github/workflows/backend_build_darwin.yml
|
uses: ./.github/workflows/backend_build_darwin.yml
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- backend: "diffusers"
|
||||||
|
tag-suffix: "-metal-darwin-arm64-diffusers"
|
||||||
|
build-type: "mps"
|
||||||
|
- backend: "mlx"
|
||||||
|
tag-suffix: "-metal-darwin-arm64-mlx"
|
||||||
|
build-type: "mps"
|
||||||
|
- backend: "mlx-vlm"
|
||||||
|
tag-suffix: "-metal-darwin-arm64-mlx-vlm"
|
||||||
|
build-type: "mps"
|
||||||
|
- backend: "mlx-audio"
|
||||||
|
tag-suffix: "-metal-darwin-arm64-mlx-audio"
|
||||||
|
build-type: "mps"
|
||||||
|
- backend: "stablediffusion-ggml"
|
||||||
|
tag-suffix: "-metal-darwin-arm64-stablediffusion-ggml"
|
||||||
|
build-type: "metal"
|
||||||
|
lang: "go"
|
||||||
|
- backend: "whisper"
|
||||||
|
tag-suffix: "-metal-darwin-arm64-whisper"
|
||||||
|
build-type: "metal"
|
||||||
|
lang: "go"
|
||||||
with:
|
with:
|
||||||
backend: "diffusers"
|
backend: ${{ matrix.backend }}
|
||||||
build-type: "mps"
|
build-type: ${{ matrix.build-type }}
|
||||||
go-version: "1.24.x"
|
go-version: "1.24.x"
|
||||||
tag-suffix: "-metal-darwin-arm64-diffusers"
|
tag-suffix: ${{ matrix.tag-suffix }}
|
||||||
use-pip: true
|
lang: ${{ matrix.lang || '' }}
|
||||||
runs-on: "macOS-14"
|
use-pip: ${{ matrix.backend == 'diffusers' }}
|
||||||
secrets:
|
|
||||||
dockerUsername: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
dockerPassword: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
||||||
quayUsername: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
|
|
||||||
quayPassword: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}
|
|
||||||
mlx-darwin:
|
|
||||||
uses: ./.github/workflows/backend_build_darwin.yml
|
|
||||||
with:
|
|
||||||
backend: "mlx"
|
|
||||||
build-type: "mps"
|
|
||||||
go-version: "1.24.x"
|
|
||||||
tag-suffix: "-metal-darwin-arm64-mlx"
|
|
||||||
runs-on: "macOS-14"
|
|
||||||
secrets:
|
|
||||||
dockerUsername: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
dockerPassword: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
||||||
quayUsername: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
|
|
||||||
quayPassword: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}
|
|
||||||
mlx-vlm-darwin:
|
|
||||||
uses: ./.github/workflows/backend_build_darwin.yml
|
|
||||||
with:
|
|
||||||
backend: "mlx-vlm"
|
|
||||||
build-type: "mps"
|
|
||||||
go-version: "1.24.x"
|
|
||||||
tag-suffix: "-metal-darwin-arm64-mlx-vlm"
|
|
||||||
runs-on: "macOS-14"
|
|
||||||
secrets:
|
|
||||||
dockerUsername: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
dockerPassword: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
||||||
quayUsername: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
|
|
||||||
quayPassword: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}
|
|
||||||
mlx-audio-darwin:
|
|
||||||
uses: ./.github/workflows/backend_build_darwin.yml
|
|
||||||
with:
|
|
||||||
backend: "mlx-audio"
|
|
||||||
build-type: "mps"
|
|
||||||
go-version: "1.24.x"
|
|
||||||
tag-suffix: "-metal-darwin-arm64-mlx-audio"
|
|
||||||
runs-on: "macOS-14"
|
runs-on: "macOS-14"
|
||||||
secrets:
|
secrets:
|
||||||
dockerUsername: ${{ secrets.DOCKERHUB_USERNAME }}
|
dockerUsername: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ on:
|
|||||||
description: 'Use pip to install dependencies'
|
description: 'Use pip to install dependencies'
|
||||||
default: false
|
default: false
|
||||||
type: boolean
|
type: boolean
|
||||||
|
lang:
|
||||||
|
description: 'Programming language (e.g. go)'
|
||||||
|
default: 'python'
|
||||||
|
type: string
|
||||||
go-version:
|
go-version:
|
||||||
description: 'Go version to use'
|
description: 'Go version to use'
|
||||||
default: '1.24.x'
|
default: '1.24.x'
|
||||||
@@ -49,26 +53,26 @@ jobs:
|
|||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
- name: Setup Go ${{ matrix.go-version }}
|
- name: Setup Go ${{ matrix.go-version }}
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
cache: false
|
cache: false
|
||||||
|
|
||||||
# You can test your matrix by printing the current Go version
|
# You can test your matrix by printing the current Go version
|
||||||
- name: Display Go version
|
- name: Display Go version
|
||||||
run: go version
|
run: go version
|
||||||
|
|
||||||
- name: Dependencies
|
- name: Dependencies
|
||||||
run: |
|
run: |
|
||||||
brew install protobuf grpc make protoc-gen-go protoc-gen-go-grpc libomp llvm
|
brew install protobuf grpc make protoc-gen-go protoc-gen-go-grpc libomp llvm
|
||||||
|
|
||||||
- name: Build ${{ inputs.backend }}-darwin
|
- name: Build ${{ inputs.backend }}-darwin
|
||||||
run: |
|
run: |
|
||||||
make protogen-go
|
make protogen-go
|
||||||
BACKEND=${{ inputs.backend }} BUILD_TYPE=${{ inputs.build-type }} USE_PIP=${{ inputs.use-pip }} make build-darwin-python-backend
|
BACKEND=${{ inputs.backend }} BUILD_TYPE=${{ inputs.build-type }} USE_PIP=${{ inputs.use-pip }} make build-darwin-${{ inputs.lang }}-backend
|
||||||
|
|
||||||
- name: Upload ${{ inputs.backend }}.tar
|
- name: Upload ${{ inputs.backend }}.tar
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
@@ -85,20 +89,20 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: ${{ inputs.backend }}-tar
|
name: ${{ inputs.backend }}-tar
|
||||||
path: .
|
path: .
|
||||||
|
|
||||||
- name: Install crane
|
- name: Install crane
|
||||||
run: |
|
run: |
|
||||||
curl -L https://github.com/google/go-containerregistry/releases/latest/download/go-containerregistry_Linux_x86_64.tar.gz | tar -xz
|
curl -L https://github.com/google/go-containerregistry/releases/latest/download/go-containerregistry_Linux_x86_64.tar.gz | tar -xz
|
||||||
sudo mv crane /usr/local/bin/
|
sudo mv crane /usr/local/bin/
|
||||||
|
|
||||||
- name: Log in to DockerHub
|
- name: Log in to DockerHub
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.dockerPassword }}" | crane auth login docker.io -u "${{ secrets.dockerUsername }}" --password-stdin
|
echo "${{ secrets.dockerPassword }}" | crane auth login docker.io -u "${{ secrets.dockerUsername }}" --password-stdin
|
||||||
|
|
||||||
- name: Log in to quay.io
|
- name: Log in to quay.io
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.quayPassword }}" | crane auth login quay.io -u "${{ secrets.quayUsername }}" --password-stdin
|
echo "${{ secrets.quayPassword }}" | crane auth login quay.io -u "${{ secrets.quayUsername }}" --password-stdin
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
@@ -112,7 +116,7 @@ jobs:
|
|||||||
flavor: |
|
flavor: |
|
||||||
latest=auto
|
latest=auto
|
||||||
suffix=${{ inputs.tag-suffix }},onlatest=true
|
suffix=${{ inputs.tag-suffix }},onlatest=true
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: quaymeta
|
id: quaymeta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
@@ -126,13 +130,13 @@ jobs:
|
|||||||
flavor: |
|
flavor: |
|
||||||
latest=auto
|
latest=auto
|
||||||
suffix=${{ inputs.tag-suffix }},onlatest=true
|
suffix=${{ inputs.tag-suffix }},onlatest=true
|
||||||
|
|
||||||
- name: Push Docker image (DockerHub)
|
- name: Push Docker image (DockerHub)
|
||||||
run: |
|
run: |
|
||||||
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n'); do
|
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n'); do
|
||||||
crane push ${{ inputs.backend }}.tar $tag
|
crane push ${{ inputs.backend }}.tar $tag
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Push Docker image (Quay)
|
- name: Push Docker image (Quay)
|
||||||
run: |
|
run: |
|
||||||
for tag in $(echo "${{ steps.quaymeta.outputs.tags }}" | tr ',' '\n'); do
|
for tag in $(echo "${{ steps.quaymeta.outputs.tags }}" | tr ',' '\n'); do
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
|
matrix-darwin: ${{ steps.set-matrix.outputs.matrix-darwin }}
|
||||||
has-backends: ${{ steps.set-matrix.outputs.has-backends }}
|
has-backends: ${{ steps.set-matrix.outputs.has-backends }}
|
||||||
|
has-backends-darwin: ${{ steps.set-matrix.outputs.has-backends-darwin }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
@@ -56,3 +58,21 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
|
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
|
||||||
|
backend-jobs-darwin:
|
||||||
|
needs: generate-matrix
|
||||||
|
uses: ./.github/workflows/backend_build_darwin.yml
|
||||||
|
if: needs.generate-matrix.outputs.has-backends-darwin == 'true'
|
||||||
|
with:
|
||||||
|
backend: ${{ matrix.backend }}
|
||||||
|
build-type: ${{ matrix.build-type }}
|
||||||
|
go-version: "1.24.x"
|
||||||
|
tag-suffix: ${{ matrix.tag-suffix }}
|
||||||
|
lang: ${{ matrix.lang || '' }}
|
||||||
|
use-pip: ${{ matrix.backend == 'diffusers' }}
|
||||||
|
runs-on: "macOS-14"
|
||||||
|
secrets:
|
||||||
|
quayUsername: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
|
||||||
|
quayPassword: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix-darwin) }}
|
||||||
|
|||||||
@@ -376,6 +376,9 @@ backends/llama-cpp-darwin: build
|
|||||||
build-darwin-python-backend: build
|
build-darwin-python-backend: build
|
||||||
bash ./scripts/build/python-darwin.sh
|
bash ./scripts/build/python-darwin.sh
|
||||||
|
|
||||||
|
build-darwin-go-backend: build
|
||||||
|
bash ./scripts/build/golang-darwin.sh
|
||||||
|
|
||||||
backends/mlx:
|
backends/mlx:
|
||||||
BACKEND=mlx $(MAKE) build-darwin-python-backend
|
BACKEND=mlx $(MAKE) build-darwin-python-backend
|
||||||
./local-ai backends install "ocifile://$(abspath ./backend-images/mlx.tar)"
|
./local-ai backends install "ocifile://$(abspath ./backend-images/mlx.tar)"
|
||||||
@@ -392,6 +395,10 @@ backends/mlx-audio:
|
|||||||
BACKEND=mlx-audio $(MAKE) build-darwin-python-backend
|
BACKEND=mlx-audio $(MAKE) build-darwin-python-backend
|
||||||
./local-ai backends install "ocifile://$(abspath ./backend-images/mlx-audio.tar)"
|
./local-ai backends install "ocifile://$(abspath ./backend-images/mlx-audio.tar)"
|
||||||
|
|
||||||
|
backends/stablediffusion-ggml-darwin:
|
||||||
|
BACKEND=stablediffusion-ggml BUILD_TYPE=metal $(MAKE) build-darwin-go-backend
|
||||||
|
./local-ai backends install "ocifile://$(abspath ./backend-images/stablediffusion-ggml.tar)"
|
||||||
|
|
||||||
backend-images:
|
backend-images:
|
||||||
mkdir -p backend-images
|
mkdir -p backend-images
|
||||||
|
|
||||||
@@ -537,4 +544,4 @@ build-launcher-darwin: build-launcher
|
|||||||
--outputDir "dist/"
|
--outputDir "dist/"
|
||||||
|
|
||||||
build-launcher-linux:
|
build-launcher-linux:
|
||||||
cd cmd/launcher && go run fyne.io/tools/cmd/fyne@latest package -os linux -icon ../../core/http/static/logo.png --executable $(LAUNCHER_BINARY_NAME)-linux && mv launcher.tar.xz ../../$(LAUNCHER_BINARY_NAME)-linux.tar.xz
|
cd cmd/launcher && go run fyne.io/tools/cmd/fyne@latest package -os linux -icon ../../core/http/static/logo.png --executable $(LAUNCHER_BINARY_NAME)-linux && mv launcher.tar.xz ../../$(LAUNCHER_BINARY_NAME)-linux.tar.xz
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package/
|
||||||
|
sources/
|
||||||
|
libgosd.so
|
||||||
|
stablediffusion-ggml
|
||||||
@@ -5,7 +5,11 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|||||||
add_subdirectory(./sources/stablediffusion-ggml.cpp)
|
add_subdirectory(./sources/stablediffusion-ggml.cpp)
|
||||||
|
|
||||||
add_library(gosd MODULE gosd.cpp)
|
add_library(gosd MODULE gosd.cpp)
|
||||||
target_link_libraries(gosd PRIVATE stable-diffusion ggml stdc++fs)
|
target_link_libraries(gosd PRIVATE stable-diffusion ggml)
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
|
||||||
|
target_link_libraries(gosd PRIVATE stdc++fs)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(gosd PUBLIC
|
target_include_directories(gosd PUBLIC
|
||||||
stable-diffusion.cpp
|
stable-diffusion.cpp
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ else ifeq ($(BUILD_TYPE),clblas)
|
|||||||
# If it's hipblas we do have also to set CC=/opt/rocm/llvm/bin/clang CXX=/opt/rocm/llvm/bin/clang++
|
# If it's hipblas we do have also to set CC=/opt/rocm/llvm/bin/clang CXX=/opt/rocm/llvm/bin/clang++
|
||||||
else ifeq ($(BUILD_TYPE),hipblas)
|
else ifeq ($(BUILD_TYPE),hipblas)
|
||||||
CMAKE_ARGS+=-DSD_HIPBLAS=ON -DGGML_HIPBLAS=ON
|
CMAKE_ARGS+=-DSD_HIPBLAS=ON -DGGML_HIPBLAS=ON
|
||||||
# If it's OSX, DO NOT embed the metal library - -DGGML_METAL_EMBED_LIBRARY=ON requires further investigation
|
|
||||||
# But if it's OSX without metal, disable it here
|
|
||||||
else ifeq ($(BUILD_TYPE),vulkan)
|
else ifeq ($(BUILD_TYPE),vulkan)
|
||||||
CMAKE_ARGS+=-DSD_VULKAN=ON -DGGML_VULKAN=ON
|
CMAKE_ARGS+=-DSD_VULKAN=ON -DGGML_VULKAN=ON
|
||||||
else ifeq ($(OS),Darwin)
|
else ifeq ($(OS),Darwin)
|
||||||
@@ -74,10 +72,10 @@ libgosd.so: sources/stablediffusion-ggml.cpp CMakeLists.txt gosd.cpp gosd.h
|
|||||||
stablediffusion-ggml: main.go gosd.go libgosd.so
|
stablediffusion-ggml: main.go gosd.go libgosd.so
|
||||||
CGO_ENABLED=0 $(GOCMD) build -tags "$(GO_TAGS)" -o stablediffusion-ggml ./
|
CGO_ENABLED=0 $(GOCMD) build -tags "$(GO_TAGS)" -o stablediffusion-ggml ./
|
||||||
|
|
||||||
package:
|
package: stablediffusion-ggml
|
||||||
bash package.sh
|
bash package.sh
|
||||||
|
|
||||||
build: stablediffusion-ggml package
|
build: package
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf libgosd.o build stablediffusion-ggml
|
rm -rf libgosd.so build stablediffusion-ggml package sources
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ CURDIR=$(dirname "$(realpath $0)")
|
|||||||
# Create lib directory
|
# Create lib directory
|
||||||
mkdir -p $CURDIR/package/lib
|
mkdir -p $CURDIR/package/lib
|
||||||
|
|
||||||
cp -avrf $CURDIR/libgosd.so $CURDIR/package/
|
cp -avf $CURDIR/libgosd.so $CURDIR/package/
|
||||||
cp -avrf $CURDIR/stablediffusion-ggml $CURDIR/package/
|
cp -avf $CURDIR/stablediffusion-ggml $CURDIR/package/
|
||||||
cp -rfv $CURDIR/run.sh $CURDIR/package/
|
cp -fv $CURDIR/run.sh $CURDIR/package/
|
||||||
|
|
||||||
# Detect architecture and copy appropriate libraries
|
# Detect architecture and copy appropriate libraries
|
||||||
if [ -f "/lib64/ld-linux-x86-64.so.2" ]; then
|
if [ -f "/lib64/ld-linux-x86-64.so.2" ]; then
|
||||||
@@ -43,6 +43,8 @@ elif [ -f "/lib/ld-linux-aarch64.so.1" ]; then
|
|||||||
cp -arfLv /lib/aarch64-linux-gnu/libdl.so.2 $CURDIR/package/lib/libdl.so.2
|
cp -arfLv /lib/aarch64-linux-gnu/libdl.so.2 $CURDIR/package/lib/libdl.so.2
|
||||||
cp -arfLv /lib/aarch64-linux-gnu/librt.so.1 $CURDIR/package/lib/librt.so.1
|
cp -arfLv /lib/aarch64-linux-gnu/librt.so.1 $CURDIR/package/lib/librt.so.1
|
||||||
cp -arfLv /lib/aarch64-linux-gnu/libpthread.so.0 $CURDIR/package/lib/libpthread.so.0
|
cp -arfLv /lib/aarch64-linux-gnu/libpthread.so.0 $CURDIR/package/lib/libpthread.so.0
|
||||||
|
elif [ $(uname -s) = "Darwin" ]; then
|
||||||
|
echo "Detected Darwin"
|
||||||
else
|
else
|
||||||
echo "Error: Could not detect architecture"
|
echo "Error: Could not detect architecture"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||||||
add_subdirectory(./sources/whisper.cpp)
|
add_subdirectory(./sources/whisper.cpp)
|
||||||
|
|
||||||
add_library(gowhisper MODULE gowhisper.cpp)
|
add_library(gowhisper MODULE gowhisper.cpp)
|
||||||
target_link_libraries(gowhisper PRIVATE whisper ggml stdc++fs)
|
target_link_libraries(gowhisper PRIVATE whisper ggml)
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
|
||||||
|
target_link_libraries(gosd PRIVATE stdc++fs)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_property(TARGET gowhisper PROPERTY CXX_STANDARD 17)
|
set_property(TARGET gowhisper PROPERTY CXX_STANDARD 17)
|
||||||
set_target_properties(gowhisper PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
set_target_properties(gowhisper PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
|
|||||||
@@ -68,10 +68,10 @@ libgowhisper.so: sources/whisper.cpp CMakeLists.txt gowhisper.cpp gowhisper.h
|
|||||||
whisper: main.go gowhisper.go libgowhisper.so
|
whisper: main.go gowhisper.go libgowhisper.so
|
||||||
CGO_ENABLED=0 $(GOCMD) build -tags "$(GO_TAGS)" -o whisper ./
|
CGO_ENABLED=0 $(GOCMD) build -tags "$(GO_TAGS)" -o whisper ./
|
||||||
|
|
||||||
package:
|
package: whisper
|
||||||
bash package.sh
|
bash package.sh
|
||||||
|
|
||||||
build: whisper package
|
build: package
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf libgowhisper.o build whisper
|
rm -rf libgowhisper.o build whisper
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ CURDIR=$(dirname "$(realpath $0)")
|
|||||||
# Create lib directory
|
# Create lib directory
|
||||||
mkdir -p $CURDIR/package/lib
|
mkdir -p $CURDIR/package/lib
|
||||||
|
|
||||||
cp -avrf $CURDIR/whisper $CURDIR/libgowhisper.so $CURDIR/package/
|
cp -avf $CURDIR/whisper $CURDIR/libgowhisper.so $CURDIR/package/
|
||||||
cp -rfv $CURDIR/run.sh $CURDIR/package/
|
cp -fv $CURDIR/run.sh $CURDIR/package/
|
||||||
|
|
||||||
# Detect architecture and copy appropriate libraries
|
# Detect architecture and copy appropriate libraries
|
||||||
if [ -f "/lib64/ld-linux-x86-64.so.2" ]; then
|
if [ -f "/lib64/ld-linux-x86-64.so.2" ]; then
|
||||||
@@ -42,6 +42,8 @@ elif [ -f "/lib/ld-linux-aarch64.so.1" ]; then
|
|||||||
cp -arfLv /lib/aarch64-linux-gnu/libdl.so.2 $CURDIR/package/lib/libdl.so.2
|
cp -arfLv /lib/aarch64-linux-gnu/libdl.so.2 $CURDIR/package/lib/libdl.so.2
|
||||||
cp -arfLv /lib/aarch64-linux-gnu/librt.so.1 $CURDIR/package/lib/librt.so.1
|
cp -arfLv /lib/aarch64-linux-gnu/librt.so.1 $CURDIR/package/lib/librt.so.1
|
||||||
cp -arfLv /lib/aarch64-linux-gnu/libpthread.so.0 $CURDIR/package/lib/libpthread.so.0
|
cp -arfLv /lib/aarch64-linux-gnu/libpthread.so.0 $CURDIR/package/lib/libpthread.so.0
|
||||||
|
elif [ $(uname -s) = "Darwin" ]; then
|
||||||
|
echo "Detected Darwin"
|
||||||
else
|
else
|
||||||
echo "Error: Could not detect architecture"
|
echo "Error: Could not detect architecture"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash -eux
|
||||||
|
|
||||||
|
export BUILD_TYPE="${BUILD_TYPE:-metal}"
|
||||||
|
|
||||||
|
mkdir -p backend-images
|
||||||
|
make -C backend/go/${BACKEND} build
|
||||||
|
|
||||||
|
PLATFORMARCH="${PLATFORMARCH:-darwin/arm64}"
|
||||||
|
IMAGE_NAME="${IMAGE_NAME:-localai/${BACKEND}-darwin}"
|
||||||
|
|
||||||
|
./local-ai util create-oci-image \
|
||||||
|
backend/go/${BACKEND}/. \
|
||||||
|
--output ./backend-images/${BACKEND}.tar \
|
||||||
|
--image-name $IMAGE_NAME \
|
||||||
|
--platform $PLATFORMARCH
|
||||||
|
|
||||||
|
make -C backend/go/${BACKEND} clean
|
||||||
@@ -5,10 +5,10 @@ import { Octokit } from "@octokit/core";
|
|||||||
// Load backend.yml and parse matrix.include
|
// Load backend.yml and parse matrix.include
|
||||||
const backendYml = yaml.load(fs.readFileSync(".github/workflows/backend.yml", "utf8"));
|
const backendYml = yaml.load(fs.readFileSync(".github/workflows/backend.yml", "utf8"));
|
||||||
const jobs = backendYml.jobs;
|
const jobs = backendYml.jobs;
|
||||||
const backendJob = jobs["backend-jobs"];
|
const backendJobs = jobs["backend-jobs"];
|
||||||
const strategy = backendJob.strategy;
|
const backendJobsDarwin = jobs["backend-jobs-darwin"];
|
||||||
const matrix = strategy.matrix;
|
const includes = backendJobs.strategy.matrix.include;
|
||||||
const includes = matrix.include;
|
const includesDarwin = backendJobsDarwin.strategy.matrix.include;
|
||||||
|
|
||||||
// Set up Octokit for PR changed files
|
// Set up Octokit for PR changed files
|
||||||
const token = process.env.GITHUB_TOKEN;
|
const token = process.env.GITHUB_TOKEN;
|
||||||
@@ -58,6 +58,14 @@ function inferBackendPath(item) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function inferBackendPathDarwin(item) {
|
||||||
|
if (!item.lang) {
|
||||||
|
return `backend/python/${item.backend}/`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `backend/${item.lang}/${item.backend}/`;
|
||||||
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const changedFiles = await getChangedFiles();
|
const changedFiles = await getChangedFiles();
|
||||||
|
|
||||||
@@ -69,11 +77,21 @@ function inferBackendPath(item) {
|
|||||||
return changedFiles.some(file => file.startsWith(backendPath));
|
return changedFiles.some(file => file.startsWith(backendPath));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const filteredDarwin = includesDarwin.filter(item => {
|
||||||
|
const backendPath = inferBackendPathDarwin(item);
|
||||||
|
return changedFiles.some(file => file.startsWith(backendPath));
|
||||||
|
})
|
||||||
|
|
||||||
console.log("Filtered files:", filtered);
|
console.log("Filtered files:", filtered);
|
||||||
|
console.log("Filtered files Darwin:", filteredDarwin);
|
||||||
|
|
||||||
const hasBackends = filtered.length > 0 ? 'true' : 'false';
|
const hasBackends = filtered.length > 0 ? 'true' : 'false';
|
||||||
|
const hasBackendsDarwin = filteredDarwin.length > 0 ? 'true' : 'false';
|
||||||
console.log("Has backends?:", hasBackends);
|
console.log("Has backends?:", hasBackends);
|
||||||
|
console.log("Has Darwin backends?:", hasBackendsDarwin);
|
||||||
|
|
||||||
fs.appendFileSync(process.env.GITHUB_OUTPUT, `has-backends=${hasBackends}\n`);
|
fs.appendFileSync(process.env.GITHUB_OUTPUT, `has-backends=${hasBackends}\n`);
|
||||||
|
fs.appendFileSync(process.env.GITHUB_OUTPUT, `has-backends-darwin=${hasBackendsDarwin}\n`);
|
||||||
fs.appendFileSync(process.env.GITHUB_OUTPUT, `matrix=${JSON.stringify({ include: filtered })}\n`);
|
fs.appendFileSync(process.env.GITHUB_OUTPUT, `matrix=${JSON.stringify({ include: filtered })}\n`);
|
||||||
|
fs.appendFileSync(process.env.GITHUB_OUTPUT, `matrix-darwin=${JSON.stringify({ include: filteredDarwin })}\n`);
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user