@@ -56,6 +56,7 @@ import Distribution.Pretty
5656import Distribution.Package
5757import Distribution.System
5858import Distribution.Compiler
59+ import Distribution.Simple.InstallDirs.Internal
5960
6061import System.Directory (getAppUserDataDirectory )
6162import System.FilePath
@@ -355,41 +356,6 @@ newtype PathTemplate = PathTemplate [PathComponent]
355356
356357instance Binary PathTemplate
357358
358- data PathComponent =
359- Ordinary FilePath
360- | Variable PathTemplateVariable
361- deriving (Eq , Ord , Generic )
362-
363- instance Binary PathComponent
364-
365- data PathTemplateVariable =
366- PrefixVar -- ^ The @$prefix@ path variable
367- | BindirVar -- ^ The @$bindir@ path variable
368- | LibdirVar -- ^ The @$libdir@ path variable
369- | LibsubdirVar -- ^ The @$libsubdir@ path variable
370- | DynlibdirVar -- ^ The @$dynlibdir@ path variable
371- | DatadirVar -- ^ The @$datadir@ path variable
372- | DatasubdirVar -- ^ The @$datasubdir@ path variable
373- | DocdirVar -- ^ The @$docdir@ path variable
374- | HtmldirVar -- ^ The @$htmldir@ path variable
375- | PkgNameVar -- ^ The @$pkg@ package name path variable
376- | PkgVerVar -- ^ The @$version@ package version path variable
377- | PkgIdVar -- ^ The @$pkgid@ package Id path variable, eg @foo-1.0@
378- | LibNameVar -- ^ The @$libname@ path variable
379- | CompilerVar -- ^ The compiler name and version, eg @ghc-6.6.1@
380- | OSVar -- ^ The operating system name, eg @windows@ or @linux@
381- | ArchVar -- ^ The CPU architecture name, eg @i386@ or @x86_64@
382- | AbiVar -- ^ The Compiler's ABI identifier, $arch-$os-$compiler-$abitag
383- | AbiTagVar -- ^ The optional ABI tag for the compiler
384- | ExecutableNameVar -- ^ The executable name; used in shell wrappers
385- | TestSuiteNameVar -- ^ The name of the test suite being run
386- | TestSuiteResultVar -- ^ The result of the test suite being run, eg
387- -- @pass@, @fail@, or @error@.
388- | BenchmarkNameVar -- ^ The name of the benchmark being run
389- deriving (Eq , Ord , Generic )
390-
391- instance Binary PathTemplateVariable
392-
393359type PathTemplateEnv = [(PathTemplateVariable , PathTemplate )]
394360
395361-- | Convert a 'FilePath' to a 'PathTemplate' including any template vars.
@@ -485,86 +451,6 @@ installDirsTemplateEnv dirs =
485451-- spans which are either strings or variables, eg:
486452-- PathTemplate [Variable PrefixVar, Ordinary "/bin" ]
487453
488- instance Show PathTemplateVariable where
489- show PrefixVar = " prefix"
490- show LibNameVar = " libname"
491- show BindirVar = " bindir"
492- show LibdirVar = " libdir"
493- show LibsubdirVar = " libsubdir"
494- show DynlibdirVar = " dynlibdir"
495- show DatadirVar = " datadir"
496- show DatasubdirVar = " datasubdir"
497- show DocdirVar = " docdir"
498- show HtmldirVar = " htmldir"
499- show PkgNameVar = " pkg"
500- show PkgVerVar = " version"
501- show PkgIdVar = " pkgid"
502- show CompilerVar = " compiler"
503- show OSVar = " os"
504- show ArchVar = " arch"
505- show AbiTagVar = " abitag"
506- show AbiVar = " abi"
507- show ExecutableNameVar = " executablename"
508- show TestSuiteNameVar = " test-suite"
509- show TestSuiteResultVar = " result"
510- show BenchmarkNameVar = " benchmark"
511-
512- instance Read PathTemplateVariable where
513- readsPrec _ s =
514- take 1
515- [ (var, drop (length varStr) s)
516- | (varStr, var) <- vars
517- , varStr `isPrefixOf` s ]
518- -- NB: order matters! Longer strings first
519- where vars = [(" prefix" , PrefixVar )
520- ,(" bindir" , BindirVar )
521- ,(" libdir" , LibdirVar )
522- ,(" libsubdir" , LibsubdirVar )
523- ,(" dynlibdir" , DynlibdirVar )
524- ,(" datadir" , DatadirVar )
525- ,(" datasubdir" , DatasubdirVar )
526- ,(" docdir" , DocdirVar )
527- ,(" htmldir" , HtmldirVar )
528- ,(" pkgid" , PkgIdVar )
529- ,(" libname" , LibNameVar )
530- ,(" pkgkey" , LibNameVar ) -- backwards compatibility
531- ,(" pkg" , PkgNameVar )
532- ,(" version" , PkgVerVar )
533- ,(" compiler" , CompilerVar )
534- ,(" os" , OSVar )
535- ,(" arch" , ArchVar )
536- ,(" abitag" , AbiTagVar )
537- ,(" abi" , AbiVar )
538- ,(" executablename" , ExecutableNameVar )
539- ,(" test-suite" , TestSuiteNameVar )
540- ,(" result" , TestSuiteResultVar )
541- ,(" benchmark" , BenchmarkNameVar )]
542-
543- instance Show PathComponent where
544- show (Ordinary path) = path
545- show (Variable var) = ' $' : show var
546- showList = foldr (\ x -> (shows x . )) id
547-
548- instance Read PathComponent where
549- -- for some reason we collapse multiple $ symbols here
550- readsPrec _ = lex0
551- where lex0 [] = []
552- lex0 (' $' : ' $' : s') = lex0 (' $' : s')
553- lex0 (' $' : s') = case [ (Variable var, s'')
554- | (var, s'') <- reads s' ] of
555- [] -> lex1 " $" s'
556- ok -> ok
557- lex0 s' = lex1 [] s'
558- lex1 " " " " = []
559- lex1 acc " " = [(Ordinary (reverse acc), " " )]
560- lex1 acc (' $' : ' $' : s) = lex1 acc (' $' : s)
561- lex1 acc (' $' : s) = [(Ordinary (reverse acc), ' $' : s)]
562- lex1 acc (c: s) = lex1 (c: acc) s
563- readList [] = [([] ," " )]
564- readList s = [ (component: components, s'')
565- | (component, s') <- reads s
566- , (components, s'') <- readList s' ]
567-
568454instance Show PathTemplate where
569455 show (PathTemplate template) = show (show template)
570456
0 commit comments