Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ target_include_directories(FoundationDB-Swift PUBLIC
)

set(STATIC_SWIFT_LIBS
# ${SWIFT_SDK_STATIC_DIR}/libswiftCore.a
# ${SWIFT_SDK_STATIC_DIR}/libswiftDispatch.a
# ${SWIFT_SDK_STATIC_DIR}/libswiftSynchronization.a
# ${SWIFT_SDK_STATIC_DIR}/libswift_Concurrency.a
${SWIFT_SDK_STATIC_DIR}/libswiftCore.a
${SWIFT_SDK_STATIC_DIR}/libswiftDispatch.a
${SWIFT_SDK_STATIC_DIR}/libswiftSynchronization.a
${SWIFT_SDK_STATIC_DIR}/libswift_Concurrency.a

${SWIFT_SDK_STATIC_DIR}/libFoundation.a
${SWIFT_SDK_STATIC_DIR}/libCoreFoundation.a
${SWIFT_SDK_STATIC_DIR}/libFoundationInternationalization.a
${SWIFT_SDK_STATIC_DIR}/libswiftCore.a
${SWIFT_SDK_STATIC_DIR}/libswift_RegexParser.a
${SWIFT_SDK_STATIC_DIR}/libswift_StringProcessing.a
)

target_link_directories(FoundationDB-Swift PUBLIC
Expand Down
10 changes: 8 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import PackageDescription

let package = Package(
name: "FoundationDB",
platforms: [
.macOS(.v14)
],
products: [
.library(name: "FoundationDB", targets: ["FoundationDB"]),
.library(name: "FoundationDB", targets: ["FoundationDB"])
],
targets: [
.systemLibrary(
Expand All @@ -33,7 +36,10 @@ let package = Package(
.target(
name: "FoundationDB",
dependencies: ["CFoundationDB"],
path: "Sources/FoundationDB"
path: "Sources/FoundationDB",
linkerSettings: [
.unsafeFlags(["-Xlinker", "-rpath", "-Xlinker", "/usr/local/lib"])
]
),
.testTarget(
name: "FoundationDBTests",
Expand Down
2 changes: 1 addition & 1 deletion Sources/CFoundationDB/fdb_c_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef FDB_C_WRAPPER_H
#define FDB_C_WRAPPER_H

#define FDB_API_VERSION 740
#define FDB_API_VERSION 730
#include <foundationdb/fdb_c.h>

#endif
4 changes: 2 additions & 2 deletions Sources/FoundationDB/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import CFoundationDB
public class FdbClient {
/// FoundationDB API version constants.
public enum APIVersion {
/// The current supported API version (740).
public static let current: Int32 = 740
/// The current supported API version (730).
public static let current: Int32 = 730
}

/// Initializes the FoundationDB client with the specified API version.
Expand Down
10 changes: 5 additions & 5 deletions Sources/FoundationDB/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FdbNetwork {
/// Indicates whether the network has been set up.
private var networkSetup = false
/// The pthread handle for the network thread.
private var networkThread: pthread_t = .init()
private var networkThread: pthread_t? = nil

/// Initializes the FoundationDB network with the specified API version.
///
Expand Down Expand Up @@ -80,7 +80,7 @@ class FdbNetwork {
///
/// This method must be called before starting the network thread.
///
/// - Throws: `FdbError` if network setup fails or if already set up.
/// - Throws: `FdbError` if network setup fails or if already set up.X
func setupNetwork() throws {
guard !networkSetup else {
throw FdbError(.networkError)
Expand All @@ -100,10 +100,10 @@ class FdbNetwork {
/// The network must be set up before calling this method.
func startNetwork() {
guard networkSetup else {
fatalError("Network must be setup before starting network thread")
fatalError("Network must be setup before starting thread network")
}

var thread = pthread_t()
var thread = pthread_t(bitPattern: 0)
let result = pthread_create(&thread, nil, { _ in
let error = fdb_run_network()
if error != 0 {
Expand All @@ -127,7 +127,7 @@ class FdbNetwork {
}

if networkSetup {
pthread_join(networkThread, nil)
pthread_join(networkThread!, nil)
}
networkSetup = false
}
Expand Down
Loading