Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename all-packages to package * #5053

Merged
merged 3 commits into from
Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cabal/doc/nix-local-build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
62 changes: 23 additions & 39 deletions cabal-install/Distribution/Client/ProjectConfig/Legacy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import Distribution.Simple.Command
, OptionField, option, reqArg' )

import qualified Data.Map as Map

import Debug.Trace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kill me

------------------------------------------------------------------
-- Representing the project config file in terms of legacy types
--
Expand Down Expand Up @@ -1045,7 +1045,7 @@ legacyPackageConfigFieldDescrs =
legacyPackageConfigSectionDescrs :: [SectionDescr LegacyProjectConfig]
legacyPackageConfigSectionDescrs =
[ packageRepoSectionDescr
, allPackagesOptionsSectionDescr
-- , allPackagesOptionsSectionDescr
, packageSpecificOptionsSectionDescr
, liftSection
legacyLocalConfig
Expand Down Expand Up @@ -1091,7 +1091,7 @@ packageRepoSectionDescr =
}

-- | The definitions of all the fields that can appear in the @package pkgfoo@
-- and @all-packages@ sections of the @cabal.project@-format files.
-- and @package *@ sections of the @cabal.project@-format files.
--
packageSpecificOptionsFieldDescrs :: [FieldDescr LegacyPackageConfig]
packageSpecificOptionsFieldDescrs =
Expand All @@ -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 =
Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions cabal-install/Distribution/Client/TargetSelector.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]> December 2017
Expand Down