Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use swift-lmdb instead of copying LMDB source #228

Merged
merged 3 commits into from
Dec 18, 2024
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE YES)

find_package(dispatch CONFIG)
find_package(Foundation CONFIG)
find_package(LMDB CONFIG)

include(SwiftSupport)

Expand Down
36 changes: 26 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
// swift-tools-version:5.5

import Foundation
import PackageDescription

func hasEnvironmentVariable(_ name: String) -> Bool {
return ProcessInfo.processInfo.environment[name] != nil
}

/// Assume that all the package dependencies are checked out next to indexstore-db and use that instead of fetching a
/// remote dependency.
var useLocalDependencies: Bool { hasEnvironmentVariable("SWIFTCI_USE_LOCAL_DEPS") }

var dependencies: [Package.Dependency] {
if useLocalDependencies {
return [
.package(path: "../swift-lmdb"),
]
} else {
return [
.package(url: "https://github.com/swiftlang/swift-lmdb.git", branch: "main"),
]
}
}

let package = Package(
name: "IndexStoreDB",
products: [
Expand All @@ -18,7 +39,7 @@ let package = Package(
name: "tibs",
targets: ["tibs"])
],
dependencies: [],
dependencies: dependencies,
targets: [

// MARK: Swift interface
Expand Down Expand Up @@ -81,18 +102,13 @@ let package = Package(
// The lmdb database layer.
.target(
name: "IndexStoreDB_Database",
dependencies: ["IndexStoreDB_Core"],
dependencies: [
"IndexStoreDB_Core",
.product(name: "CLMDB", package: "swift-lmdb"),
],
path: "lib/Database",
exclude: [
"CMakeLists.txt",
"lmdb/LICENSE",
"lmdb/COPYRIGHT",
],
cSettings: [
.define("MDB_USE_POSIX_MUTEX", to: "1",
// Windows does not use POSIX mutex
.when(platforms: [.linux, .macOS])),
.define("MDB_USE_ROBUST", to: "0"),
]),

// Core index types.
Expand Down
5 changes: 2 additions & 3 deletions lib/Database/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ add_library(Database STATIC
Database.cpp
DatabaseError.cpp
ImportTransaction.cpp
ReadTransaction.cpp
lmdb/mdb.c
lmdb/midl.c)
ReadTransaction.cpp)
target_compile_definitions(Database PRIVATE
_CRT_NONSTDC_NO_WARNINGS
_CRT_SECURE_NO_WARNINGS)
Expand All @@ -13,6 +11,7 @@ target_compile_options(Database PRIVATE
target_include_directories(Database PRIVATE
include)
target_link_libraries(Database PRIVATE
LMDB::CLMDB
Core
LLVMSupport)
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
Expand Down
20 changes: 0 additions & 20 deletions lib/Database/lmdb/COPYRIGHT

This file was deleted.

47 changes: 0 additions & 47 deletions lib/Database/lmdb/LICENSE

This file was deleted.

Loading