swift-driver: force-unwrap file handles in swift-tools-support-core

This commit is contained in:
Pavel Sobolev 2023-11-21 21:37:37 +03:00
parent 56aa31d0b4
commit 647e9c8668
No known key found for this signature in database
2 changed files with 37 additions and 1 deletions

View File

@ -52,7 +52,10 @@ stdenv.mkDerivation {
})
];
configurePhase = generated.configure;
configurePhase = generated.configure + ''
swiftpmMakeMutable swift-tools-support-core
patch -p1 -d .build/checkouts/swift-tools-support-core -i ${./patches/force-unwrap-file-handles.patch}
'';
# TODO: Tests depend on indexstore-db being provided by an existing Swift
# toolchain. (ie. looks for `../lib/libIndexStore.so` relative to swiftc.

View File

@ -0,0 +1,33 @@
From 8d9ab4b6ed24a97e8af0cc338a52aacdcf438b8c Mon Sep 17 00:00:00 2001
From: Pavel Sobolev <paveloom@riseup.net>
Date: Tue, 21 Nov 2023 20:53:33 +0300
Subject: [PATCH] Force-unwrap file handles.
---
Sources/TSCBasic/FileSystem.swift | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Sources/TSCBasic/FileSystem.swift b/Sources/TSCBasic/FileSystem.swift
index 3a63bdf..a1f3d9d 100644
--- a/Sources/TSCBasic/FileSystem.swift
+++ b/Sources/TSCBasic/FileSystem.swift
@@ -425,7 +425,7 @@ private class LocalFileSystem: FileSystem {
if fp == nil {
throw FileSystemError(errno: errno, path)
}
- defer { fclose(fp) }
+ defer { fclose(fp!) }
// Read the data one block at a time.
let data = BufferedOutputByteStream()
@@ -455,7 +455,7 @@ private class LocalFileSystem: FileSystem {
if fp == nil {
throw FileSystemError(errno: errno, path)
}
- defer { fclose(fp) }
+ defer { fclose(fp!) }
// Write the data in one chunk.
var contents = bytes.contents
--
2.42.0