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
5 changes: 1 addition & 4 deletions Sources/SwiftDriver/Jobs/Planning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,9 @@ extension Driver {
assert(backendJobs.count <= 1)
addCompileJobGroup(CompileJobGroup(compileJob: compile, backendJob: backendJobs.first))
} else {
// TODO: if !canSkipIfOnlyModule {
// Some other tools still expect the partial jobs. Bring this check
// back once they are updated. rdar://84979778

// We can skip the compile jobs if all we want is a module when it's
// built separately.
if parsedOptions.hasArgument(.driverExplicitModuleBuild), canSkipIfOnlyModule { return }
let compile = try compileJob(primaryInputs: [primaryInput],
outputType: compilerOutputType,
addJobOutputs: addJobOutputs,
Expand Down
38 changes: 38 additions & 0 deletions Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,44 @@ final class ExplicitModuleBuildTests: XCTestCase {
}
}

func testEmitModuleSeparatelyJobs() throws {
try withTemporaryDirectory { path in
try localFileSystem.changeCurrentWorkingDirectory(to: path)
let moduleCachePath = path.appending(component: "ModuleCache")
try localFileSystem.createDirectory(moduleCachePath)
let fileA = path.appending(component: "fileA.swift")
try localFileSystem.writeFileContents(fileA, bytes:
"""
public struct A {}
"""
)
let fileB = path.appending(component: "fileB.swift")
try localFileSystem.writeFileContents(fileB, bytes:
"""
public struct B {}
"""
)

let outputModule = path.appending(component: "Test.swiftmodule")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swiftc",
"-explicit-module-build", "-v", "-module-name", "Test",
"-module-cache-path", moduleCachePath.nativePathString(escaped: true),
"-working-directory", path.nativePathString(escaped: true),
"-emit-module", outputModule.nativePathString(escaped: true),
"-experimental-emit-module-separately",
fileA.nativePathString(escaped: true), fileB.nativePathString(escaped: true)] + sdkArgumentsForTesting,
env: ProcessEnv.vars)
let jobs = try driver.planBuild()
let compileJobs = jobs.filter({ $0.kind == .compile })
XCTAssertEqual(compileJobs.count, 0)
let emitModuleJob = jobs.filter({ $0.kind == .emitModule })
XCTAssertEqual(emitModuleJob.count, 1)
try driver.run(jobs: jobs)
XCTAssertFalse(driver.diagnosticEngine.hasErrors)
}
}

// We only care about prebuilt modules in macOS.
#if os(macOS)
func testPrebuiltModuleGenerationJobs() throws {
Expand Down