Skip to content

Commit 868f15b

Browse files
authored
Merge pull request #2915 from lorentey/add-overlay
Import the Foundation overlay codebase from the Swift repository
2 parents 57c6d69 + b463609 commit 868f15b

File tree

144 files changed

+44992
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+44992
-0
lines changed

Darwin/Config/install-swiftmodules.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
#===----------------------------------------------------------------------===//
3+
#
4+
# This source file is part of the Swift.org open source project
5+
#
6+
# Copyright (c) 2020 Apple Inc. and the Swift project authors
7+
# Licensed under Apache License v2.0 with Runtime Library Exception
8+
#
9+
# See http://swift.org/LICENSE.txt for license information
10+
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
11+
#
12+
#===----------------------------------------------------------------------===//
13+
14+
set -e
15+
#set -xv
16+
17+
# This only needs to run during installation, but that includes "installapi".
18+
[ "$ACTION" = "installapi" -o "$ACTION" = "install" ] || exit 0
19+
20+
[ "$SKIP_INSTALL" != "YES" ] || exit 0
21+
[ "$SWIFT_INSTALL_MODULES" = "YES" ] || exit 0
22+
23+
srcmodule="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.swiftmodule"
24+
dstpath="${INSTALL_ROOT}/${INSTALL_PATH}/"
25+
26+
if [ ! -d "$srcmodule" ]; then
27+
echo "Cannot find Swift module at $srcmodule" >&2
28+
exit 1
29+
fi
30+
31+
mkdir -p "$dstpath"
32+
cp -r "$srcmodule" "$dstpath"

Darwin/Config/overlay-base.xcconfig

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// Configuration settings file format documentation can be found at:
14+
// https://help.apple.com/xcode/#/dev745c5c974
15+
16+
// Base configuration for Swift overlays.
17+
18+
EXECUTABLE_PREFIX = libswift
19+
SWIFT_OVERLAY_INSTALL_PATH=/usr/lib/swift
20+
STRIP_SWIFT_SYMBOLS = NO
21+
BUILD_LIBRARY_FOR_DISTRIBUTION = YES
22+
GENERATE_TEXT_BASED_STUBS = YES
23+
SWIFT_LINK_OBJC_RUNTIME = NO
24+
CLANG_LINK_OBJC_RUNTIME = NO
25+
26+
// Enable InstallAPI.
27+
SUPPORTS_TEXT_BASED_API = YES
28+
29+
// We need to run install-swiftmodules.sh during the installapi action.
30+
INSTALLHDRS_SCRIPT_PHASE = YES
31+
32+
INSTALL_PATH=$(SWIFT_OVERLAY_INSTALL_PATH)
33+
34+
OTHER_SWIFT_FLAGS = -module-link-name $(SWIFT_MODULE_LINK_NAME) -autolink-force-load -runtime-compatibility-version none
35+
SWIFT_MODULE_LINK_NAME = swift$(PRODUCT_NAME)
36+
SWIFT_ENABLE_INCREMENTAL_COMPILATION = NO // YES conflicts with -autolink-force-load
37+
38+
// Custom build settings for install-swiftmodules.sh.
39+
SWIFT_INSTALL_MODULES = YES
40+
SWIFT_MODULE_INSTALL_PATH = $(INSTALL_PATH)
41+
42+
// We need to generate swiftmodules for these architectures, so that they can be
43+
// imported in apps that are deployable on OS versions that support them.
44+
// However, we can only generate module files for these; we can't emit binaries.
45+
// (All imported definitions will be unavailable on these older OS versions.)
46+
SWIFT_MODULE_ONLY_IPHONEOS_DEPLOYMENT_TARGET = 10.3
47+
SWIFT_MODULE_ONLY_ARCHS_iphoneos = armv7 armv7s
48+
SWIFT_MODULE_ONLY_ARCHS_iphonesimulator = i386
49+
SWIFT_MODULE_ONLY_ARCHS = $(SWIFT_MODULE_ONLY_ARCHS_$(PLATFORM_NAME))

Darwin/Config/overlay-debug.xcconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// Configuration settings file format documentation can be found at:
14+
// https://help.apple.com/xcode/#/dev745c5c974
15+
16+
#include "../Config/overlay-base.xcconfig"
17+
18+
ONLY_ACTIVE_ARCH = YES
19+
ENABLE_TESTABILITY = YES
20+
GCC_OPTIMIZATION_LEVEL = 0
21+
SWIFT_OPTIMIZATION_LEVEL = -Onone
22+
DEBUG_INFORMATION_FORMAT = dwarf
23+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG
24+
GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 $(inherited)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// Configuration settings file format documentation can be found at:
14+
// https://help.apple.com/xcode/#/dev745c5c974
15+
16+
#include "../Config/overlay-base.xcconfig"
17+
18+
ONLY_ACTIVE_ARCH = NO
19+
ENABLE_TESTABILITY = NO
20+
GCC_OPTIMIZATION_LEVEL = s
21+
SWIFT_OPTIMIZATION_LEVEL = -O
22+
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
23+
SWIFT_COMPILATION_MODE = wholemodule
24+
ENABLE_NS_ASSERTIONS = NO

Darwin/Config/overlay-shared.xcconfig

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// Configuration settings file format documentation can be found at:
14+
// https://help.apple.com/xcode/#/dev745c5c974
15+
16+
SWIFT_IS_OVERLAY = YES
17+
18+
SWIFT_VERSION = 5.0
19+
SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator
20+
21+
// TAPI needs to be told about the magic-symbols-for-install-name header.
22+
OTHER_TAPI_FLAGS = $(inherited) -extra-public-header $(SRCROOT)/$(PRODUCT_NAME)-swiftoverlay/magic-symbols-for-install-name.h
23+
24+
// Pass the module link name to C/C++ files; this is needed to generate the
25+
// magic install name symbols for overlays that existed in Swift 5.0.
26+
GCC_PREPROCESSOR_DEFINITIONS = SWIFT_TARGET_LIBRARY_NAME=$(SWIFT_MODULE_LINK_NAME)
27+
28+
// We need to generate swiftmodules for these architectures, so that they can be
29+
// imported in apps that are deployable on OS versions that support them.
30+
// However, we can only generate module files for these; we can't emit binaries.
31+
// (All imported definitions will be unavailable on these older OS versions.)
32+
SWIFT_MODULE_ONLY_IPHONEOS_DEPLOYMENT_TARGET = 10.3
33+
SWIFT_MODULE_ONLY_ARCHS_iphoneos = armv7 armv7s
34+
SWIFT_MODULE_ONLY_ARCHS_iphonesimulator = i386
35+
SWIFT_MODULE_ONLY_ARCHS = $(SWIFT_MODULE_ONLY_ARCHS_$(PLATFORM_NAME))
36+
37+
// Custom settings specific for the Foundation overlay
38+
OTHER_SWIFT_FLAGS = $(inherited) -Xllvm -sil-inline-generics -Xllvm -sil-partial-specialization
39+
ALWAYS_SEARCH_USER_PATHS = NO
40+
CLANG_ENABLE_OBJC_ARC = NO
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// Configuration settings file format documentation can be found at:
14+
// https://help.apple.com/xcode/#/dev745c5c974
15+
16+
SWIFT_VERSION = 5.0
17+
18+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
19+
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks @loader_path/../Frameworks
20+
21+
PRODUCT_NAME = $(TARGET_NAME)
22+
INFOPLIST_FILE = $(PROJECT_DIR)/$(PRODUCT_NAME)/Info.plist
23+
24+
// Can't emit a swift module interface with bridging headers
25+
SWIFT_EMIT_MODULE_INTERFACE = NO
26+
27+
CLANG_LINK_OBJC_RUNTIME = YES
28+
SWIFT_LINK_OBJC_RUNTIME = YES
29+
CLANG_ENABLE_OBJC_ARC = YES
30+
31+
ALWAYS_SEARCH_USER_PATHS = NO
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import XCTest
14+
import CoreFoundation
15+
16+
class CoreFoundationTests: XCTestCase {
17+
// There are no tests dedicated to the CoreFoundation overlay yet.
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "../Config/overlay-tests-shared.xcconfig"
14+
15+
PRODUCT_BUNDLE_IDENTIFIER = org.swift.CoreFoundationTests
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
</dict>
22+
</plist>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
@_exported import CoreFoundation
14+
15+
public protocol _CFObject: class, Hashable {}
16+
extension _CFObject {
17+
public var hashValue: Int {
18+
return Int(bitPattern: CFHash(self))
19+
}
20+
public func hash(into hasher: inout Hasher) {
21+
hasher.combine(self.hashValue)
22+
}
23+
public static func ==(left: Self, right: Self) -> Bool {
24+
return CFEqual(left, right)
25+
}
26+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "../Config/overlay-shared.xcconfig"
14+
15+
PRODUCT_NAME = CoreFoundation
16+
OTHER_LDFLAGS = $(inherited) -framework CoreFoundation
17+
18+
// Use 0.0.0 as the version number for development builds.
19+
CURRENT_PROJECT_VERSION = 0.0.0
20+
DYLIB_CURRENT_VERSION = $(CURRENT_PROJECT_VERSION)
21+
MODULE_VERSION = $(CURRENT_PROJECT_VERSION)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===--- magic-symbols-for-install-name.c - Magic linker directive symbols ===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "magic-symbols-for-install-name.h"

0 commit comments

Comments
 (0)