Skip to content

Commit ba1d5cd

Browse files
committed
Add missing mod-def-file field
1 parent 2078399 commit ba1d5cd

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ This is done to allow compatibility with a wider range of `Cabal` versions.
336336
| `type` | . | | |
337337
| `lib-version-info` | . | | |
338338
| `options` | . | | |
339+
| `mod-def-file` | . | | |
339340
| `other-modules` | · | All modules in `source-dirs` less `main` less any modules mentioned in `when` | |
340341
| `generated-other-modules` | | | Added to `other-modules` and `autogen-modules`. Since `0.23.0`.
341342

src/Hpack/Config.hs

+6-2
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,21 @@ data ForeignLibrarySection = ForeignLibrarySection {
245245
foreignLibrarySectionType :: Last String
246246
, foreignLibrarySectionLibVersionInfo :: Last String
247247
, foreignLibrarySectionOptions :: Maybe (List String)
248+
, foreignLibrarySectionModDefFile :: Last String
248249
, foreignLibrarySectionOtherModules :: Maybe (List Module)
249250
, foreignLibrarySectionGeneratedOtherModules :: Maybe (List Module)
250251
} deriving (Eq, Show, Generic, FromValue)
251252

252253
instance Monoid ForeignLibrarySection where
253-
mempty = ForeignLibrarySection mempty mempty Nothing Nothing Nothing
254+
mempty = ForeignLibrarySection mempty mempty Nothing mempty Nothing Nothing
254255
mappend = (<>)
255256

256257
instance Semigroup ForeignLibrarySection where
257258
a <> b = ForeignLibrarySection {
258259
foreignLibrarySectionType = foreignLibrarySectionType a <> foreignLibrarySectionType b
259260
, foreignLibrarySectionLibVersionInfo = foreignLibrarySectionLibVersionInfo a <> foreignLibrarySectionLibVersionInfo b
260261
, foreignLibrarySectionOptions = foreignLibrarySectionOptions a <> foreignLibrarySectionOptions b
262+
, foreignLibrarySectionModDefFile = foreignLibrarySectionModDefFile a <> foreignLibrarySectionModDefFile b
261263
, foreignLibrarySectionOtherModules = foreignLibrarySectionOtherModules a <> foreignLibrarySectionOtherModules b
262264
, foreignLibrarySectionGeneratedOtherModules = foreignLibrarySectionGeneratedOtherModules a <> foreignLibrarySectionGeneratedOtherModules b
263265
}
@@ -1115,6 +1117,7 @@ data ForeignLibrary = ForeignLibrary {
11151117
foreignLibraryType :: Maybe String
11161118
, foreignLibraryLibVersionInfo :: Maybe String
11171119
, foreignLibraryOptions :: Maybe [String]
1120+
, foreignLibraryModDefFile :: Maybe String
11181121
, foreignLibraryOtherModules :: [Module]
11191122
, foreignLibraryGeneratedModules :: [Module]
11201123
} deriving (Eq, Show)
@@ -1600,7 +1603,7 @@ fromLibrarySectionPlain LibrarySection{..} = Library {
16001603
}
16011604

16021605
getMentionedForeignLibraryModules :: ForeignLibrarySection -> [Module]
1603-
getMentionedForeignLibraryModules (ForeignLibrarySection _ _ _ otherModules generatedModules)=
1606+
getMentionedForeignLibraryModules (ForeignLibrarySection _ _ _ _ otherModules generatedModules)=
16041607
fromMaybeList (otherModules <> generatedModules)
16051608

16061609
toForeignLibrary :: (MonadIO m, State m) => FilePath -> String -> Section ForeignLibrarySection -> m (Section ForeignLibrary)
@@ -1613,6 +1616,7 @@ toForeignLibrary dir packageName_ =
16131616
(getLast foreignLibrarySectionType)
16141617
(getLast foreignLibrarySectionLibVersionInfo)
16151618
(fromList <$> foreignLibrarySectionOptions)
1619+
(getLast foreignLibrarySectionModDefFile)
16161620
(otherModules ++ generatedModules)
16171621
generatedModules
16181622
)

src/Hpack/Render.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,12 @@ renderForeignLibrarySection extraFields = renderSection renderForeignLibraryFiel
228228

229229
renderForeignLibraryFields :: ForeignLibrary -> [Element]
230230
renderForeignLibraryFields ForeignLibrary{..} =
231-
typeField ++ libVersionInfo ++ options ++ [otherModules, generatedModules]
231+
typeField ++ libVersionInfo ++ options ++ modDefFile ++ [otherModules, generatedModules]
232232
where
233233
typeField = maybe [] (return . Field "type" . Literal) foreignLibraryType
234234
libVersionInfo = maybe [] (return . Field "lib-version-info" . Literal) foreignLibraryLibVersionInfo
235235
options = maybe [] (\opts -> [renderForeignLibOptions opts]) foreignLibraryOptions
236+
modDefFile = maybe [] (return . Field "mod-def-file" . Literal) foreignLibraryModDefFile
236237
otherModules = renderOtherModules foreignLibraryOtherModules
237238
generatedModules = renderGeneratedModules foreignLibraryGeneratedModules
238239

@@ -351,7 +352,6 @@ renderDirectories name = Field name . LineSeparatedList . replaceDots
351352
"." -> "./"
352353
_ -> xs
353354

354-
355355
renderForeignLibOptions :: [String] -> Element
356356
renderForeignLibOptions = Field "options" . LineSeparatedList
357357

0 commit comments

Comments
 (0)