forked from swiftlang/swift-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJExtractDefaultBuildConfiguration.swift
More file actions
103 lines (83 loc) · 2.58 KB
/
JExtractDefaultBuildConfiguration.swift
File metadata and controls
103 lines (83 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2026 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
import SwiftIfConfig
import SwiftSyntax
/// A default, fixed build configuration during static analysis for interface extraction.
struct JExtractDefaultBuildConfiguration: BuildConfiguration {
static let shared = JExtractDefaultBuildConfiguration()
private var base: StaticBuildConfiguration
init() {
guard let url = Bundle.module.url(forResource: "static-build-config", withExtension: "json") else {
fatalError("static-build-config.json is not found in module bundle")
}
do {
let data = try Data(contentsOf: url)
let decoder = JSONDecoder()
base = try decoder.decode(StaticBuildConfiguration.self, from: data)
} catch {
fatalError("\(error)")
}
}
func isCustomConditionSet(name: String) throws -> Bool {
base.isCustomConditionSet(name: name)
}
func hasFeature(name: String) throws -> Bool {
base.hasFeature(name: name)
}
func hasAttribute(name: String) throws -> Bool {
base.hasAttribute(name: name)
}
func canImport(importPath: [(TokenSyntax, String)], version: CanImportVersion) throws -> Bool {
try base.canImport(importPath: importPath, version: version)
}
func isActiveTargetOS(name: String) throws -> Bool {
true
}
func isActiveTargetArchitecture(name: String) throws -> Bool {
true
}
func isActiveTargetEnvironment(name: String) throws -> Bool {
true
}
func isActiveTargetRuntime(name: String) throws -> Bool {
true
}
func isActiveTargetPointerAuthentication(name: String) throws -> Bool {
true
}
func isActiveTargetObjectFormat(name: String) throws -> Bool {
true
}
var targetPointerBitWidth: Int {
base.targetPointerBitWidth
}
var targetAtomicBitWidths: [Int] {
base.targetAtomicBitWidths
}
var endianness: Endianness {
base.endianness
}
var languageVersion: VersionTuple {
base.languageVersion
}
var compilerVersion: VersionTuple {
base.compilerVersion
}
}
extension BuildConfiguration where Self == JExtractDefaultBuildConfiguration {
static var jextractDefault: JExtractDefaultBuildConfiguration {
.shared
}
}