Skip to content

Commit

Permalink
Moved files around renamced RHVoice to RHVoiceObjC and created new RH…
Browse files Browse the repository at this point in the history
…VoiceSwift to start adding Swift implementation and deprecate RHVoiceObjC
  • Loading branch information
IhorShevchuk committed Mar 9, 2024
1 parent 1ca750d commit 15c36f7
Show file tree
Hide file tree
Showing 33 changed files with 111 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
submodules: recursive
- run: |
rm -fr .build | echo "Removed build folder"
swift build -c release --target RHVoiceCore
swift build -c release --target RHVoiceSwift
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "RHVoice"]
path = RHVoice
path = RHVoice/RHVoice
url = https://github.com/RHVoice/RHVoice.git
132 changes: 88 additions & 44 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// swift-tools-version: 5.7
// swift-tools-version: 5.9

// Copyright (C) 2022 Olga Yakovleva <olga@rhvoice.org>

import PackageDescription
import Foundation

func boostHeaders() -> [CSetting] {
func boostHeadersPaths() -> [String] {
let packageURL = URL(fileURLWithPath: #file).deletingLastPathComponent()
let RHVoicePath = packageURL
.appendingPathComponent("RHVoice")
.appendingPathComponent("RHVoice")
let boostRoot = RHVoicePath
.appendingPathComponent("external")
.appendingPathComponent("libs")
Expand All @@ -22,7 +23,7 @@ func boostHeaders() -> [CSetting] {

folderEnumerator.skipDescendants()

var result: [CSetting] = []
var result: [String] = []
for folder in folderEnumerator {
guard let folderPath = folder as? URL else {
continue
Expand All @@ -31,13 +32,31 @@ func boostHeaders() -> [CSetting] {
let includePath = folderPath.appendingPathComponent("include").path
if fileManager.fileExists(atPath: includePath) {
let path = includePath.replacingOccurrences(of: RHVoicePath.path + "/", with: "")
result.append(.headerSearchPath(path))
result.append(path)
}
}

return result
}

func boostHeaders(prefix: String = "") -> [CSetting] {
return boostHeadersPaths().map { path in
return .headerSearchPath(prefix + path)
}
}

func commonHeaderSearchPath(prefix: String = "") -> [CSetting] {
let headerPaths = [
"RHVoice/src/third-party/utf8",
"RHVoice/src/third-party/rapidxml",
"RHVoice/src/include"
]

return headerPaths.map { path in
return .headerSearchPath(prefix + path)
}
}

let package = Package(
name: "RHVoice",
platforms: [
Expand All @@ -48,58 +67,56 @@ let package = Package(
],
products: [
.library(
name: "RHVoice",
targets: ["RHVoice"]),
name: "RHVoiceObjC",
targets: ["RHVoiceObjC"]),
.plugin(name: "PackDataPlugin", targets: [
"PackDataPlugin"
])
]),
.library(name: "RHVoiceSwift",
targets: ["RHVoiceSwift"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0")
],
targets: [
.target(
name: "RHVoiceCore",
name: "RHVoice",
dependencies: [
],
path: "RHVoice/",
path: "RHVoice",
exclude: [
// Files that are not compiled because they are included into sources directly
"src/core/unidata.cpp",
"src/core/userdict_parser.c",
"src/core/emoji_data.cpp",
"RHVoice/src/core/unidata.cpp",
"RHVoice/src/core/userdict_parser.c",
"RHVoice/src/core/emoji_data.cpp",
// Platform audio files that shouldn't be compiled for iOS and macOS(at least in scope of this package)
"src/audio/libao.cpp",
"src/audio/portaudio.cpp",
"src/audio/pulse.cpp",
"RHVoice/src/audio/libao.cpp",
"RHVoice/src/audio/portaudio.cpp",
"RHVoice/src/audio/pulse.cpp",
// cmake files
"src/core/CMakeLists.txt",
"src/hts_engine/CMakeLists.txt",
"src/audio/CMakeLists.txt",
"src/lib/CMakeLists.txt",
"RHVoice/src/core/CMakeLists.txt",
"RHVoice/src/hts_engine/CMakeLists.txt",
"RHVoice/src/audio/CMakeLists.txt",
"RHVoice/src/lib/CMakeLists.txt",
// Scons files
"src/audio/SConscript",
"src/core/SConscript",
"src/hts_engine/SConscript",
"src/lib/SConscript",
"src/pkg/SConscript",
"RHVoice/src/audio/SConscript",
"RHVoice/src/core/SConscript",
"RHVoice/src/hts_engine/SConscript",
"RHVoice/src/lib/SConscript",
"RHVoice/src/pkg/SConscript",
// Not used on Apple platfroms since config path is set during runtime
"src/core/config.h.in",
"RHVoice/src/core/config.h.in",
// Not used on Apple platforms
"src/core/userdict_parser.g"
"RHVoice/src/core/userdict_parser.g"
],
sources: [
"src/core",
"src/hts_engine",
"src/lib",
"src/audio"
"RHVoice/src/core",
"RHVoice/src/hts_engine",
"RHVoice/src/lib",
"RHVoice/src/audio"
],
publicHeadersPath: "src/include/",
cSettings: [
.headerSearchPath("src/include/**"),
.headerSearchPath("src/hts_engine"),
.headerSearchPath("src/third-party/utf8"),
.headerSearchPath("src/third-party/rapidxml"),
.headerSearchPath("RHVoice/src/hts_engine"),
.headerSearchPath("../Sources/Mock"),
.define("RHVOICE"),
.define("PACKAGE", to: "\"RHVoice\""),
Expand All @@ -108,35 +125,62 @@ let package = Package(
.define("ANDROID"),
.define("TARGET_OS_IPHONE", .when(platforms: [.iOS])),
.define("TARGET_OS_MAC", .when(platforms: [.macOS]))
] + boostHeaders()
]
+ boostHeaders(prefix: "RHVoice/")
+ commonHeaderSearchPath()
),
.target(name: "RHVoice",
.target(name: "RHVoiceObjC",
dependencies: [
.target(name: "RHVoiceCore")
.target(name: "RHVoice")
],
path: "Sources",
exclude: [
"RHVoiceSwift"
],
sources: [
"CoreLib",
"RHVoice",
"Utils"
],
publicHeadersPath: "RHVoice/PublicHeaders/",
publicHeadersPath: "RHVoiceObjC/PublicHeaders/",
cSettings: [
.headerSearchPath("../RHVoice/src/third-party/utf8"),
.headerSearchPath("../RHVoice/src/third-party/rapidxml"),
.headerSearchPath("RHVoice/Logger"),
.headerSearchPath("RHVoice/PrivateHeaders"),
.headerSearchPath("RHVoiceObjC/Logger"),
.headerSearchPath("RHVoiceObjC/PrivateHeaders"),
.headerSearchPath("Utils"),
.headerSearchPath("CoreLib"),
.headerSearchPath("Mock"),
.define("ANDROID"),
.define("TARGET_OS_IPHONE", .when(platforms: [.iOS])),
.define("TARGET_OS_MAC", .when(platforms: [.macOS]))
],
]
+ commonHeaderSearchPath(prefix: "../RHVoice/")
,
linkerSettings: [
.linkedFramework("AVFAudio")
]
),
.target(name: "RHVoiceSwift",
dependencies: [
.target(name: "RHVoice")
],
path: "Sources",
sources: [
"RHVoiceSwift"
],
cSettings: ([
.headerSearchPath("Mock"),
.define("ANDROID"),
.define("TARGET_OS_IPHONE", .when(platforms: [.iOS])),
.define("TARGET_OS_MAC", .when(platforms: [.macOS]))
]
+ boostHeaders(prefix: "../RHVoice/RHVoice/")
+ commonHeaderSearchPath(prefix: "../RHVoice/")

),
swiftSettings: [
.interoperabilityMode(.Cxx)
]
),
/// Plugin to copy languages and voices data files
.executableTarget(
name: "PackDataExecutable",
Expand Down
8 changes: 8 additions & 0 deletions RHVoice/include/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module RHVoice {
umbrella "../RHVoice/src/include/"

explicit module * {
export *
}
requires cplusplus
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>

#import <RHVoice/RHVoiceLoggerProtocol.h>
#import "RHVoice_common.h"
#import "RHVoice.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "RHEventLoggerImpl.hpp"
#include "core/engine.hpp"
#include "../../RHVoice/src/include/RHVoice.h"
#include "../../RHVoice/RHVoice/src/include/RHVoice.h"

@interface RHVoiceBridge () {
std::shared_ptr<RHVoice::engine> RHEngine;
Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions Sources/RHVoiceSwift/RHVoice.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// RHVoice.swift
//
//
// Created by Ihor Shevchuk on 08.03.2024.
//

import Foundation
import RHVoice.core.package_client

let voice_package = RHVoice.pkg.voice_package()

0 comments on commit 15c36f7

Please sign in to comment.