Skip to content

Commit

Permalink
Filter out non-header files from Compile Source phase (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwellE committed May 24, 2022
1 parent abc4d80 commit 6b4d177
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 20 deletions.
2 changes: 0 additions & 2 deletions examples/ios_app/test/fixtures/bwb.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
8490D2560B037FDA913FA479 /* TestingUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DFA501580379A58AE2389D0 /* TestingUtils.swift */; };
8827E174961A52D2C88CF0C9 /* ExampleObjcTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1945E01AD98FE05054F33AE5 /* ExampleObjcTests.m */; };
A29169FF12586786795BC72E /* ExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDA5C3FF5C9611B6DF55D3C /* ExampleUITests.swift */; };
A3F3925312098E3A0298FEA1 /* Answers.h in Sources */ = {isa = PBXBuildFile; fileRef = 46A804416537B31F7C6B6E0E /* Answers.h */; };
B054C3F6BAFAFA0604A3B413 /* Foo.m in Sources */ = {isa = PBXBuildFile; fileRef = DE684C8B8336D55C43040D1E /* Foo.m */; };
B9F1B2EA1F682CDC63CA17BC /* _BazelForcedCompile_.swift in Sources */ = {isa = PBXBuildFile; fileRef = E61C1B860E7015FBB3750A95 /* _BazelForcedCompile_.swift */; };
C35F652B550BB76721075171 /* _BazelForcedCompile_.swift in Sources */ = {isa = PBXBuildFile; fileRef = E61C1B860E7015FBB3750A95 /* _BazelForcedCompile_.swift */; };
Expand Down Expand Up @@ -1013,7 +1012,6 @@
buildActionMask = 2147483647;
files = (
EF069547E19BA1AA74D9E906 /* Answers.mm in Sources */,
A3F3925312098E3A0298FEA1 /* Answers.h in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 0 additions & 2 deletions examples/ios_app/test/fixtures/bwx.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
E24F005794DBF4FAC13BCABC /* ExternalFramework.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 711E9FC3B7C0052C8DDBA1C9 /* ExternalFramework.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
E42FEF40785F7445F33C1307 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3D76639B60E2E2CA3019CBCA /* Localizable.strings */; };
E622F80C56CEC483C5E577E5 /* ExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BF64499057F57FE175119DD /* ExampleTests.swift */; };
F3B0FD689CE3C0600EA95DD9 /* Answers.h in Sources */ = {isa = PBXBuildFile; fileRef = D56500D4BDA570832AE3734D /* Answers.h */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -1112,7 +1111,6 @@
buildActionMask = 2147483647;
files = (
CD4E817DEB1ED2B9E3F6F7A8 /* Answers.mm in Sources */,
F3B0FD689CE3C0600EA95DD9 /* Answers.h in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 0 additions & 4 deletions test/fixtures/cc/bwb.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
/* End PBXAggregateTarget section */

/* Begin PBXBuildFile section */
91AD5E78AE94B72CEDD275A5 /* private.inc in Sources */ = {isa = PBXBuildFile; fileRef = 3C80F439DD6B6A9F76C8BCC6 /* private.inc */; };
CD2AA10AC79D5924E155E574 /* lib.c in Sources */ = {isa = PBXBuildFile; fileRef = FB80EF95C89684721EBBDC35 /* lib.c */; };
CFDEFD32F9576B104A39894D /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 9411DCDC5C6F92122299107F /* main.c */; };
D770DE28E597BAF74254AFCB /* private.h in Sources */ = {isa = PBXBuildFile; fileRef = 8D73636373B8CDD4BE62C0A5 /* private.h */; };
D8961DA25CBC1AF0367FBA37 /* lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 26866FEDF67CD3FA66FFAB17 /* lib.c */; };
FC39DB0614B0AB5B5A2DF90E /* lib.c in Sources */ = {isa = PBXBuildFile; fileRef = FB0F020B344E60F89B31265D /* lib.c */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -385,7 +383,6 @@
buildActionMask = 2147483647;
files = (
D8961DA25CBC1AF0367FBA37 /* lib.c in Sources */,
91AD5E78AE94B72CEDD275A5 /* private.inc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -402,7 +399,6 @@
buildActionMask = 2147483647;
files = (
CD2AA10AC79D5924E155E574 /* lib.c in Sources */,
D770DE28E597BAF74254AFCB /* private.h in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 0 additions & 4 deletions test/fixtures/cc/bwx.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
27F99F3C7155CD79101A4A0F /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = BD77ACEF34FC7AFD41A09A4A /* main.c */; };
376A1C58A742EDEA9540B257 /* lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C8095547A55E1C477C2E094 /* lib.c */; };
6487CF8827955B8B86C59E14 /* lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 72DD4925E3FB6AE32B7ACADA /* lib.c */; };
67FC89385DBE8738095CFD9E /* private.h in Sources */ = {isa = PBXBuildFile; fileRef = 054732C7DCF543EED5337D81 /* private.h */; };
9BA8E705EB7AE75262F669CA /* private.inc in Sources */ = {isa = PBXBuildFile; fileRef = 473752B2F4FD8D5B513230B3 /* private.inc */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -384,7 +382,6 @@
buildActionMask = 2147483647;
files = (
6487CF8827955B8B86C59E14 /* lib.c in Sources */,
67FC89385DBE8738095CFD9E /* private.h in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -393,7 +390,6 @@
buildActionMask = 2147483647;
files = (
051B8A7BC0F5DBB11025923F /* lib.c in Sources */,
9BA8E705EB7AE75262F669CA /* private.inc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/command_line/bwb.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
25605E8E5912BBF468A910D4 /* private_lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 4F18976D8538975B332CAC08 /* private_lib.c */; };
2565B0E6AC6DB939D6A8209E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C06A565663AED0899589F574 /* main.m */; };
2848C0B211EE176A3865CF72 /* SwiftGreetingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CE87466AFFDC6606F8518F8 /* SwiftGreetingsTests.swift */; };
5FF3391F448E2AD999E2D37A /* private.h in Sources */ = {isa = PBXBuildFile; fileRef = 061F2388C98C7C8A40A50744 /* private.h */; };
710D43D76CB511A8B84AADBE /* _BazelForcedCompile_.swift in Sources */ = {isa = PBXBuildFile; fileRef = E61C1B860E7015FBB3750A95 /* _BazelForcedCompile_.swift */; };
D339677D7D46139DE6887FAB /* lib.swift in Sources */ = {isa = PBXBuildFile; fileRef = A59B10F9022E9CC335541BDA /* lib.swift */; };
E88BD8A7C61237C9DA4A3253 /* lib.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A44BF8F252A4102EA584307 /* lib.m */; };
Expand Down Expand Up @@ -698,7 +697,6 @@
buildActionMask = 2147483647;
files = (
E88BD8A7C61237C9DA4A3253 /* lib.m in Sources */,
5FF3391F448E2AD999E2D37A /* private.h in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/command_line/bwx.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
7BC8A776D2D1C760F9C38A4A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C0B86F4542BE9E526167481 /* main.m */; };
8061E3DE63D96635F98C9B3A /* lib.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F5E4ABAACB85A529597A95E /* lib.swift */; };
9D33767266FC4D21B0BF2358 /* lib.m in Sources */ = {isa = PBXBuildFile; fileRef = B45E624D6CB9A25AD05AA3EB /* lib.m */; };
BB13B22EC1C20144E655F4AB /* private.h in Sources */ = {isa = PBXBuildFile; fileRef = 7703BC6D5949A71AA4B20322 /* private.h */; };
DCEAC0456D3DB4A3DE4A12A2 /* SwiftGreetingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D945EBC9B2F4A830BCCF4F4 /* SwiftGreetingsTests.swift */; };
EE8870A9BDAE53F2ABD71A26 /* private_lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 782EFB0F35839BA9778CEB6A /* private_lib.c */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -598,7 +597,6 @@
buildActionMask = 2147483647;
files = (
9D33767266FC4D21B0BF2358 /* lib.m in Sources */,
BB13B22EC1C20144E655F4AB /* private.h in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
10 changes: 8 additions & 2 deletions tools/generator/src/Generator+AddTargets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ File "\(headerFile.filePath)" not found in `files`
let forcedBazelCompileFiles = outputs
.forcedBazelCompileFiles(buildMode: buildMode)
let sources = forcedBazelCompileFiles.map(SourceFile.init) +
inputs.srcs.map(SourceFile.init) +
inputs.nonArcSrcs.map { filePath in
inputs.srcs.excludingHeaders.map(SourceFile.init) +
inputs.nonArcSrcs.excludingHeaders.map { filePath in
return SourceFile(
filePath,
compilerFlags: ["-fno-objc-arc"]
Expand Down Expand Up @@ -402,6 +402,12 @@ Framework with file path "\(filePath)" had nil `PBXFileElement` in `files`
}
}

private extension Sequence where Element == FilePath {
var excludingHeaders: [Element] {
self.filter { !$0.path.isHeader }
}
}

private struct HeaderFile: Hashable {
enum Visibility {
case `public`
Expand Down
3 changes: 1 addition & 2 deletions tools/generator/test/Fixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,6 @@ done < "$SCRIPT_INPUT_FILE_LIST_0"
),
PBXSourcesBuildPhase(
files: buildFiles([
PBXBuildFile(file: elements["z.h"]!),
PBXBuildFile(file: elements["z.mm"]!),
])
),
Expand Down Expand Up @@ -1397,7 +1396,7 @@ done < "$SCRIPT_INPUT_FILE_LIST_0"

var pbxTargets = Dictionary(
uniqueKeysWithValues: pbxNativeTargets
.map { targetID, pbxTarget -> (TargetID, PBXTarget) in
.map { targetID, pbxTarget -> (TargetID, PBXTarget) in
return (targetID, pbxTarget)
}
)
Expand Down

0 comments on commit 6b4d177

Please sign in to comment.