From 567484dba04920180d35acc4a59893270fb919f3 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 18 Jan 2018 17:23:10 +0800 Subject: [PATCH 1/3] 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. --- Cabal/doc/nix-local-build.rst | 2 +- .../Client/ProjectConfig/Legacy.hs | 62 +++++++------------ .../Distribution/Client/TargetSelector.hs | 4 +- cabal-install/changelog | 2 +- 4 files changed, 27 insertions(+), 43 deletions(-) diff --git a/Cabal/doc/nix-local-build.rst b/Cabal/doc/nix-local-build.rst index 58696ae0cb7..8bc2e4f7cc8 100644 --- a/Cabal/doc/nix-local-build.rst +++ b/Cabal/doc/nix-local-build.rst @@ -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. diff --git a/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs b/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs index 2811a4343a5..9d1c64e8279 100644 --- a/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs +++ b/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs @@ -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 @all-packages@ sections of the @cabal.project@-format files. +-- 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 } diff --git a/cabal-install/Distribution/Client/TargetSelector.hs b/cabal-install/Distribution/Client/TargetSelector.hs index 9e558a9e903..563d011ffc0 100644 --- a/cabal-install/Distribution/Client/TargetSelector.hs +++ b/cabal-install/Distribution/Client/TargetSelector.hs @@ -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" diff --git a/cabal-install/changelog b/cabal-install/changelog index 15771d30cd0..d5bd4ea3810 100644 --- a/cabal-install/changelog +++ b/cabal-install/changelog @@ -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 December 2017 From f43fa8c64630015aa70ffeb065831493d67b67fd Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Fri, 19 Jan 2018 10:51:18 +0800 Subject: [PATCH 2/3] Drop dead code. --- cabal-install/Distribution/Client/ProjectConfig/Legacy.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs b/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs index 9d1c64e8279..3be37dcab0a 100644 --- a/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs +++ b/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs @@ -81,7 +81,6 @@ 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 +1044,6 @@ legacyPackageConfigFieldDescrs = legacyPackageConfigSectionDescrs :: [SectionDescr LegacyProjectConfig] legacyPackageConfigSectionDescrs = [ packageRepoSectionDescr --- , allPackagesOptionsSectionDescr , packageSpecificOptionsSectionDescr , liftSection legacyLocalConfig From 9cc2c34ec639ff77f8d73ae6c21c971404402e7e Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Fri, 19 Jan 2018 13:58:57 +0800 Subject: [PATCH 3/3] Drop trace. --- cabal-install/Distribution/Client/ProjectConfig/Legacy.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs b/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs index 3be37dcab0a..200489c3061 100644 --- a/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs +++ b/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs @@ -1132,7 +1132,7 @@ packageSpecificOptionsSectionDescr = legacyAllConfig = legacyAllConfig projconf <> pkgconf } _ -> do - pkgname <- case simpleParse (traceShowId pkgnamestr) of + pkgname <- case simpleParse pkgnamestr of Just pkgname -> return pkgname Nothing -> syntaxError lineno $ "a 'package' section requires a package name "