File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
Cabal-syntax/src/Distribution
Cabal/src/Distribution/Simple Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,7 @@ instance Binary CompilerInfo
229229instance Structured CompilerInfo
230230instance NFData CompilerInfo where rnf = genericRnf
231231
232+ -- | AbiTag logic
232233data AbiTag
233234 = NoAbiTag
234235 | AbiTag String
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ module Distribution.Types.UnitId
1616 , newSimpleUnitId
1717 , mkLegacyUnitId
1818 , getHSLibraryName
19+ , getAbiTag
1920 ) where
2021
2122import Distribution.Compat.Prelude
@@ -184,3 +185,17 @@ instance Parsec DefUnitId where
184185-- is to ensure that the 'DefUnitId' invariant holds.
185186unsafeMkDefUnitId :: UnitId -> DefUnitId
186187unsafeMkDefUnitId = DefUnitId
188+
189+ -- | The ABI tag is the part of the unit id that comes after the
190+ -- last hyphen. It is used to distinguish between different
191+ -- versions of the same package that are ABI compatible.
192+ --
193+ -- FIXME: ideally this would be part of the proper structure of the
194+ -- datatype, instead of some heuristic of the string.
195+ getAbiTag :: HasCallStack => UnitId -> AbiTag
196+ getAbiTag (UnitId _c s _) = case takeWhile (/= ' -' ) . reverse . fromShortText $ s of
197+ [] -> NoAbiTag
198+ xs -> AbiTag . reverse $ xs
199+ getAbiTag (PartialUnitId s) = case takeWhile (/= ' -' ) . reverse . fromShortText $ s of
200+ [] -> NoAbiTag
201+ xs -> AbiTag . reverse $ xs
Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ configure verbosity hcPath hcPkgPath conf0 = do
249249 compilerId = CompilerId GHC ghcVersion
250250
251251 compilerAbiTag :: AbiTag
252- compilerAbiTag = maybe NoAbiTag AbiTag ( Map. lookup " Project Unit Id" ghcInfoMap >>= stripPrefix (prettyShow compilerId <> " - " ) )
252+ compilerAbiTag = fromMaybe NoAbiTag (getAbiTag . fromString <$> Map. lookup " Project Unit Id" ghcInfoMap)
253253
254254 let comp =
255255 Compiler
You can’t perform that action at this time.
0 commit comments