|
| 1 | +// swift-tools-version: 5.10 |
| 2 | +// |
| 3 | +//===----------------------------------------------------------------------===// |
| 4 | +// |
| 5 | +// Copyright (c) 2023 Svyatoslav Popov (info@keyvar.com). |
| 6 | +// |
| 7 | +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 8 | +// the License. You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 13 | +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 14 | +// specific language governing permissions and limitations under the License. |
| 15 | +// |
| 16 | +// SPDX-License-Identifier: Apache-2.0 |
| 17 | +// |
| 18 | +//===----------------------------------------------------------------------===// |
| 19 | + |
| 20 | +import PackageDescription |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +let swiftSettings: [SwiftSetting]? = nil |
| 25 | + |
| 26 | +let isSimdAvailable: Bool |
| 27 | +#if canImport(simd) |
| 28 | +isSimdAvailable = true |
| 29 | +#else // !canImport(simd) |
| 30 | +isSimdAvailable = false |
| 31 | +#endif // !canImport(simd) |
| 32 | + |
| 33 | +// Module is named "simd" to use `import simd` when the SIMD framework is not available. |
| 34 | +// Otherwise it's named "kvSIMD" to prevent collision. |
| 35 | +let moduleName = isSimdAvailable ? "kvSIMD" : "simd" |
| 36 | +let placeholderModuleName = "kvSIMD_Placeholder" |
| 37 | + |
| 38 | + |
| 39 | +let package = Package( |
| 40 | + name: "kvSIMD.swift", |
| 41 | + |
| 42 | + products: [ .library(name: "kvSIMD", targets: [ !isSimdAvailable ? moduleName : placeholderModuleName ]), |
| 43 | + .library(name: "kvSIMD.forced", targets: [ moduleName ])], |
| 44 | + |
| 45 | + targets: Array([ |
| 46 | + [ .target(name: moduleName, path: "Sources/kvSIMD", swiftSettings: swiftSettings), |
| 47 | + .target(name: placeholderModuleName), ], |
| 48 | + |
| 49 | + isSimdAvailable ? [ .testTarget(name: "kvSIMDTests", dependencies: [ .target(name: moduleName) ], swiftSettings: swiftSettings) ] : [ ], |
| 50 | + ].joined()) |
| 51 | +) |
0 commit comments