Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SWBApplePlatform/Specs/MetalCompiler.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
Name = "METAL_INDEX_STORE_ONLY_PROJECT_FILES";
Type = Boolean;
DefaultValue = "$(INDEX_STORE_ONLY_PROJECT_FILES)";
Condition = "$(MTL_ENABLE_INDEX_STORE)";
Condition = "$(MTL_ENABLE_INDEX_STORE) && ( $(COMPILER_INDEX_STORE_ENABLE) == YES || ( $(COMPILER_INDEX_STORE_ENABLE) == Default && $(MTL_ENABLE_DEBUG_INFO) != NO ) )";
CommandLineArgs = {
YES = (
// See corresponding definition in Clang.xcspec
Expand Down
6 changes: 3 additions & 3 deletions Sources/SWBUniversalPlatform/Specs/Clang.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -3189,7 +3189,7 @@
Name = "CLANG_INDEX_STORE_ONLY_PROJECT_FILES";
Type = Boolean;
DefaultValue = "$(INDEX_STORE_ONLY_PROJECT_FILES)";
Condition = "$(CLANG_INDEX_STORE_ENABLE)";
Condition = "$(CLANG_INDEX_STORE_ENABLE) && ( $(COMPILER_INDEX_STORE_ENABLE) || ( $(COMPILER_INDEX_STORE_ENABLE) == Default && $(GCC_OPTIMIZATION_LEVEL) == 0 ) )";
CommandLineArgs = {
YES = (
"-index-ignore-system-symbols",
Expand All @@ -3203,7 +3203,7 @@
Name = "CLANG_INDEX_STORE_COMPRESS";
Type = Boolean;
DefaultValue = "$(INDEX_STORE_COMPRESS)";
Condition = "$(CLANG_INDEX_STORE_ENABLE)";
Condition = "$(CLANG_INDEX_STORE_ENABLE) && ( $(COMPILER_INDEX_STORE_ENABLE) || ( $(COMPILER_INDEX_STORE_ENABLE) == Default && $(GCC_OPTIMIZATION_LEVEL) == 0 ) )";
CommandLineArgs = {
YES = (
"-index-store-compress",
Expand All @@ -3215,7 +3215,7 @@
Name = "CLANG_INDEX_STORE_IGNORE_MACROS";
Type = Boolean;
DefaultValue = NO;
Condition = "$(CLANG_INDEX_STORE_ENABLE)";
Condition = "$(CLANG_INDEX_STORE_ENABLE) && ( $(COMPILER_INDEX_STORE_ENABLE) || ( $(COMPILER_INDEX_STORE_ENABLE) == Default && $(GCC_OPTIMIZATION_LEVEL) == 0 ) )";
DisplayName = "Do not index C macros";
Description = "Do not emit entries for C macros into the Index Store.";
CommandLineArgs = {
Expand Down
4 changes: 2 additions & 2 deletions Sources/SWBUniversalPlatform/Specs/Swift.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@
Name = "SWIFT_INDEX_STORE_ONLY_PROJECT_FILES";
Type = Boolean;
DefaultValue = "$(INDEX_STORE_ONLY_PROJECT_FILES)";
Condition = "$(SWIFT_INDEX_STORE_ENABLE)";
Condition = "$(SWIFT_INDEX_STORE_ENABLE) && ( $(COMPILER_INDEX_STORE_ENABLE) || ( $(COMPILER_INDEX_STORE_ENABLE) == Default && $(SWIFT_OPTIMIZATION_LEVEL) == '-Onone' ) )";
CommandLineArgs = {
YES = (
// Assume that clang modules are getting indexed by a clang file within them. While this is technically not correct, since you could have a clang module that only consists of header files and is only included from Swift, such scenarios are rare.
Expand All @@ -1357,7 +1357,7 @@
Name = "SWIFT_INDEX_STORE_COMPRESS";
Type = Boolean;
DefaultValue = "$(INDEX_STORE_COMPRESS)";
Condition = "$(SWIFT_INDEX_STORE_ENABLE)";
Condition = "$(SWIFT_INDEX_STORE_ENABLE) && ( $(COMPILER_INDEX_STORE_ENABLE) || ( $(COMPILER_INDEX_STORE_ENABLE) == Default && $(SWIFT_OPTIMIZATION_LEVEL) == '-Onone' ) )";
CommandLineArgs = {
YES = (
"-Xfrontend",
Expand Down
48 changes: 48 additions & 0 deletions Tests/SWBTaskConstructionTests/ClangTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,52 @@ fileprivate struct ClangTests: CoreBasedTests {
}
}
}

@Test(.requireSDKs(.host))
func indexOptionsNotAddedIfIndexingIsDisabled() async throws {
try await withTemporaryDirectory { tmpDir in
let testProject = TestProject(
"ProjectName",
sourceRoot: tmpDir,
groupTree: TestGroup(
"SomeFiles",
children: [
TestFile("File1.c")
]),
targets: [
TestStandardTarget(
"Test",
type: .dynamicLibrary,
buildConfigurations: [
TestBuildConfiguration(
"Debug",
buildSettings: [
"COMPILER_INDEX_STORE_ENABLE": "NO",
"INDEX_DATA_STORE_DIR": tmpDir.join("index").str,
"INDEX_STORE_COMPRESS": "YES",
"INDEX_STORE_ONLY_PROJECT_FILES": "YES",
"CLANG_INDEX_STORE_IGNORE_MACROS": "YES",
"OTHER_CFLAGS": "-DCLANG_INDEX_STORE_ENABLE=$(CLANG_INDEX_STORE_ENABLE) -DCOMPILER_INDEX_STORE_ENABLE=$(COMPILER_INDEX_STORE_ENABLE)"
]
),
],
buildPhases: [
TestSourcesBuildPhase(["File1.c"]),
]
)
])

let core = try await getCore()
let tester = try TaskConstructionTester(core, testProject)
await tester.checkBuild(BuildParameters(configuration: "Debug", commandLineOverrides: ["INDEX_ENABLE_DATA_STORE": "YES"]), runDestination: .host) { results in
results.checkTask(.matchRuleType("CompileC")) { compileTask in
compileTask.checkCommandLineDoesNotContain("-index-store-path")
compileTask.checkCommandLineDoesNotContain("-index-store-compress")
compileTask.checkCommandLineDoesNotContain("-index-ignore-system-symbols")
compileTask.checkCommandLineDoesNotContain("-index-ignore-pcms")
compileTask.checkCommandLineDoesNotContain("-index-ignore-macros")
}
}
}
}
}
46 changes: 46 additions & 0 deletions Tests/SWBTaskConstructionTests/MetalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,50 @@ fileprivate struct MetalTests: CoreBasedTests {
}
}
}

@Test(.requireSDKs(.macOS), .skipInGitHubActions("Metal toolchain is not installed on GitHub runners"))
func indexOptionsNotAddedIfIndexingIsDisabled() async throws {
try await withTemporaryDirectory { tmpDir in
let testProject = TestProject(
"ProjectName",
sourceRoot: tmpDir,
groupTree: TestGroup(
"SomeFiles",
children: [
TestFile("File1.metal")
]),
targets: [
TestStandardTarget(
"Test",
type: .staticLibrary,
buildConfigurations: [
TestBuildConfiguration(
"Debug",
buildSettings: [
"COMPILER_INDEX_STORE_ENABLE": "NO",
"INDEX_DATA_STORE_DIR": tmpDir.join("index").str,
"INDEX_STORE_COMPRESS": "YES",
"INDEX_STORE_ONLY_PROJECT_FILES": "YES",
"CLANG_INDEX_STORE_IGNORE_MACROS": "YES",
]
),
],
buildPhases: [
TestSourcesBuildPhase(["File1.metal"]),
]
)
])

let core = try await getCore()
let tester = try TaskConstructionTester(core, testProject)
await tester.checkBuild(BuildParameters(configuration: "Debug", commandLineOverrides: ["INDEX_ENABLE_DATA_STORE": "YES"]), runDestination: .macOS) { results in
results.checkTask(.matchRuleType("CompileMetalFile")) { compileTask in
compileTask.checkCommandLineDoesNotContain("-index-store-path")
compileTask.checkCommandLineDoesNotContain("-index-store-compress")
compileTask.checkCommandLineDoesNotContain("-index-ignore-system-symbols")
compileTask.checkCommandLineDoesNotContain("-index-ignore-pcms")
}
}
}
}
}
47 changes: 47 additions & 0 deletions Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4572,6 +4572,53 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
}
}
}

@Test(.requireSDKs(.host))
func indexOptionsNotAddedIfIndexingIsDisabled() async throws {
try await withTemporaryDirectory { tmpDir in
let testProject = try await TestProject(
"ProjectName",
sourceRoot: tmpDir,
groupTree: TestGroup(
"SomeFiles",
children: [
TestFile("File1.swift")
]),
targets: [
TestStandardTarget(
"Test",
type: .dynamicLibrary,
buildConfigurations: [
TestBuildConfiguration(
"Debug",
buildSettings: [
"SWIFT_EXEC": swiftCompilerPath.str,
"SWIFT_VERSION": swiftVersion,
"COMPILER_INDEX_STORE_ENABLE": "NO",
"INDEX_DATA_STORE_DIR": tmpDir.join("index").str,
"INDEX_STORE_COMPRESS": "YES",
"INDEX_STORE_ONLY_PROJECT_FILES": "YES"
]
),
],
buildPhases: [
TestSourcesBuildPhase(["File1.swift"]),
]
)
])

let core = try await getCore()
let tester = try TaskConstructionTester(core, testProject)
await tester.checkBuild(BuildParameters(configuration: "Debug", commandLineOverrides: ["INDEX_ENABLE_DATA_STORE": "YES"]), runDestination: .host) { results in
results.checkTask(.matchRuleType("SwiftDriver Compilation")) { compileTask in
compileTask.checkCommandLineDoesNotContain("-index-store-path")
compileTask.checkCommandLineDoesNotContain("-index-store-compress")
compileTask.checkCommandLineDoesNotContain("-index-ignore-clang-modules")
compileTask.checkCommandLineDoesNotContain("-index-ignore-system-modules")
}
}
}
}
}

private func XCTAssertEqual(_ lhs: EnvironmentBindings, _ rhs: [String: String], file: StaticString = #filePath, line: UInt = #line) {
Expand Down