Skip to content

Commit

Permalink
Ignore test bundles when generating bitcode
Browse files Browse the repository at this point in the history
  • Loading branch information
bmxav committed Sep 26, 2024
1 parent 2b9c352 commit 1d61bcd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/GenIR/CompilerCommandRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct CompilerCommandRunner {

var totalModulesRun = 0

for target in targets.filter({ $0.isBuildable }) {
for target in targets {
guard let targetCommands = commands[target.name] else {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/GenIR/GenIR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ let programName = CommandLine.arguments.first!

// Find and parse the PIF cache
let pifCache = try PIFCache(buildCache: log.buildCachePath)
let targets = pifCache.targets.map { Target(from: $0) }
let targets = pifCache.targets.map { Target(from: $0) }.filter { !$0.isTest }

let builder = DependencyGraphBuilder<PIFDependencyProvider, Target>(
provider: .init(targets: targets, cache: pifCache),
Expand Down
11 changes: 11 additions & 0 deletions Sources/GenIR/Target.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class Target {
/// for the object file, since this is used by the other targets.
let isBuildable: Bool

/// Returns true if this target is a test bundle. These will be ignored when packaging bitcode
/// in order to reduce archive size.
let isTest: Bool

/// Returns true if this target produces a package product that will be included in the archive.
/// For simplicity we say this can be anything that is not a `PACKAGE-TARGET`, which will just be
/// an object file. The `dynamicTargetVariantGuid` of a `PACKAGE-TARGET` is technically a framework,
Expand All @@ -48,6 +52,13 @@ class Target {
// Fallback to the target's name if we are unable to determine a proper product name.
productName = baseTarget.name
}

if let target = baseTarget as? PIF.Target {
isTest = target.productType == .unitTest || target.productType == .uiTesting
} else {
isTest = false
}

isBuildable = guid == "PACKAGE-TARGET:\(name)" || !guid.hasPrefix("PACKAGE-")
isPackageProduct = !guid.hasPrefix("PACKAGE-TARGET:")
isSwiftPackage = guid.hasPrefix("PACKAGE-")
Expand Down

0 comments on commit 1d61bcd

Please sign in to comment.