diff --git a/.gitignore b/.gitignore index 8cbabe85..c500a8ca 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ bld/ # Visual Studio 2015/2017 cache/options directory .vs/ +.idea/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ diff --git a/Makefile b/Makefile index 4218d9de..07526ef8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,16 @@ BUILD_TYPE=Release VERSION=1.4.0 +CMAKE_PARAMETERS=-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) +NDK := +ifeq ($(strip $(NDK_PATH)),) + ifeq ($(shell test -d $(HOME)/Library/Developer/Xamarin/android-sdk-macosx/ndk-bundle && echo -n yes),yes) + NDK := $(HOME)/Library/Developer/Xamarin/android-sdk-macosx/ndk-bundle + else + $(error NDK_PATH not defined and NDK not found at default location on Mac.) + endif +else + NDK := $(strip $(NDK_PATH)) +endif nuget: mkdir -p nupkgs @@ -37,70 +48,70 @@ linux_arm: macos: rm -rf build/macos - cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=MAC_UNIVERSAL -S . -B build/macos + cmake $(CMAKE_PARAMETERS) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=MAC_UNIVERSAL -S . -B build/macos cmake --build build/macos mkdir -p runtimes/macos cp build/macos/whisper.cpp/libwhisper.dylib runtimes/macos/libwhisper.dylib ios: rm -rf build/ios - cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=OS -S . -B build/ios + cmake $(CMAKE_PARAMETERS) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=OS -S . -B build/ios cmake --build build/ios mkdir -p runtimes/ios cp build/ios/whisper.cpp/libwhisper.dylib runtimes/ios/libwhisper.dylib ios_64: rm -rf build/ios_64 - cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=OS64 -S . -B build/ios_64 + cmake $(CMAKE_PARAMETERS) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=OS64 -S . -B build/ios_64 cmake --build build/ios_64 mkdir -p runtimes/ios_64 cp build/ios_64/whisper.cpp/libwhisper.dylib runtimes/ios_64/libwhisper.dylib maccatalyst_x64: rm -rf build/maccatalyst_x64 - cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=MAC_CATALYST -S . -B build/maccatalyst_x64 + cmake $(CMAKE_PARAMETERS) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=MAC_CATALYST -S . -B build/maccatalyst_x64 cmake --build build/maccatalyst_x64 mkdir -p runtimes/maccatalyst_x64 cp build/maccatalyst_x64/whisper.cpp/libwhisper.dylib runtimes/maccatalyst_x64/libwhisper.dylib maccatalyst_arm64: rm -rf build/maccatalyst_arm64 - cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=MAC_CATALYST_ARM64 -S . -B build/maccatalyst_arm64 + cmake $(CMAKE_PARAMETERS) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=MAC_CATALYST_ARM64 -S . -B build/maccatalyst_arm64 cmake --build build/maccatalyst_arm64 mkdir -p runtimes/maccatalyst_arm64 cp build/maccatalyst_arm64/whisper.cpp/libwhisper.dylib runtimes/maccatalyst_arm64/libwhisper.dylib ios_simulator_x64: rm -rf build/ios_simulator_x64 - cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=SIMULATOR64 -S . -B build/ios_simulator_x64 + cmake $(CMAKE_PARAMETERS) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=SIMULATOR64 -S . -B build/ios_simulator_x64 cmake --build build/ios_simulator_x64 mkdir -p runtimes/ios_simulator_x64 cp build/ios_simulator_x64/whisper.cpp/libwhisper.dylib runtimes/ios_simulator_x64/libwhisper.dylib ios_simulator_arm64: rm -rf build/ios_simulator_arm64 - cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=SIMULATORARM64 -S . -B build/ios_simulator_arm64 + cmake $(CMAKE_PARAMETERS) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=SIMULATORARM64 -S . -B build/ios_simulator_arm64 cmake --build build/ios_simulator_arm64 mkdir -p runtimes/ios_simulator_arm64 cp build/ios_simulator_arm64/whisper.cpp/libwhisper.dylib runtimes/ios_simulator_arm64/libwhisper.dylib tvos_simulator_x64: rm -rf build/tvos_simulator_x64 - cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=SIMULATOR_TVOS -S . -B build/tvos_simulator_x64 + cmake $(CMAKE_PARAMETERS) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=SIMULATOR_TVOS -S . -B build/tvos_simulator_x64 cmake --build build/tvos_simulator_x64 mkdir -p runtimes/tvos_simulator_x64 cp build/tvos_simulator_x64/whisper.cpp/libwhisper.dylib runtimes/tvos_simulator_x64/libwhisper.dylib tvos_simulator_arm64: rm -rf build/tvos_simulator_arm64 - cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=SIMULATOR_TVOSARM64 -S . -B build/tvos_simulator_arm64 + cmake $(CMAKE_PARAMETERS) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=SIMULATOR_TVOSARM64 -S . -B build/tvos_simulator_arm64 cmake --build build/tvos_simulator_arm64 mkdir -p runtimes/tvos_simulator_arm64 cp build/tvos_simulator_arm64/whisper.cpp/libwhisper.dylib runtimes/tvos_simulator_arm64/libwhisper.dylib tvos: rm -rf build/tvos - cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=TVOS -S . -B build/tvos + cmake $(CMAKE_PARAMETERS) -DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DPLATFORM=TVOS -S . -B build/tvos cmake --build build/tvos mkdir -p runtimes/tvos cp build/tvos/whisper.cpp/libwhisper.dylib runtimes/tvos/libwhisper.dylib @@ -121,21 +132,21 @@ lipo: android_arm64-v8a: rm -rf build/android-arm64-v8a - cmake -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API=21 -DCMAKE_ANDROID_NDK=/Users/sandrohanea/Library/Developer/Xamarin/android-sdk-macosx/ndk-bundle -S . -B build/android-arm64-v8a + cmake $(CMAKE_PARAMETERS) -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API=21 -DCMAKE_ANDROID_NDK=$(NDK) -S . -B build/android-arm64-v8a cmake --build build/android-arm64-v8a mkdir -p Whisper.net.Runtime/android-arm64-v8a cp build/android-arm64-v8a/whisper.cpp/libwhisper.so Whisper.net.Runtime/android-arm64-v8a/libwhisper.so android_x86: rm -rf build/android-x86 - cmake -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API=21 -DCMAKE_ANDROID_NDK=/Users/sandrohanea/Library/Developer/Xamarin/android-sdk-macosx/ndk-bundle -S . -B build/android-x86 + cmake $(CMAKE_PARAMETERS) -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API=21 -DCMAKE_ANDROID_NDK=$(NDK) -S . -B build/android-x86 cmake --build build/android-x86 mkdir -p Whisper.net.Runtime/android-x86 cp build/android-x86/whisper.cpp/libwhisper.so Whisper.net.Runtime/android-x86/libwhisper.so android_x64: rm -rf build/android-x86_64 - cmake -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API=21 -DCMAKE_ANDROID_NDK=/Users/sandrohanea/Library/Developer/Xamarin/android-sdk-macosx/ndk-bundle -S . -B build/android-x86_64 + cmake $(CMAKE_PARAMETERS) -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API=21 -DCMAKE_ANDROID_NDK=$(NDK) -S . -B build/android-x86_64 cmake --build build/android-x86_64 mkdir -p Whisper.net.Runtime/android-x86_64 cp build/android-x86_64/whisper.cpp/libwhisper.so Whisper.net.Runtime/android-x86_64/libwhisper.so diff --git a/readme.md b/readme.md index 84d2469d..d4374d18 100644 --- a/readme.md +++ b/readme.md @@ -74,6 +74,40 @@ Also, for easier integration Whisper.net provides a Downloader which is using ht You can find the documentation and code samples here: [https://github.com/sandrohanea/whisper.net](https://github.com/sandrohanea/whisper.net) +## Building The Runtime + +The build scripts are a combination of PowerShell scripts and a Makefile. You can read each of them for the underlying `cmake` commands being used, or run them directly from the scripts. + +### Android: + +`make android` + +- Before running, create an environment variable for `NDK_PATH` with the path to your Android NDK. For example, + +`NDK_PATH=/Users/UserName/Library/Developer/Xamarin/android-sdk-macosx/ndk-bundle` + +### Apple: + +`make apple` + +or + +`pwsh ./scripts/build-osx.ps1` + +- Compiling the Apple libraries requires a Mac with Xcode installed. + +### Linux: + +`make linux` + +or + +`pwsh ./scripts/build-linux.ps1` + +### Windows: + +- Run the `.bat` files in the root of this repo, or the powershell `./script/build-windows.ps1` + ## License MIT Licence