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

Main framework compiles on Linux #354

Merged
merged 5 commits into from
May 21, 2018
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
8 changes: 7 additions & 1 deletion GRDB/Core/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ extension Database {
let db = Unmanaged<Database>.fromOpaque(dbPointer!).takeUnretainedValue()
db.configuration.trace!(sql)
}, dbPointer)
#else
#elseif !os(Linux)
if #available(iOS 10.0, OSX 10.12, watchOS 3.0, *) {
sqlite3_trace_v2(sqliteConnection, UInt32(SQLITE_TRACE_STMT), { (mask, dbPointer, stmt, unexpandedSQL) -> Int32 in
guard let stmt = stmt else { return SQLITE_OK }
Expand All @@ -322,6 +322,12 @@ extension Database {
db.configuration.trace!(sql)
}, dbPointer)
}
#else
sqlite3_trace(sqliteConnection, { (dbPointer, sql) in
guard let sql = sql.map({ String(cString: $0) }) else { return }
let db = Unmanaged<Database>.fromOpaque(dbPointer!).takeUnretainedValue()
db.configuration.trace!(sql)
}, dbPointer)
#endif
}

Expand Down
3 changes: 3 additions & 0 deletions GRDB/Core/StatementAuthorizer.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#if os(Linux)
import Glibc
#endif
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
Expand Down
2 changes: 2 additions & 0 deletions GRDB/Core/Support/CoreGraphics/CGFloat.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(Linux)
import CoreGraphics

/// CGFloat adopts DatabaseValueConvertible
Expand All @@ -16,3 +17,4 @@ extension CGFloat : DatabaseValueConvertible {
return CGFloat(double)
}
}
#endif
2 changes: 2 additions & 0 deletions GRDB/Core/Support/Foundation/Date.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Foundation
import SQLite3
#endif

#if !os(Linux)
/// NSDate is stored in the database using the format
/// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone.
extension NSDate : DatabaseValueConvertible {
Expand All @@ -31,6 +32,7 @@ extension NSDate : DatabaseValueConvertible {
return cast(date)
}
}
#endif

/// Date is stored in the database using the format
/// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone.
Expand Down
2 changes: 2 additions & 0 deletions GRDB/Core/Support/Foundation/NSData.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(Linux)
import Foundation

/// NSData is convertible to and from DatabaseValue.
Expand All @@ -17,3 +18,4 @@ extension NSData : DatabaseValueConvertible {
return cast(data)
}
}
#endif
2 changes: 2 additions & 0 deletions GRDB/Core/Support/Foundation/NSNumber.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(Linux)
import Foundation

private let integerRoundingBehavior = NSDecimalNumberHandler(roundingMode: .plain, scale: 0, raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)
Expand Down Expand Up @@ -65,3 +66,4 @@ extension NSNumber : DatabaseValueConvertible {
}
}
}
#endif
2 changes: 2 additions & 0 deletions GRDB/Core/Support/Foundation/NSString.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(Linux)
import Foundation

/// NSString adopts DatabaseValueConvertible
Expand All @@ -16,3 +17,4 @@ extension NSString : DatabaseValueConvertible {
return self.init(string: string)
}
}
#endif
2 changes: 2 additions & 0 deletions GRDB/Core/Support/Foundation/URL.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation

#if !os(Linux)
/// NSURL stores its absoluteString in the database.
extension NSURL : DatabaseValueConvertible {

Expand All @@ -17,6 +18,7 @@ extension NSURL : DatabaseValueConvertible {
return cast(URL(string: string))
}
}
#endif

/// URL stores its absoluteString in the database.
extension URL : DatabaseValueConvertible { }
4 changes: 3 additions & 1 deletion GRDB/Core/Support/Foundation/UUID.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation

#if !os(Linux)
/// NSUUID adopts DatabaseValueConvertible
extension NSUUID : DatabaseValueConvertible {

Expand All @@ -18,8 +19,9 @@ extension NSUUID : DatabaseValueConvertible {
return nil
}
return self.init(uuidBytes: data.bytes.assumingMemoryBound(to: UInt8.self))
}
}
}
#endif

/// UUID adopts DatabaseValueConvertible
extension UUID : DatabaseValueConvertible { }