Skip to content

Commit 762ecad

Browse files
committed
Address the conditional case
visibility can be a part of CondTree, e. g., ```haskell library foo-internal if flag(foo) visibility: public else visibility: private ``` See #1437 (comment)
1 parent 924296c commit 762ecad

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Distribution/Server/Packages/Render.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,13 @@ allCondLibs desc = filter (isPublicCondLib . snd) $
199199
++ (first LSubLibName <$> condSubLibraries desc)
200200
where
201201
-- Check if a conditional library tree contains a public library
202-
-- We check the root node since visibility is a property of the library itself
203-
isPublicCondLib condTree =
204-
let lib = condTreeData condTree
205-
in libName lib == LMainLibName || libVisibility lib == LibraryVisibilityPublic
202+
-- We need to check all branches since visibility can be conditional
203+
isPublicCondLib :: CondTree ConfVar [Dependency] Library -> Bool
204+
isPublicCondLib (CondNode lib _ branches) =
205+
let rootIsPublic = libName lib == LMainLibName || libVisibility lib == LibraryVisibilityPublic
206+
branchIsPublic (CondBranch _ thenTree elseTree) =
207+
isPublicCondLib thenTree || maybe False isPublicCondLib elseTree
208+
in rootIsPublic || any branchIsPublic branches
206209

207210
type DependencyTree = CondTree ConfVar [Dependency] IsBuildable
208211

0 commit comments

Comments
 (0)