Skip to content
Open
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
2 changes: 2 additions & 0 deletions Sources/SwiftDocC/Benchmark/Benchmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class Benchmark: Encodable {
public let platform = "Android"
#elseif os(FreeBSD)
public let platform = "FreeBSD"
#elseif os(OpenBSD)
public let platform = "OpenBSD"
#else
public let platform = "unsupported"
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDocC/Benchmark/Metrics/PeakMemory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extension Benchmark {
) else { return nil }
return Int64(pmcStats.PeakWorkingSetSize)
}
#elseif os(FreeBSD)
#elseif os(FreeBSD) || os(OpenBSD)
private static func peakMemory() -> Int64? {
var usage = rusage()
if (getrusage(RUSAGE_SELF, &usage) == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ private class LongRunningService: ExternalLinkResolving {
/// This private class is only used by the ``OutOfProcessReferenceResolver`` and shouldn't be used for general communication with other processes.
private class LongRunningProcess: ExternalLinkResolving {

#if os(macOS) || os(Linux) || os(Android) || os(FreeBSD)
#if os(macOS) || os(Linux) || os(Android) || os(FreeBSD) || os(OpenBSD)
private let process: Process

init(location: URL, errorOutputHandler: @escaping (String) -> Void) throws {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDocC/Model/Rendering/RenderContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public struct RenderContext {
)
}

#if os(macOS) || os(iOS) || os(Android) || os(Windows) || os(FreeBSD)
#if os(macOS) || os(iOS) || os(Android) || os(Windows) || os(FreeBSD) || os(OpenBSD)
// Concurrently render content on macOS/iOS, Windows & Android
let results: [(reference: ResolvedTopicReference, content: RenderReferenceStore.TopicContent)] = references.concurrentPerform { reference, results in
results.append((reference, renderContentFor(reference)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

#if os(Linux) || os(Android) || os(Windows) || os(FreeBSD)
#if os(Linux) || os(Android) || os(Windows) || os(FreeBSD) || os(OpenBSD)
/// A shim for non-ObjC targets that runs the given block of code.
///
/// The existence of this shim allows you the use of auto-release pools to optimize memory footprint on Darwin platforms while maintaining
Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftDocC/Utility/Synchronization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Synchronized<Value> {
#elseif os(Linux) || os(Android)
/// A lock type appropriate for the current platform.
var lock: UnsafeMutablePointer<pthread_mutex_t>
#elseif os(FreeBSD)
#elseif os(FreeBSD) || os(OpenBSD)
/// A lock type appropriate for the current platform.
var lock: UnsafeMutablePointer<pthread_mutex_t?>
#elseif os(Windows)
Expand All @@ -56,7 +56,7 @@ public class Synchronized<Value> {
lock = UnsafeMutablePointer<pthread_mutex_t>.allocate(capacity: 1)
lock.initialize(to: pthread_mutex_t())
pthread_mutex_init(lock, nil)
#elseif os(FreeBSD)
#elseif os(FreeBSD) || os(OpenBSD)
lock = UnsafeMutablePointer<pthread_mutex_t?>.allocate(capacity: 1)
lock.initialize(to: nil)
pthread_mutex_init(lock, nil)
Expand Down Expand Up @@ -84,7 +84,7 @@ public class Synchronized<Value> {
#elseif os(Linux) || os(Android)
pthread_mutex_lock(lock)
defer { pthread_mutex_unlock(lock) }
#elseif os(FreeBSD)
#elseif os(FreeBSD) || os(OpenBSD)
pthread_mutex_lock(lock)
defer { pthread_mutex_unlock(lock) }
#elseif os(Windows)
Expand Down Expand Up @@ -123,7 +123,7 @@ extension Lock {
#elseif os(Linux) || os(Android)
pthread_mutex_lock(lock)
defer { pthread_mutex_unlock(lock) }
#elseif os(FreeBSD)
#elseif os(FreeBSD) || os(OpenBSD)
pthread_mutex_lock(lock)
defer { pthread_mutex_unlock(lock) }
#elseif os(Windows)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import Foundation
import SwiftDocC

#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)
import Darwin

/// A throttle object to filter events that come too fast.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDocCUtilities/Utility/Signal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public struct Signal {
signalAction.__sigaction_handler = unsafeBitCast(callback, to: sigaction.__Unnamed_union___sigaction_handler.self)
#elseif os(Android)
signalAction.sa_handler = callback
#elseif os(FreeBSD)
#elseif os(FreeBSD) || os(OpenBSD)
signalAction.__sigaction_u.__sa_handler = callback
#else
signalAction.__sigaction_u = unsafeBitCast(callback, to: __sigaction_u.self)
Expand Down
2 changes: 1 addition & 1 deletion Sources/docc/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

#if os(macOS) || os(Linux) || os(Android) || os(Windows) || os(FreeBSD)
#if os(macOS) || os(Linux) || os(Android) || os(Windows) || os(FreeBSD) || os(OpenBSD)
import SwiftDocCUtilities

await Task {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DocumentationSchemeHandlerTests: XCTestCase {
forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")!

func testDocumentationSchemeHandler() {
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)
let topicSchemeHandler = DocumentationSchemeHandler(withTemplateURL: templateURL)

let request = URLRequest(url: baseURL.appendingPathComponent("/images/figure1.jpg"))
Expand All @@ -50,7 +50,7 @@ class DocumentationSchemeHandlerTests: XCTestCase {
}

func testSetData() {
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)
let topicSchemeHandler = DocumentationSchemeHandler(withTemplateURL: templateURL)

let data = "hello!".data(using: .utf8)!
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftDocCTests/Servers/FileServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class FileServerTests: XCTestCase {
(response, data) = fileServer.response(to: failingRequest)
XCTAssertNil(data)
// Initializing a URLResponse with `nil` as MIME type in Linux returns nil
#if os(Linux) || os(Android) || os(Windows) || os(FreeBSD)
#if os(Linux) || os(Android) || os(Windows) || os(FreeBSD) || os(OpenBSD)
XCTAssertNil(response.mimeType)
#else
// Doing the same in macOS or iOS returns the default MIME type
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftDocCTests/Utility/LMDBTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ final class SwiftLMDBTests: XCTestCase {
}

func testArrayOfInt() throws {
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)
let database = try environment.openDatabase()

var array: [UInt32] = []
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftDocCUtilitiesTests/C+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import Foundation
#if os(Windows)
import ucrt
#elseif os(Linux) || os(Android) || os(FreeBSD)
#elseif os(Linux) || os(Android) || os(FreeBSD) || os(OpenBSD)
import Glibc
#else
import Darwin
Expand Down
10 changes: 5 additions & 5 deletions Tests/SwiftDocCUtilitiesTests/DirectoryMonitorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import XCTest
@testable import SwiftDocCUtilities

#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)
fileprivate extension NSNotification.Name {
static let testNodeUpdated = NSNotification.Name(rawValue: "testNodeUpdated")
static let testDirectoryReloaded = NSNotification.Name(rawValue: "testDirectoryReloaded")
Expand All @@ -24,7 +24,7 @@ func fileURLsAreEqual(_ url1: URL, _ url2: URL) -> Bool {
#endif

class DirectoryMonitorTests: XCTestCase {
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)
// - MARK: Directory watching test infra

/// Method that automates setting up a directory monitor, setting up the relevant expectations for a test,
Expand Down Expand Up @@ -115,7 +115,7 @@ class DirectoryMonitorTests: XCTestCase {
/// Tests a succession of file system changes and verifies that they produce
/// the expected monitor events.
func testMonitorUpdates() throws {
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)

// Create temp folder & sub-folder.
let tempSubfolderURL = try createTemporaryDirectory(named: "subfolder")
Expand Down Expand Up @@ -164,7 +164,7 @@ class DirectoryMonitorTests: XCTestCase {
}

func testMonitorDoesNotTriggerUpdates() throws {
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)

// Create temp folder & sub-folder.
let tempSubfolderURL = try createTemporaryDirectory(named: "subfolder")
Expand Down Expand Up @@ -197,7 +197,7 @@ class DirectoryMonitorTests: XCTestCase {

/// Tests a zero sum change aggregation triggers an event.
func testMonitorZeroSumSizeChangesUpdates() throws {
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)

// Create temp folder & sub-folder.
let tempSubfolderURL = try createTemporaryDirectory(named: "subfolder")
Expand Down
5 changes: 5 additions & 0 deletions build-script-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ def get_swiftpm_options(action, args):
]
if action == 'install':
swiftpm_args += ['--disable-local-rpath']
elif build_os.startswith('openbsd'):
swiftpm_args += [
'-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/openbsd',
'-Xlinker', '-z', '-Xlinker', 'origin',
]
else:
swiftpm_args += [
# Library rpath for swift, dispatch, Foundation, etc. when installing
Expand Down