Commit 567484db authored by Moritz Angermann's avatar Moritz Angermann

Rename `all-packages` to `package *`

Using `package *` for all packages is in line with `package foo` for
and does not introduce a new keyword to remember.
parent 67276f87
......@@ -872,7 +872,7 @@ ways a package option can be specified:
apply to the build of the package, whether or not it is local or
external.
- They can be specified inside an ``all-packages`` stanza, in which case they
- They can be specified inside an ``package *`` stanza, in which case they
apply to all packages, local ones from the project and also external
dependencies.
......
......@@ -81,7 +81,7 @@ import Distribution.Simple.Command
, OptionField, option, reqArg' )
import qualified Data.Map as Map
import Debug.Trace
------------------------------------------------------------------
-- Representing the project config file in terms of legacy types
--
......@@ -1045,7 +1045,7 @@ legacyPackageConfigFieldDescrs =
legacyPackageConfigSectionDescrs :: [SectionDescr LegacyProjectConfig]
legacyPackageConfigSectionDescrs =
[ packageRepoSectionDescr
, allPackagesOptionsSectionDescr
-- , allPackagesOptionsSectionDescr
, packageSpecificOptionsSectionDescr
, liftSection
legacyLocalConfig
......@@ -1091,7 +1091,7 @@ packageRepoSectionDescr =
}
-- | The definitions of all the fields that can appear in the @package pkgfoo@
-- and @package *@ sections of the @cabal.project@-format files.
--
packageSpecificOptionsFieldDescrs :: [FieldDescr LegacyPackageConfig]
packageSpecificOptionsFieldDescrs =
......@@ -1112,30 +1112,9 @@ packageSpecificOptionsFieldDescrs =
)
programLocationsFieldDescrs
-- | The definition of the @all-packages@ sections of the
-- @cabal.project@-format files. This is the one that applies to all packages
-- used anywhere by the project, locally or as dependencies.
--
allPackagesOptionsSectionDescr :: SectionDescr LegacyProjectConfig
allPackagesOptionsSectionDescr =
SectionDescr {
sectionName = "all-packages",
sectionFields = packageSpecificOptionsFieldDescrs,
sectionSubsections = [],
sectionGet = (\x->[("", x)])
. legacyAllConfig,
sectionSet =
\lineno unused pkgsconf projconf -> do
unless (null unused) $
syntaxError lineno "the section 'all-packages' takes no arguments"
return projconf {
legacyAllConfig = legacyAllConfig projconf <> pkgsconf
},
sectionEmpty = mempty
}
-- | The definition of the @package pkgfoo@ sections of the @cabal.project@-format
-- files. This section is per-package name.
-- files. This section is per-package name. The special package @*@ applies to all
-- packages used anywhere by the project, locally or as dependencies.
--
packageSpecificOptionsSectionDescr :: SectionDescr LegacyProjectConfig
packageSpecificOptionsSectionDescr =
......@@ -1147,20 +1126,25 @@ packageSpecificOptionsSectionDescr =
[ (display pkgname, pkgconf)
| (pkgname, pkgconf) <-
Map.toList . getMapMappend
. legacySpecificConfig $ projconf ],
. legacySpecificConfig $ projconf ]
++ [ ("*", legacyAllConfig projconf) ],
sectionSet =
\lineno pkgnamestr pkgconf projconf -> do
pkgname <- case simpleParse pkgnamestr of
Just pkgname -> return pkgname
Nothing -> syntaxError lineno $
"a 'package' section requires a package name "
++ "as an argument"
return projconf {
legacySpecificConfig =
MapMappend $
Map.insertWith mappend pkgname pkgconf
(getMapMappend $ legacySpecificConfig projconf)
},
\lineno pkgnamestr pkgconf projconf -> case pkgnamestr of
"*" -> return projconf {
legacyAllConfig = legacyAllConfig projconf <> pkgconf
}
_ -> do
pkgname <- case simpleParse (traceShowId pkgnamestr) of
Just pkgname -> return pkgname
Nothing -> syntaxError lineno $
"a 'package' section requires a package name "
++ "as an argument"
return projconf {
legacySpecificConfig =
MapMappend $
Map.insertWith mappend pkgname pkgconf
(getMapMappend $ legacySpecificConfig projconf)
},
sectionEmpty = mempty
}
......
......@@ -356,8 +356,8 @@ showTargetSelectorKind bt = case bt of
TargetPackage TargetImplicitCwd _ (Just _) -> "cwd-package:filter"
TargetPackageNamed _ Nothing -> "named-package"
TargetPackageNamed _ (Just _) -> "named-package:filter"
TargetAllPackages Nothing -> "all-packages"
TargetAllPackages (Just _) -> "all-packages:filter"
TargetAllPackages Nothing -> "package *"
TargetAllPackages (Just _) -> "package *:filter"
TargetComponent _ _ WholeComponent -> "component"
TargetComponent _ _ ModuleTarget{} -> "module"
TargetComponent _ _ FileTarget{} -> "file"
......
......@@ -57,7 +57,7 @@
line, the last one is now preferred, so e.g. '-f+dev -f-dev' is
now equivalent to '-f-dev' (#4452).
* Removed support for building cabal-install with GHC < 7.10 (#4870).
* New 'all-packages' section in 'cabal.project' files that applies
* New 'package *' section in 'cabal.project' files that applies
options to all packages, not just those local to the project.
2.0.0.1 Mikhail Glushenkov <mikhail.glushenkov@gmail.com> December 2017
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment