From acb35435e31ac968fa195d3a21ed19b149ec9bce Mon Sep 17 00:00:00 2001 From: Vu Le Hoang Date: Tue, 8 Mar 2022 14:16:01 +0700 Subject: [PATCH] Cheating to add Swift ObjC generated header to hmap --- .../cxx/HeaderSymlinkTreeWithHeaderMap.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/com/facebook/buck/cxx/HeaderSymlinkTreeWithHeaderMap.java b/src/com/facebook/buck/cxx/HeaderSymlinkTreeWithHeaderMap.java index 0404394e970..c60e28cbde5 100644 --- a/src/com/facebook/buck/cxx/HeaderSymlinkTreeWithHeaderMap.java +++ b/src/com/facebook/buck/cxx/HeaderSymlinkTreeWithHeaderMap.java @@ -32,6 +32,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Optional; public final class HeaderSymlinkTreeWithHeaderMap extends HeaderSymlinkTree { @@ -81,6 +82,27 @@ public ImmutableList getBuildSteps( // aligning in order to get this to work. May we find peace in another life. headerMapEntries.put(key, buckOut.relativize(getRoot().resolve(key))); } + + // A cheat to add Swift ObjC generated header to hmap + // + // The header (*-Swift.h) is generated when compiling swift sources. + // It's header file location is in `#iphoneos-arm64,swift-compile` + // or `#iphoneos-armv7,swift-compile` is a doubting location. + // Of course, this header is not found from the hmap is crawled + // from a `#header-mode-symlink-tree-with-header-map,headers` folder + // + // The cheat tries to add the generated header (*-Swift.h) to the hmap + // don't care it existed or not + String targetName = getBuildTarget().getShortName(); + String swiftHeader = targetName + "-Swift.h"; + String dummyFlavors = "iphoneos-arm64,swift-compile"; + Path root = getRoot(); + Path compilePath = root.resolve("..") + .resolve(targetName + "#" + dummyFlavors) + .resolve(swiftHeader); + Path swiftHeaderPath = buckOut.relativize(compilePath); + headerMapEntries.put(Paths.get(targetName, swiftHeader), swiftHeaderPath); + ImmutableList.Builder builder = ImmutableList.builder() .addAll(super.getBuildSteps(context, buildableContext))