Skip to content

Commit 11dddfb

Browse files
committed
ci : disable Obj-C build + fixes
1 parent 384e214 commit 11dddfb

File tree

8 files changed

+54
-71
lines changed

8 files changed

+54
-71
lines changed

.github/workflows/build.yml

+28-5
Original file line numberDiff line numberDiff line change
@@ -518,27 +518,50 @@ jobs:
518518
emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
519519
make
520520
521-
ios:
521+
ios-xcode-build:
522522
runs-on: macos-latest
523523

524524
strategy:
525525
matrix:
526526
build: [Release]
527527

528528
steps:
529-
- name: Clone
529+
- name: Checkout code
530530
uses: actions/checkout@v4
531531

532532
- name: Configure
533533
run: |
534534
cp models/for-tests-ggml-base.en.bin models/ggml-base.en.bin
535535
mkdir models/ggml-base.en-encoder.mlmodelc
536536
537-
- name: Build objc example
538-
run: xcodebuild -project examples/whisper.objc/whisper.objc.xcodeproj -scheme whisper.objc -configuration ${{ matrix.build }} -sdk iphonesimulator build
537+
- name: Build
538+
id: cmake_build
539+
run: |
540+
sysctl -a
541+
mkdir build
542+
cd build
543+
cmake -G Xcode .. \
544+
-DGGML_METAL_USE_BF16=ON \
545+
-DGGML_METAL_EMBED_LIBRARY=ON \
546+
-DWHISPER_BUILD_EXAMPLES=OFF \
547+
-DWHISPER_BUILD_TESTS=OFF \
548+
-DWHISPER_BUILD_SERVER=OFF \
549+
-DCMAKE_SYSTEM_NAME=iOS \
550+
-DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
551+
-DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
552+
cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
553+
sudo cmake --install . --config Release
554+
555+
- name: xcodebuild for swift package
556+
id: xcodebuild
557+
run: |
558+
xcodebuild -scheme whisper-Package -destination 'generic/platform=iOS'
559+
560+
#- name: Build objc example
561+
# run: xcodebuild -project examples/whisper.objc/whisper.objc.xcodeproj -scheme whisper.objc -configuration ${{ matrix.build }} -sdk iphoneos build
539562

540563
- name: Build swiftui example
541-
run: xcodebuild -project examples/whisper.swiftui/whisper.swiftui.xcodeproj -scheme WhisperCppDemo -configuration ${{ matrix.build }} -sdk iphonesimulator build
564+
run: xcodebuild -project examples/whisper.swiftui/whisper.swiftui.xcodeproj -scheme WhisperCppDemo -configuration ${{ matrix.build }} -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' build
542565

543566
android:
544567
runs-on: ubuntu-latest

Package.swift

+2-51
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,6 @@ let package = Package(
1414
.library(name: "whisper", targets: ["whisper"]),
1515
],
1616
targets: [
17-
.target(
18-
name: "whisper",
19-
path: ".",
20-
exclude: [
21-
"build",
22-
"bindings",
23-
"cmake",
24-
"examples",
25-
"scripts",
26-
"models",
27-
"samples",
28-
"tests",
29-
"CMakeLists.txt",
30-
"Makefile",
31-
"ggml/src/ggml-metal/ggml-metal-embed.metal"
32-
],
33-
sources: [
34-
"ggml/src/ggml.c",
35-
"src/whisper.cpp",
36-
"ggml/src/ggml-aarch64.c",
37-
"ggml/src/ggml-alloc.c",
38-
"ggml/src/ggml-backend.cpp",
39-
"ggml/src/ggml-backend-reg.cpp",
40-
"ggml/src/ggml-cpu/ggml-cpu.c",
41-
"ggml/src/ggml-cpu/ggml-cpu.cpp",
42-
"ggml/src/ggml-cpu/ggml-cpu-aarch64.c",
43-
"ggml/src/ggml-cpu/ggml-cpu-quants.c",
44-
"ggml/src/ggml-quants.c",
45-
"ggml/src/ggml-threading.cpp",
46-
"ggml/src/ggml-metal/ggml-metal.m"
47-
],
48-
resources: [.process("ggml/src/ggml-metal/ggml-metal.metal")],
49-
publicHeadersPath: "spm-headers",
50-
cSettings: [
51-
.unsafeFlags(["-Wno-shorten-64-to-32", "-O3", "-DNDEBUG"]),
52-
.unsafeFlags(["-fno-objc-arc"]),
53-
.headerSearchPath("ggml/src"),
54-
.define("GGML_USE_ACCELERATE"),
55-
.define("GGML_USE_METAL")
56-
// NOTE: NEW_LAPACK will required iOS version 16.4+
57-
// We should consider add this in the future when we drop support for iOS 14
58-
// (ref: ref: https://developer.apple.com/documentation/accelerate/1513264-cblas_sgemm?language=objc)
59-
// .define("ACCELERATE_NEW_LAPACK"),
60-
// .define("ACCELERATE_LAPACK_ILP64")
61-
],
62-
linkerSettings: [
63-
.linkedFramework("Accelerate")
64-
]
65-
)
66-
],
67-
cxxLanguageStandard: .cxx11
17+
.systemLibrary(name: "whisper", pkgConfig: "whisper"),
18+
]
6819
)

Sources/whisper/module.modulemap

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module whisper [system] {
2+
header "whisper.h"
3+
link "whisper"
4+
export *
5+
}

Sources/whisper/whisper.h

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#pragma once
2+
3+
#include <whisper.h>
4+

cmake/whisper.pc.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
prefix=@CMAKE_INSTALL_PREFIX@
22
exec_prefix=${prefix}
3-
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
3+
libdir=${exec_prefix}/lib
44
includedir=${prefix}/include
55

66
Name: whisper
77
Description: Port of OpenAI's Whisper model in C/C++
88
Version: @PROJECT_VERSION@
9-
Libs: -L${libdir} -lwhisper
9+
Libs: -L${libdir} -lggml -lggml-base -lwhisper
1010
Cflags: -I${includedir}

examples/whisper.android/lib/src/main/jni/whisper/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
22

33
project(whisper.cpp)
44

5-
set(CMAKE_CXX_STANDARD 11)
5+
set(CMAKE_CXX_STANDARD 17)
66
set(WHISPER_LIB_DIR ${CMAKE_SOURCE_DIR}/../../../../../../..)
77

88
# Path to external GGML, otherwise uses the copy in whisper.cpp.

examples/whisper.objc/whisper.objc.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
364364
GCC_WARN_UNUSED_FUNCTION = YES;
365365
GCC_WARN_UNUSED_VARIABLE = YES;
366-
HEADER_SEARCH_PATHS = "";
366+
HEADER_SEARCH_PATHS = ../../../ggml/src/;
367367
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
368368
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
369369
MTL_FAST_MATH = YES;
@@ -417,7 +417,7 @@
417417
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
418418
GCC_WARN_UNUSED_FUNCTION = YES;
419419
GCC_WARN_UNUSED_VARIABLE = YES;
420-
HEADER_SEARCH_PATHS = "";
420+
HEADER_SEARCH_PATHS = ../../../ggml/src/;
421421
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
422422
MTL_ENABLE_DEBUG_INFO = NO;
423423
MTL_FAST_MATH = YES;

examples/whisper.swiftui/whisper.cpp.swift/LibWhisper.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ actor WhisperContext {
6666

6767
private func systemInfo() -> String {
6868
var info = ""
69-
if (ggml_cpu_has_neon() != 0) { info += "NEON " }
69+
//if (ggml_cpu_has_neon() != 0) { info += "NEON " }
7070
return String(info.dropLast())
7171
}
7272

@@ -75,45 +75,45 @@ actor WhisperContext {
7575
if (whisper_set_mel(context, nil, 0, nMels) != 0) {
7676
return "error: failed to set mel"
7777
}
78-
78+
7979
// heat encoder
8080
if (whisper_encode(context, 0, nThreads) != 0) {
8181
return "error: failed to encode"
8282
}
83-
83+
8484
var tokens = [whisper_token](repeating: 0, count: 512)
85-
85+
8686
// prompt heat
8787
if (whisper_decode(context, &tokens, 256, 0, nThreads) != 0) {
8888
return "error: failed to decode"
8989
}
90-
90+
9191
// text-generation heat
9292
if (whisper_decode(context, &tokens, 1, 256, nThreads) != 0) {
9393
return "error: failed to decode"
9494
}
95-
95+
9696
whisper_reset_timings(context)
97-
97+
9898
// actual run
9999
if (whisper_encode(context, 0, nThreads) != 0) {
100100
return "error: failed to encode"
101101
}
102-
102+
103103
// text-generation
104104
for i in 0..<256 {
105105
if (whisper_decode(context, &tokens, 1, Int32(i), nThreads) != 0) {
106106
return "error: failed to decode"
107107
}
108108
}
109-
109+
110110
// batched decoding
111111
for _ in 0..<64 {
112112
if (whisper_decode(context, &tokens, 5, 0, nThreads) != 0) {
113113
return "error: failed to decode"
114114
}
115115
}
116-
116+
117117
// prompt processing
118118
for _ in 0..<16 {
119119
if (whisper_decode(context, &tokens, 256, 0, nThreads) != 0) {

0 commit comments

Comments
 (0)