[Hackage] #326: Cabal should support Cabal-version-dependent Setup.hs

Hackage trac at galois.com
Tue Aug 19 17:04:03 EDT 2008


#326: Cabal should support Cabal-version-dependent Setup.hs
----------------------------+-----------------------------------------------
  Reporter:  claus          |        Owner:         
      Type:  enhancement    |       Status:  new    
  Priority:  normal         |    Milestone:         
 Component:  Cabal library  |      Version:  1.2.3.0
  Severity:  normal         |   Resolution:         
  Keywords:                 |   Difficulty:  normal 
Ghcversion:  6.8.2          |     Platform:         
----------------------------+-----------------------------------------------
Comment (by claus):

 Replying to [comment:9 duncan]:
 > It would not work for hugs or nhc98 because hugs does not grok the CPP
 pragma and neither let us specify extra info like `include-dirs` in the
 package resistration, so even if they did cpp they would not be able to
 find the header file.

 Interesting. How do hugs and nhc98 survive processing base without CPP and
 include-dir?

 Anyway, that brings us back to a CPP-less approach. Here is that sketch
 again, this time in code:
 {{{
 import System.IO
 import System.Process
 import Text.Regex
 import System.Exit
 import Control.Monad
 import System.Directory

 die last_words = do
   hPrint stderr last_words
   exitFailure

 condition `orElse` action = do
   c <- condition
   unless c action

 main = do
   (_,o,_,_) <- runInteractiveCommand "ghc-pkg field Cabal version"
   field <- hGetContents o
   case matchRegex (mkRegex "version: ([0-9.]*)") field of
     Just [version] -> do
       let setup = "Setup-"++version++".hs"
       doesFileExist setup `orElse` die ("can't find version-specific Setup
 source: "++setup)
       runCommand $ "runhaskell "++setup
     _ -> die $ "can't determine Cabal version: "++field
 }}}


 I'm sure something less inelegant can be hacked up within Cabal, but I can
 never find what I'm looking for in `Distribution.*` (in spite of the many
 pieces of functionality available, it seems they are only really meant to
 be used in one specific context/order/framework, not in isolation).

-- 
Ticket URL: <http://hackage.haskell.org/trac/hackage/ticket/326#comment:10>
Hackage <http://haskell.org/cabal/>
Hackage: Cabal and related projects


More information about the cabal-devel mailing list