danbev commited on
Commit
f89bcc9
·
unverified ·
1 Parent(s): 79fa7cf

bindings-go : update Makefile to use cmake (#2952)

Browse files

This commit updates the Makefile to use cmake instead of make to build
whisper.cpp.

The motivation for this change is that currently the make recipe test
will fail with the following error:
```console
$ make test
Mkdir build
Mkdir models
Build whisper
make[1]: Entering directory '/home/danbev/work/ai/whisper-work'
make[1]: *** No rule to make target 'libwhisper.a'. Stop.
make[1]: Leaving directory '/home/danbev/work/ai/whisper-work'
make: *** [Makefile:33: whisper] Error 2
```

Files changed (2) hide show
  1. bindings/go/Makefile +6 -4
  2. bindings/go/whisper.go +1 -1
bindings/go/Makefile CHANGED
@@ -11,11 +11,11 @@ UNAME_M := $(shell uname -m)
11
  endif
12
 
13
  GGML_METAL_PATH_RESOURCES := $(abspath ../..)
14
- BUILD_DIR := build
15
  MODELS_DIR := models
16
  EXAMPLES_DIR := $(wildcard examples/*)
17
  INCLUDE_PATH := $(abspath ../../include):$(abspath ../../ggml/include)
18
- LIBRARY_PATH := $(abspath ../..)
19
 
20
  ifeq ($(GGML_CUDA),1)
21
  LIBRARY_PATH := $(LIBRARY_PATH):$(CUDA_PATH)/targets/$(UNAME_M)-linux/lib/
@@ -29,8 +29,10 @@ endif
29
  all: clean whisper examples
30
 
31
  whisper: mkdir
32
- @echo Build whisper
33
- @${MAKE} -C ../.. libwhisper.a
 
 
34
 
35
  test: model-small whisper modtidy
36
  ifeq ($(UNAME_S),Darwin)
 
11
  endif
12
 
13
  GGML_METAL_PATH_RESOURCES := $(abspath ../..)
14
+ BUILD_DIR := build_go
15
  MODELS_DIR := models
16
  EXAMPLES_DIR := $(wildcard examples/*)
17
  INCLUDE_PATH := $(abspath ../../include):$(abspath ../../ggml/include)
18
+ LIBRARY_PATH := $(abspath ../../${BUILD_DIR}/src:$(abspath ../../${BUILD_DIR}/ggml/src))
19
 
20
  ifeq ($(GGML_CUDA),1)
21
  LIBRARY_PATH := $(LIBRARY_PATH):$(CUDA_PATH)/targets/$(UNAME_M)-linux/lib/
 
29
  all: clean whisper examples
30
 
31
  whisper: mkdir
32
+ cmake -S ../.. -B ../../${BUILD_DIR} \
33
+ -DCMAKE_BUILD_TYPE=Release \
34
+ -DBUILD_SHARED_LIBS=OFF
35
+ cmake --build ../../${BUILD_DIR} --target whisper
36
 
37
  test: model-small whisper modtidy
38
  ifeq ($(UNAME_S),Darwin)
bindings/go/whisper.go CHANGED
@@ -9,7 +9,7 @@ import (
9
  // CGO
10
 
11
  /*
12
- #cgo LDFLAGS: -lwhisper -lm -lstdc++ -fopenmp
13
  #cgo darwin LDFLAGS: -framework Accelerate -framework Metal -framework Foundation -framework CoreGraphics
14
  #include <whisper.h>
15
  #include <stdlib.h>
 
9
  // CGO
10
 
11
  /*
12
+ #cgo LDFLAGS: -lwhisper -lggml -lggml-base -lggml-cpu -lm -lstdc++ -fopenmp
13
  #cgo darwin LDFLAGS: -framework Accelerate -framework Metal -framework Foundation -framework CoreGraphics
14
  #include <whisper.h>
15
  #include <stdlib.h>