android: use cmake build system

This commit is contained in:
Yury Popov
2022-12-02 21:34:33 +03:00
parent c60a49d711
commit 0f050397dc
4 changed files with 81 additions and 125 deletions
+54 -42
View File
@@ -25,45 +25,6 @@ dependencies {
androidTestImplementation 'org.hamcrest:hamcrest-all:1.3'
}
tasks.register('checkData') {
doFirst {
assert file("../espeak-ng-data/en_dict").exists()
assert file("../espeak-ng-data/intonations").exists()
assert file("../espeak-ng-data/phondata").exists()
assert file("../espeak-ng-data/phondata-manifest").exists()
assert file("../espeak-ng-data/phonindex").exists()
assert file("../espeak-ng-data/phontab").exists()
}
}
tasks.register('createDataArchive', Zip) {
dependsOn tasks.checkData
preserveFileTimestamps = false
reproducibleFileOrder = true
archiveFileName = "espeakdata.zip"
destinationDirectory = file("res/raw")
from("../espeak-ng-data/") {
into "espeak-ng-data"
}
}
tasks.register('createDataHash', Checksum) {
dependsOn tasks.createDataArchive
checksumAlgorithm.set(Checksum.Algorithm.SHA256)
inputFiles.setFrom(file("./res/raw/espeakdata.zip"))
outputDirectory.set(layout.buildDirectory.dir('intermediates/datahash'))
}
tasks.register('createDataVersion', Copy) {
dependsOn tasks.createDataHash
from layout.buildDirectory.file('intermediates/datahash/espeakdata.zip.sha256')
rename { return 'espeakdata_version' }
into file("./res/raw")
}
preBuild.dependsOn createDataVersion
android {
compileSdk 33
ndkVersion "25.1.8937393"
@@ -71,14 +32,22 @@ android {
defaultConfig {
minSdk 19
targetSdk 30
targetSdk 33
versionCode 22
versionName "1.52-dev"
externalNativeBuild {
cmake {
arguments "-DUSE_ASYNC:BOOL=OFF", "-DUSE_MBROLA:BOOL=OFF"
targets "ttsespeak", "espeak-data"
}
}
}
externalNativeBuild {
ndkBuild {
path "jni/Android.mk"
cmake {
path "jni/CMakeLists.txt"
version "3.22.1"
}
}
@@ -98,3 +67,46 @@ android {
abortOnError false
}
}
tasks.register('checkData') {
doFirst {
assert file("../espeak-ng-data/en_dict").exists()
assert file("../espeak-ng-data/intonations").exists()
assert file("../espeak-ng-data/phondata").exists()
assert file("../espeak-ng-data/phondata-manifest").exists()
assert file("../espeak-ng-data/phonindex").exists()
assert file("../espeak-ng-data/phontab").exists()
}
}
tasks.register('createDataArchive', Zip) {
preserveFileTimestamps = false
reproducibleFileOrder = true
archiveFileName = "espeakdata.zip"
destinationDirectory = file("res/raw")
from("build/generated/espeak-ng-data/") {
into "espeak-ng-data"
}
}
tasks.register('createDataHash', Checksum) {
dependsOn tasks.createDataArchive
checksumAlgorithm.set(Checksum.Algorithm.SHA256)
inputFiles.setFrom(file("./res/raw/espeakdata.zip"))
outputDirectory.set(layout.buildDirectory.dir('intermediates/datahash'))
}
tasks.register('createDataVersion', Copy) {
dependsOn tasks.createDataHash
from layout.buildDirectory.file('intermediates/datahash/espeakdata.zip.sha256')
rename { return 'espeakdata_version' }
into file("./res/raw")
}
project.afterEvaluate {
tasks.checkData.dependsOn(externalNativeBuildDebug)
tasks.createDataArchive.dependsOn(externalNativeBuildDebug)
javaPreCompileDebug.dependsOn(tasks.createDataVersion)
javaPreCompileRelease.dependsOn(tasks.createDataVersion)
}
-83
View File
@@ -1,83 +0,0 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
#LOCAL_CFLAGS = -std=c11 # speechplayer is c++ code
# ucd-tools wide-character compatibility support:
UCDTOOLS_SRC_PATH := ../../src/ucd-tools/src
UCDTOOLS_SRC_FILES := \
$(subst $(LOCAL_PATH)/$(UCDTOOLS_SRC_PATH),$(UCDTOOLS_SRC_PATH),$(wildcard $(LOCAL_PATH)/$(UCDTOOLS_SRC_PATH)/*.c*))
LOCAL_SRC_FILES += $(UCDTOOLS_SRC_FILES)
SPEECHPLAYER_SRC_FILES := \
../../src/speechPlayer/src/frame.cpp \
../../src/speechPlayer/src/speechPlayer.cpp \
../../src/speechPlayer/src/speechWaveGenerator.cpp
LOCAL_SRC_FILES += $(SPEECHPLAYER_SRC_FILES)
ESPEAK_SOURCES := \
src/libespeak-ng/common.c \
src/libespeak-ng/compiledata.c \
src/libespeak-ng/compiledict.c \
src/libespeak-ng/compilembrola.c \
src/libespeak-ng/dictionary.c \
src/libespeak-ng/encoding.c \
src/libespeak-ng/error.c \
src/libespeak-ng/espeak_api.c \
src/libespeak-ng/ieee80.c \
src/libespeak-ng/intonation.c \
src/libespeak-ng/klatt.c \
src/libespeak-ng/langopts.c \
src/libespeak-ng/mnemonics.c \
src/libespeak-ng/numbers.c \
src/libespeak-ng/phoneme.c \
src/libespeak-ng/phonemelist.c \
src/libespeak-ng/readclause.c \
src/libespeak-ng/setlengths.c \
src/libespeak-ng/soundicon.c \
src/libespeak-ng/spect.c \
src/libespeak-ng/speech.c \
src/libespeak-ng/sPlayer.c \
src/libespeak-ng/ssml.c \
src/libespeak-ng/synthdata.c \
src/libespeak-ng/synthesize.c \
src/libespeak-ng/synth_mbrola.c \
src/libespeak-ng/translate.c \
src/libespeak-ng/translateword.c \
src/libespeak-ng/tr_languages.c \
src/libespeak-ng/voices.c \
src/libespeak-ng/wavegen.c
ESPEAK_SRC_PATH := ../../src
ESPEAK_SRC_FILES := \
$(subst src/,$(ESPEAK_SRC_PATH)/,$(ESPEAK_SOURCES))
LOCAL_CFLAGS += -DINCLUDE_KLATT -DINCLUDE_SPEECHPLAYER -DINCLUDE_SONIC -DHAVE_ENDIAN_H
LOCAL_SRC_FILES += \
$(filter-out $(BLACKLIST_SRC_FILES),$(ESPEAK_SRC_FILES))
# JNI
LOCAL_SRC_FILES += \
$(subst $(LOCAL_PATH)/jni,jni,$(wildcard $(LOCAL_PATH)/jni/*.c))
# Common
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/$(UCDTOOLS_SRC_PATH)/include \
$(LOCAL_PATH)/../../src/speechPlayer/include \
$(LOCAL_PATH)/$(ESPEAK_SRC_PATH)/include \
$(LOCAL_PATH)/$(ESPEAK_SRC_PATH)/include/compat
LOCAL_LDLIBS := \
-llog
LOCAL_MODULE := libttsespeak
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
+26
View File
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.8)
project(espeak-android)
add_subdirectory(../../ espeakng)
add_custom_target(
espeak-data
COMMAND ${CMAKE_COMMAND} -B${CMAKE_CURRENT_BINARY_DIR}/../espeak-data ${CMAKE_CURRENT_SOURCE_DIR}/../../
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/../espeak-data --target data
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/../espeak-data/espeak-ng-data ${CMAKE_SOURCE_DIR}/../build/generated/espeak-ng-data
)
message(STATUS "Data: ${CMAKE_CURRENT_SOURCE_DIR}")
find_library(A_LOG log)
add_library(ttsespeak SHARED
jni/eSpeakService.c
)
target_include_directories(ttsespeak PRIVATE
include
)
target_link_libraries(ttsespeak PRIVATE
espeak-ng ${A_LOG}
)
+1
View File
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <jni.h>
#include <espeak/speak_lib.h>