Skip to content

Commit

Permalink
Fix linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Automation committed Oct 18, 2024
1 parent b75d878 commit 68e698f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ jobs:
with:
name: hylo-lsp-artifacts-linux
path: |
artifacts/hylo-lsp-client
artifacts/hylo-lsp-server
${{ env.BUILD_DIR }}/hylo-lsp-client
${{ env.BUILD_DIR }}/hylo-lsp-server
build-native-macos:
name: "Build and test: ${{ matrix.host.os }}/${{ inputs.build-type }}"
Expand Down
30 changes: 23 additions & 7 deletions Sources/hylo-lsp-server/hylo-lsp-server-cli.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ extension Bool {
extension Logger.Level: @retroactive ExpressibleByArgument {
}

func forceLineBuffering() {
#if !os(Windows)
#if os(Linux)
/**
TODO: Fix this error:
/home/runner/work/hylo-lsp/hylo-lsp/Sources/hylo-lsp-server/hylo-lsp-server-cli.swift:31:11: error: reference to var 'stderr' is not concurrency-safe because it involves shared mutable state
29 | #if !os(Windows)
30 | setvbuf(stdout, nil, _IOLBF, 0)
31 | setvbuf(stderr, nil, _IOLBF, 0)
| `- error: reference to var 'stderr' is not concurrency-safe because it involves shared mutable state
32 | #endif
33 | }
SwiftGlibc.stderr:1:12: note: var declared here
1 | public var stderr: UnsafeMutablePointer<FILE>!
| `- note: var declared here
*/
#else
setvbuf(stdout, nil, _IOLBF, 0)
setvbuf(stderr, nil, _IOLBF, 0)
#endif
#endif
}

@main
struct HyloLspCommand: AsyncParsableCommand {
Expand Down Expand Up @@ -95,13 +117,7 @@ struct HyloLspCommand: AsyncParsableCommand {
}

func run() async throws {

#if !os(Windows)
// Force line buffering
setvbuf(stdout, nil, _IOLBF, 0)
setvbuf(stderr, nil, _IOLBF, 0)
#endif

forceLineBuffering()
let logFileURL = URL(fileURLWithPath: logFile)
// let fileLogger = try FileLogging(to: logFileURL)
let fileLogger = try FileLogger("hylo-lsp",
Expand Down

0 comments on commit 68e698f

Please sign in to comment.