ghc-pkg and quoting on haddock-related fields

Esa Ilari Vuokko eivuokko at gmail.com
Thu Aug 9 00:18:22 EDT 2007


Esa Ilari Vuokko wrote:
> Is the right fix to make Cabal unquote the fields it
> receives from ghc-pkg, or is there some more complex
> problem lurking around?

Attached patch uses existing parsers to handle ghc-pkg
output.  It still ignores multiple values, as it used to
before, as well.  I have no idea if it's the right
approach, but it fixes the immediate problem for me.

Thu Aug  9 07:11:53 FLE Daylight Time 2007  Esa Ilari Vuokko <ei at vuokko.info>
  * Use existing parsers to handle ghc-pkg field output


Best regards,
Esa
-------------- next part --------------

New patches:

[Use existing parsers to handle ghc-pkg field output
Esa Ilari Vuokko <ei at vuokko.info>**20070809041153] {
hunk ./Distribution/Simple/Haddock.hs 50
+import Distribution.Compat.ReadP(readP_to_S)
hunk ./Distribution/Simple/Haddock.hs 53
+import Distribution.ParseUtils(Field(..), readFields, parseCommaList, parseFilePathQ)
hunk ./Distribution/Simple/Haddock.hs 62
-import Distribution.Simple.Utils (die, createDirectoryIfMissingVerbose,
+import Distribution.Simple.Utils (die, warn, createDirectoryIfMissingVerbose,
hunk ./Distribution/Simple/Haddock.hs 71
-import Control.Monad(liftM, when, unless)
-import Data.Char	( isSpace )
+import Control.Monad(liftM, when, unless, join)
hunk ./Distribution/Simple/Haddock.hs 138
-    let trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace
hunk ./Distribution/Simple/Haddock.hs 141
-            return $ trim $ dropWhile (not . isSpace) $ head $ lines s
+            case readFields s of
+                (ParseOk _ ((F _ _ fieldVal):_)) ->
+                    return . join . join . take 1 . map fst . filter (null . snd)
+                        . readP_to_S (parseCommaList parseFilePathQ) $ fieldVal
+                _ -> do
+                    warn verbosity $ "Unrecognised output from haddock: " ++ s
+                    return []
}

Context:

[Oops, fix deprecated Distribution.Extension module
Duncan Coutts <duncan at haskell.org>**20070807172125
 it no longer exports the internal per-compiler extension to flags functions
 as they are no longer exist and the equivalents are internal.
] 
[remove unused local vars
Duncan Coutts <duncan at haskell.org>**20070807171235] 
[Add compilerExtensions field to Compiler and make each compiler fill it in
Duncan Coutts <duncan at haskell.org>**20070807170653
 It's just a list of supported extensions and the corresponding compiler flags.
 For most compilers this is currently just a static list. For ghc 6.7 and above
 we query ghc to find the list of language extensions it supports.
 In each case the code has moved out into the compiler-specific modules and the
 core code treats it generically.
 The extensionsToFlags function has been split into two:
 extensionsToFlags which now returns the flags for the supported extensions and
 unsupportedExtensions which does what it says it does. This is because the two
 roles of the previous function were always used separately, never together.
] 
[Use String rather than importing a module just to misuse a String type alias
Duncan Coutts <duncan at haskell.org>**20070807170526] 
[Add a little documentation.
Thomas Schilling <nominolo at gmail.com>**20070807162023] 
[Fix error message.
Thomas Schilling <nominolo at gmail.com>**20070807162001] 
[Fix translation of deprecated fields.  Add test case.
Thomas Schilling <nominolo at gmail.com>**20070807161837] 
[Warn if no Cabal-version field is specified, but new syntax is used.
Thomas Schilling <nominolo at gmail.com>**20070806235131
 This isn't quite exact.  Ideally, we'd like to have something like
 isEmptyRange (specified-range && >= 1.2) but implementing isEmptyRange
 is non-trivial, so we'll go with this imperfect solution until we need
 that feature elsewhere.
] 
[Re-enable and update unit tests.
Thomas Schilling <nominolo at gmail.com>**20070807000155] 
[Cosmetic cleanup (fix line length)
Thomas Schilling <nominolo at gmail.com>**20070806235644] 
[No longer fail to parse packages without any library or executable
Thomas Schilling <nominolo at gmail.com>**20070806235404
 sections.  Issue a warning instead.  (The previous error message
 "Unexpected end of file" was not very helpful.)
] 
[Allow querying for the wildcard version range.
Thomas Schilling <nominolo at gmail.com>**20070806234707] 
[Split up make target for documentation generation.  Allows to build
Thomas Schilling <nominolo at gmail.com>**20070803200533
 the user's guide separately from the Haddock documentation. 
] 
[Remove more os-specific cppery
Duncan Coutts <duncan at haskell.org>**20070807115707
 The only difference for this one was / vs \\ path separators
] 
[Ask the compiler what languages it supports, when possible
Ian Lynagh <igloo at earth.li>**20070805171323] 
[Remove use of cpp in Distribution.System
Duncan Coutts <duncan at haskell.org>**20070807111837
 base it off of the System.Info.os string rather than cpp defs
] 
[Make things build with ghc-6.6.x rather than just ghc HEAD
Duncan Coutts <duncan at haskell.org>**20070807111724
 filepath-1.0 does not export dropDrive
] 
[Pattern match on an OS datatype rather than using ifdef everywhere
Ian Lynagh <igloo at earth.li>**20070805130347] 
[Add StandaloneDeriving extension
Ian Lynagh <igloo at earth.li>**20070804192416] 
[extensionToGHCFlag is now version dependent, and uses -XFoo flags for >=6.7
Ian Lynagh <igloo at earth.li>**20070804191833] 
[Add TypeFamilies extension
Ian Lynagh <igloo at earth.li>**20070804184959] 
[Don't complain about AllRightsReserved licenses
Duncan Coutts <duncan at haskell.org>**20070804125110
 That can be done in hackage when people try to upload. Fixes bug #127.
] 
[Add setup register --gen-pkg-config flag for distros that want that.
Duncan Coutts <duncan at haskell.org>**20070804115512
 It generates the actual file to be passed to the compiler's package program.
 This is obviously compiler-specific.
] 
[Correct the location of the haddock dir in inplace registrations
Duncan Coutts <duncan at haskell.org>**20070804115428] 
[normalise the input and output file names when pre-processing
Duncan Coutts <duncan at haskell.org>**20070804013029
 eg so we don't call cpp with ././src/blah -o ./dist/blah
 since those ././ can end up in error messages.
] 
[Put the generated haddock-prolog file under dist
Duncan Coutts <duncan at haskell.org>**20070804004848] 
[Try and simplify cleaning by always removing dist
Duncan Coutts <duncan at haskell.org>**20070804004643
 so we don't have to individually track all the files we create
 we still have to delete a few files outside of the build dir sadly
 the configuration is still preserved if you specify --save-configure
] 
[Remove compilerBinaryName, use compilerId instead
Duncan Coutts <duncan at haskell.org>**20070804004524] 
[Move compiler-specific code for configurion into compiler modules
Duncan Coutts <duncan at haskell.org>**20070803213321
 There's slightly more code overally but it's no longer incomprehensible
 because it's not all mixed together for all the different compilers.
] 
[Clean up rather un-sbstract use of Compiler in configure
Duncan Coutts <duncan at haskell.org>**20070803205901] 
[-Wall police
Duncan Coutts <duncan at haskell.org>**20070802194000] 
[Change Compiler's compilerVersion fild to compilerId
Duncan Coutts <duncan at haskell.org>**20070802193400
 Of type PackageIdentifier rather than Version.
] 
[Remove Distribution.Simple.Configure.findProgram as it's no longer used
Duncan Coutts <duncan at haskell.org>**20070802194230] 
[Put the haddock and hscolour version numbers in the global ProgramConfiguration
Duncan Coutts <duncan at haskell.org>**20070802185614
 We do this during the configure step and then later we don't have to run
 haddock & hscolour again to find out their version numbers.
 This also eliminates some annoying module interdependencies.
 Eventually the Program abstraction ought to include the ability for programs
 to discover their own version numbers so it can be done more modularly.
] 
[Alter version parse error message to make it clearer
Duncan Coutts <duncan at haskell.org>**20070802181620] 
[Add version field to Program and add findProgram(AndVersion) utilities
Duncan Coutts <duncan at haskell.org>**20070802172941
 findProgram and findProgramAndVersion construct Program values
 The latter makes it easier to parse output of --version calls.
 The idea is that we should carry the version number along with the program
 if we know it, so we can later decide version-dependent args without having
 to do more IO to find the program version, eg see use_optP_P & haddockVersion.
] 
[Tidy some imports/exports
Duncan Coutts <duncan at haskell.org>**20070802003250] 
[Remove redundant configure flags, missed bits of previous refactoring.
Duncan Coutts <duncan at haskell.org>**20070802003154] 
[Make the Compiler abstraction use the Program abstraction
Duncan Coutts <duncan at haskell.org>**20070801205428
 So out with compilerPath :: FilePath, in with compilerProg :: Program
 Similarly for compilerPkgTool.
 Lots of knock-on changes due to this, including converting many more uses of
 rawSystemExit to rawSystemProgram.
] 
[Simplify rawSystemProgram using programPath
Duncan Coutts <duncan at haskell.org>**20070801200247] 
[Add programPath :: Program -> FilePath
Duncan Coutts <duncan at haskell.org>**20070801200139
 At the moment it's a partial function, but we should change that by having
 a distinction between an abstract program and a configured program.
] 
[Clean up cpphs/ghc -cpp preprocessor code
Duncan Coutts <duncan at haskell.org>**20070801135256
 Now better separated and uses Program better.
 Also no longer needs internal lookupProgram' utils function.
] 
[Clean up calling of ar, make it use Program abstraction
Duncan Coutts <duncan at haskell.org>**20070801021526] 
[Make all the pre-processors use the Program abstraction
Duncan Coutts <duncan at haskell.org>**20070801021049] 
[Improve hangling of the title and prolog for haddock docs
Duncan Coutts <duncan at haskell.org>**20070804021538
 Only include ": " in the title if it has a synopsis to use as subtitle
 Use the description as the prolog, or if that's empty we use the synopsis.
 Do the same for executables, fixing bug #142.
] 
[Less confusing haddock command output when there are no libs in the package
Duncan Coutts <duncan at haskell.org>**20070804013133
 It says:
 > No documentation was generated as this package does not contain a library.
 > Perhaps you want to use the haddock command with the --executables flag.
] 
[Add message saying where haddock docs got put
Duncan Coutts <duncan at haskell.org>**20070804010016
 And make the similar message for sdist respect the verbosity
] 
[Make the writing registration script message less silly
Duncan Coutts <duncan at haskell.org>**20070804002353] 
[Fix haddock markup for finalizePackageDescription
Duncan Coutts <duncan at haskell.org>**20070804001745] 
[Change error message for tabs used as indentation to something more
Thomas Schilling <nominolo at gmail.com>**20070803213331
 helpful.
] 
[Fix import path to HUnit.
Thomas Schilling <nominolo at gmail.com>**20070803200829] 
[Fix printing of 'impl' checks.
Thomas Schilling <nominolo at gmail.com>**20070803200622] 
[Disallow tabs .cabal files with new syntax
Thomas Schilling <nominolo at gmail.com>**20070803181244] 
[Fix tab in Cabal.cabal.
Thomas Schilling <nominolo at gmail.com>**20070803175701] 
[Add impl(...) conditional to configurations.
Thomas Schilling <nominolo at gmail.com>**20070802010527
 You can now use expressions like impl( ghc >= 6.6.1 ) in conditionals
 in .cabal files.
] 
[Add documentation for Cabal Configurations.
Thomas Schilling <nominolo at gmail.com>**20070803125632] 
[Move the SetupWrapper module under Distribution.Simple
Duncan Coutts <duncan at haskell.org>**20070803012304
 It's really a wrapper around the simple build system.
] 
[Cleanup. fix line length
Thomas Schilling <nominolo at gmail.com>**20070801221329] 
[Fix name of flag in error message
Duncan Coutts <duncan at haskell.org>**20070802172141] 
[Add readVersion convenience function to Distribution.Version
Duncan Coutts <duncan at haskell.org>**20070802171703
 So it's merely readVersion :: String -> Maybe Version
 Having to use readP_to_S parseVersion all over the place is annoying.
] 
[extraArgs should override args in command lines
Duncan Coutts <duncan at haskell.org>**20070801023042
 besides, the order was inconsistent within the same function between the
 UserSpecified and FoundOnSystem cases.
] 
[FIX compilation with GHC 6.2.x
Simon Marlow <simonmar at microsoft.com>**20070801095523] 
[Move the haddock code out into it's own module
Duncan Coutts <duncan at haskell.org>**20070731183410
 It removes about 250 loc from Distribution.Simple
] 
[-Wall police
Duncan Coutts <duncan at haskell.org>**20070731173626] 
[Fix order of warnings.
Thomas Schilling <nominolo at gmail.com>**20070730225311] 
[Add line numbers to unknown fields error message.
Thomas Schilling <nominolo at gmail.com>**20070730225256] 
[Display a more helpful error message, when unknown fields are
Thomas Schilling <nominolo at gmail.com>**20070730224026
 noticed. 
] 
[Fix self-compile warnings.
Thomas Schilling <nominolo at gmail.com>**20070730220537] 
[Fix haddock markup
Ian Lynagh <igloo at earth.li>**20070729233545
 I haven't checked that it looks right, but it is now accepted by haddock.
] 
[Pass ghc -package flags when using it as a C compiler in GHCMakefile
Ian Lynagh <igloo at earth.li>**20070729152803
 This means we get the CPP include directories included.
] 
[Add a missing case in updateCfg
Ian Lynagh <igloo at earth.li>**20070729105910] 
[Resolve conflicts
Ian Lynagh <igloo at earth.li>**20070729105854] 
[Fix conflicts.  Fix for changed argument to 'preprocessSources'.
Thomas Schilling <nominolo at gmail.com>**20070728223322] 
[Rename field.
Thomas Schilling <nominolo at gmail.com>**20070728223102] 
[Change HUnit module path to Test.HUnit (the default now).
Thomas Schilling <nominolo at gmail.com>**20070728221453] 
[Add note to 'clean' that it could be simpler, but for compatibility
Thomas Schilling <nominolo at gmail.com>**20070728221342
 reasons isn't (for now). 
] 
[Let sdist command run the preprocessors itself.  This way we don't
Thomas Schilling <nominolo at gmail.com>**20070728221237
 have to put stuff into the source tree.
] 
[Store resolved package description in local build info.  
Thomas Schilling <nominolo at gmail.com>**20070728221102
 
 The clean and sdist commands need to use a flattened representation of
 the original description.  Note the notes for
 flattenPackageDescription for some problems with this approach.
] 
[Export 'flattenPackageDescription'.
Thomas Schilling <nominolo at gmail.com>**20070728215155] 
[Minor documentation fix.
Thomas Schilling <nominolo at gmail.com>**20070728214859] 
[Modify test case.
Thomas Schilling <nominolo at gmail.com>**20070728214825] 
[Add function 'flattenPackageDescription'.
Thomas Schilling <nominolo at gmail.com>**20070728214746] 
[Avoid reporting the same missing dependecy twice.
Thomas Schilling <nominolo at gmail.com>**20070728214645] 
[Add documentation
Thomas Schilling <nominolo at gmail.com>**20070728214541] 
[Add documentation
Thomas Schilling <nominolo at gmail.com>**20070728214444] 
[Add/Fix test cases
Thomas Schilling <nominolo at gmail.com>**20070728214410] 
[Minor. Moved some code.
Thomas Schilling <nominolo at gmail.com>**20070719222541] 
[Add function 'ignoreCondition'.
Thomas Schilling <nominolo at gmail.com>**20070719222444] 
[Re-enable and extend test case.
Thomas Schilling <nominolo at gmail.com>**20070719222341] 
[Filter duplicate dependencies.
Thomas Schilling <nominolo at gmail.com>**20070719222233] 
[Adopt new CondTree data structure.
Thomas Schilling <nominolo at gmail.com>**20070719125305
 
 'finalizePackageDescription' now also takes dependencies of
 executables into account.
] 
[Change CondTree data structure to something more flexible.
Thomas Schilling <nominolo at gmail.com>**20070719124655
 
 This also requires some interface changes.
] 
[Add simpler representation of a .cabal file with conditions.
Thomas Schilling <nominolo at gmail.com>**20070717203942] 
[Preprocessor output never gets written back to the source dir.
Thomas Schilling <nominolo at gmail.com>**20070717174026
 
 'preprocessSources' now gets an additional flag to determine whether
 to process all sources (for building) or only platform independent
 ones (for sdist).
] 
[Add resolved package description to 'LocalBuildInfo'.
Thomas Schilling <nominolo at gmail.com>**20070716204325] 
[Fix removed import by importing a required accessor only.
Thomas Schilling <nominolo at gmail.com>**20070716204238] 
[Add tags target to generate a tags file using 'hasktags'.  (Unix only)
Thomas Schilling <nominolo at gmail.com>**20070716203015] 
[Rename 'PreparedPackageDescription' to 'GenericPackageDescription'
Thomas Schilling <nominolo at gmail.com>**20070716200427] 
[Remove unused dependency.
Thomas Schilling <nominolo at gmail.com>**20070716200215] 
[Move configured_cabal to 'dist' directory.
Thomas Schilling <nominolo at gmail.com>**20070716154146] 
[Bugfix by Ian Lynagh:  Cabal can't have a Cabal-Version header; it breaks bootstrapping
Thomas Schilling <nominolo at gmail.com>**20070716151535] 
[Partial bugfix to allow traditional .cabal files without a library but
Thomas Schilling <nominolo at gmail.com>**20070628112301
 global build dependencies.  The correct solution is to add global
 dependencies to each executable and implement dependency resolution
 for executables.
 
 The current workaround is to add the dependencies to the library, but
 disable building of the library.
] 
[Take advantage of configurations to build Cabal itself and fix bootstrapping problem.
Thomas Schilling <nominolo at gmail.com>**20070628081438] 
[Re-add configurations module to .cabal file.  (Got removed on update.)
Thomas Schilling <nominolo at gmail.com>**20070623204706] 
[Properly fix tests.
Thomas Schilling <nominolo at gmail.com>**20070623203939] 
[Disable (comment out) tests for now.  Break due to changed interface.
Thomas Schilling <nominolo at gmail.com>**20070623203121] 
[Fix typo.
Thomas Schilling <nominolo at gmail.com>**20070623202333] 
[Add proper handling of configurations to configure command.
Thomas Schilling <nominolo at gmail.com>**20070623202017] 
[Fix warnings.
Thomas Schilling <nominolo at gmail.com>**20070623201723] 
[Adjust to new package reading interface.
Thomas Schilling <nominolo at gmail.com>**20070623201546] 
[Downcase flagnames.  Re-add config flags (were removed due to update).
Thomas Schilling <nominolo at gmail.com>**20070623201455] 
[Fix warnings.
Thomas Schilling <nominolo at gmail.com>**20070623201254] 
[Fix warnings, add documentation and changes in response to some
Thomas Schilling <nominolo at gmail.com>**20070623201135
 interface changes.
] 
[Make explicit that reading package descriptions isn't supported here, ATM.
Thomas Schilling <nominolo at gmail.com>**20070623200701] 
[Fixed warning
Thomas Schilling <nominolo at gmail.com>**20070623200522] 
[Fixed warnings, added documentation, and changed os and arch names to
Thomas Schilling <nominolo at gmail.com>**20070623200453
 simple strings.
] 
[Add helpers for reading and writing the file to hold a configured cabal-file.
Thomas Schilling <nominolo at gmail.com>**20070618195710] 
[Add commandline support for specifying defaults for flags.
Thomas Schilling <nominolo at gmail.com>**20070618195449] 
[Compatibility parsing and working configurations.
Thomas Schilling <nominolo at gmail.com>**20070618195329] 
[Pretty printing of conditions and CondTrees.  Non-dependency
Thomas Schilling <nominolo at gmail.com>**20070614125031
 information of CondTrees is now a modifier.  Move CondTree resolution functionality. 
] 
[Prototypical configurations
Thomas Schilling <nominolo at gmail.com>**20070613184332] 
[add line numbers to all field times
Thomas Schilling <nominolo at gmail.com>**20070613173548] 
[add flag as a section
Thomas Schilling <nominolo at gmail.com>**20070613172416] 
[added docs
Thomas Schilling <nominolo at gmail.com>**20070613172309] 
[fixed typo
Thomas Schilling <nominolo at gmail.com>**20070613172230] 
[Abstracted variables out of conditions.  Generalized simplification
Thomas Schilling <nominolo at gmail.com>**20070613172114
 function to accept an arbitrary partial assignment of these
 variables.
] 
[Added Configuration parsing and simplification.
Thomas Schilling <nominolo at gmail.com>**20070529210344] 
[Extended low-level parsing routines to also allow labelled blocks and if-blocks.
Thomas Schilling <nominolo at gmail.com>**20070529205958] 
[Added documentation.
Thomas Schilling <nominolo at gmail.com>**20070528211221] 
[Use the right output directory when building C sources for executables
Duncan Coutts <duncan at haskell.org>**20070726213309] 
[Use our own GetOpt if __GLASGOW_HASKELL__ >= 606 only
Ian Lynagh <igloo at earth.li>**20070724213112
 Used to be if __GLASGOW_HASKELL__ >= 604, but the 6.4 branch had a bug
 which looks likely to be the cause of GHC build failures we're seeing:
 -         procNextOpt (NonOpt x)   RequireOrder      = ([],x:rest,us,[])
 +         procNextOpt (NonOpt x)   RequireOrder      = ([],x:rest,[],[])
] 
[-Wall police
Duncan Coutts <duncan at haskell.org>**20070724172023] 
[Update user guide about haddock --css --hyperlink-source --hscolour-css
Duncan Coutts <duncan at haskell.org>**20070724160742
 The haddock --css flag is new. The old --hscolour=[path] flag got split
 into two flags: --hyperlink-source and --hscolour-css=path
] 
[Remove a couple bits of unused code and imports
Duncan Coutts <duncan at haskell.org>**20070724110732] 
[use nhc-Options rather than deprecated nhc98-Options
Duncan Coutts <duncan at haskell.org>**20070724110703] 
[Hugs build: track change to install-includes
Ross Paterson <ross at soi.city.ac.uk>**20070724101816] 
[Rename --hscolour to --hyperlink-source and add haddock --css flag
Duncan Coutts <duncan at haskell.org>**20070723190026
 So now --hyperlink-source controles wether or not we run hscolour and
 get haddock to link to the sources. The new flag --hscolour-css can
 be used to override the css file that hscolour uses.
 Also, the new flag --css can override the css file that haddock uses.
] 
[Merges from hscolour patch and make it work with haddock-0.8
Duncan Coutts <duncan at haskell.org>**20070723180602
 Some minor changes due to changes since the hscolour patch was written.
 Make it work with haddock-0.8 by using %{MODULE} rather than %{FILE}
 and generate output file names to match (ie not using the original file
 extension, just using the module name for the output file).
] 
[HsColour support
Roberto Zunino <zunrob at users.sf.net>**20070530194747
 Integration of Cabal, HsColour, and Haddock.
 (Also fixes bug #102)
] 
[Remove ContextStack extension
Ian Lynagh <igloo at earth.li>**20070709132341
 Seems to be based on GHC's -fcontext-stack flag, which takes an integer
 argument.
] 
[Remove InlinePhase extension
Ian Lynagh <igloo at earth.li>**20070708172919
 As far as I can tell
 (a) The -finline-phase flag stopped actually being accepted by GHC
     sometime between GHC 4.08.2 and GHC 5.04.3
 (b) It took an Int argument
] 
[Add KindSignatures extension
Ian Lynagh <igloo at earth.li>**20070708120616] 
[Add the MagicHash extension
Ian Lynagh <igloo at earth.li>**20070708111043] 
[TAG 2007-06-29
Ian Lynagh <igloo at earth.li>**20070629112545] 
Patch bundle hash:
a608bac28167cbcb85c567a31d2736c22e249753


More information about the cabal-devel mailing list