packages feed

hpack 0.34.5 → 0.34.6

raw patch · 4 files changed

+115/−6 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,6 @@+## Changes in 0.34.6+  - Add `Paths_` module to `autogen-modules` when `cabal-version >= 2`+ ## Changes in 0.34.5   - Compatibility with `aeson-2.*` @@ -11,7 +14,7 @@   - Reject empty `then` / `else` sections (see #362)   - Omit conditionals that are always `false` from generated `.cabal` file     (see #404)-  - Infer correct `cabal-version` when `Path_` is used with `RebindableSyntax`+  - Infer correct `cabal-version` when `Paths_` is used with `RebindableSyntax`     and `OverloadedStrings` or `OverloadedLists` (see #400)   - Do not use indentation from any existing `.cabal` file if it is invalid     (e.g. `0`) (fixes #252)
hpack.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.34.5. -- -- see: https://github.com/sol/hpack  name:           hpack-version:        0.34.5+version:        0.34.6 synopsis:       A modern format for Haskell packages description:    See README at <https://github.com/sol/hpack#readme> category:       Development
src/Hpack/Config.hs view
@@ -676,15 +676,49 @@   VerbatimBool b -> show b   VerbatimNull -> "" -determineCabalVersion :: Maybe (License SPDX.License) -> Package -> (Package, String)+addPathsModuleToGeneratedModules  :: Package -> Version -> Package+addPathsModuleToGeneratedModules pkg cabalVersion+  | cabalVersion < makeVersion [2] = pkg+  | otherwise = pkg {+      packageLibrary = fmap mapLibrary <$> packageLibrary pkg+    , packageInternalLibraries = fmap mapLibrary <$> packageInternalLibraries pkg+    , packageExecutables = fmap mapExecutable <$> packageExecutables pkg+    , packageTests = fmap mapExecutable <$> packageTests pkg+    , packageBenchmarks = fmap mapExecutable <$> packageBenchmarks pkg+    }+  where+    pathsModule = pathsModuleFromPackageName (packageName pkg)++    mapLibrary :: Library -> Library+    mapLibrary lib+      | pathsModule `elem` getLibraryModules lib = lib {+          libraryGeneratedModules = if pathsModule `elem` generatedModules then generatedModules else pathsModule : generatedModules+        }+      | otherwise = lib+      where+        generatedModules = libraryGeneratedModules lib++    mapExecutable :: Executable -> Executable+    mapExecutable executable+      | pathsModule `elem` executableOtherModules executable = executable {+          executableGeneratedModules = if pathsModule `elem` generatedModules then generatedModules else pathsModule : generatedModules+        }+      | otherwise = executable+      where+        generatedModules = executableGeneratedModules executable++determineCabalVersion :: Maybe (License SPDX.License) -> Package -> (Package, String, Maybe Version) determineCabalVersion inferredLicense pkg@Package{..} = (     pkg {         packageVerbatim = deleteVerbatimField "cabal-version" packageVerbatim       , packageLicense = formatLicense <$> license       }-  , "cabal-version: " ++ fromMaybe inferredCabalVersion verbatimCabalVersion ++ "\n\n"+  , "cabal-version: " ++ effectiveCabalVersion ++ "\n\n"+  , parseVersion effectiveCabalVersion   )   where+    effectiveCabalVersion = fromMaybe inferredCabalVersion verbatimCabalVersion+     license = fmap prettyShow <$> (parsedLicense <|> inferredLicense)      parsedLicense = parseLicense <$> packageLicense@@ -1184,7 +1218,9 @@    tell nameWarnings   tell (formatMissingSourceDirs missingSourceDirs)-  return (determineCabalVersion inferredLicense pkg)++  let (pkg_, renderedCabalVersion, cabalVersion) = determineCabalVersion inferredLicense pkg+  return (maybe pkg_ (addPathsModuleToGeneratedModules pkg_) cabalVersion, renderedCabalVersion)   where     nameWarnings :: [String]     packageName_ :: String
test/EndToEndSpec.hs view
@@ -79,6 +79,47 @@             Paths_foo         |] +      context "when cabal-version is >= 2" $ do+        it "adds Paths_ to autogen-modules" $ do+          [i|+          verbatim:+            cabal-version: 2.0+          library: {}+          |] `shouldRenderTo` (library [i|+          other-modules:+              Paths_foo+          autogen-modules:+              Paths_foo+          |]) { packageCabalVersion = "2.0" }++        context "when Paths_ module is listed explicitly under generated-other-modules" $ do+          it "adds Paths_ to autogen-modules only once" $ do+            [i|+            verbatim:+              cabal-version: 2.0+            library:+              generated-other-modules: Paths_foo+            |] `shouldRenderTo` (library [i|+            other-modules:+                Paths_foo+            autogen-modules:+                Paths_foo+            |]) { packageCabalVersion = "2.0" }++        context "when Paths_ module is listed explicitly under generated-exposed-modules" $ do+          it "adds Paths_ to autogen-modules only once" $ do+            [i|+            verbatim:+              cabal-version: 2.0+            library:+              generated-exposed-modules: Paths_foo+            |] `shouldRenderTo` (library [i|+            exposed-modules:+                Paths_foo+            autogen-modules:+                Paths_foo+            |]) { packageCabalVersion = "2.0" }+       context "when Paths_ is mentioned in a conditional that is always false" $ do         it "does not add Paths_" $ do           [i|@@ -100,6 +141,8 @@               OverloadedStrings           other-modules:               Paths_foo+          autogen-modules:+              Paths_foo           |]) {packageCabalVersion = "2.2"}          context "when Paths_ is mentioned in a conditional that is always false" $ do@@ -455,6 +498,8 @@           library             other-modules:                 Paths_foo+            autogen-modules:+                Paths_foo             cxx-options: -Wall             default-language: Haskell2010           |]) {packageCabalVersion = "2.2"}@@ -469,6 +514,8 @@           library             other-modules:                 Paths_foo+            autogen-modules:+                Paths_foo             cxx-options: -Wall             default-language: Haskell2010           |]) {packageCabalVersion = "2.2"}@@ -671,6 +718,8 @@             system-build-tools:               g++ >= 5.4.0           |] `shouldRenderTo` (executable_ "foo" [i|+          autogen-modules:+              Paths_foo           build-tools:               g++ >=5.4.0           |]) {packageCabalVersion = "2.0"}@@ -690,6 +739,8 @@         executable:           dependencies: foo:bar         |] `shouldRenderTo` (executable_ "foo" [i|+        autogen-modules:+            Paths_foo         build-depends:             foo:bar         |]) {packageCabalVersion = "3.0"}@@ -800,6 +851,8 @@         executable:           cxx-options: -Wall         |] `shouldRenderTo` (executable_ "foo" [i|+        autogen-modules:+            Paths_foo         cxx-options: -Wall         |]) {packageCabalVersion = "2.2"} @@ -815,6 +868,8 @@                   condition: True                   cxx-options: -Wall           |] `shouldRenderTo` (executable_ "foo" [i|+          autogen-modules:+              Paths_foo           if true             if true               if true@@ -829,6 +884,8 @@             - foo.cc             - cxxbits/*.cc         |] `shouldRenderTo` (executable_ "foo" [i|+        autogen-modules:+            Paths_foo         cxx-sources:             foo.cc             cxxbits/bar.cc@@ -979,6 +1036,8 @@         library:           signatures: Foo         |] `shouldRenderTo` (library_ [i|+          autogen-modules:+              Paths_foo           signatures:               Foo         |]) {packageCabalVersion = "2.0"}@@ -1008,6 +1067,8 @@           |] `shouldRenderTo` (library [i|           other-modules:               Paths_foo+          autogen-modules:+              Paths_foo           build-depends:               foo           mixins:@@ -1026,6 +1087,8 @@             Foo         other-modules:             Paths_foo+        autogen-modules:+            Paths_foo         hs-source-dirs:             src         |]@@ -1055,6 +1118,8 @@         visibility: public         other-modules:             Paths_foo+        autogen-modules:+            Paths_foo         |]) {packageCabalVersion = "3.0"}      context "when inferring modules" $ do@@ -1239,6 +1304,7 @@                 Paths_foo                 Bar             autogen-modules:+                Paths_foo                 Foo                 Bar             |]) {packageCabalVersion = "2.0"}@@ -1260,6 +1326,7 @@                 Paths_foo                 Other             autogen-modules:+                Paths_foo                 Exposed                 Other             |]) {packageCabalVersion = "2.0"}@@ -1277,6 +1344,8 @@             |] `shouldRenderTo` (library [i|             other-modules:                 Paths_foo+            autogen-modules:+                Paths_foo             hs-source-dirs:                 src             if os(windows)@@ -1340,6 +1409,7 @@                 Paths_foo                 Foo             autogen-modules:+                Paths_foo                 Foo           |]) {packageCabalVersion = "2.0"}