Permalink
Browse files

Use Cabal's mechanism to find the datadir rather than our own

So remove the --data flag and the wrapper scripts. Cabal now
installs the C2HS.hs file. Also means the Setup.hs no longer
needs to install the wrapper script or C2HS.hs.

darcs-hash:20070209104238-9561d-3c05637d01b77c45d14381e532c17c629ac70395
  • Loading branch information...
dcoutts committed Feb 9, 2007
1 parent 34a97c4 commit fddacaa96803736bd44dc138d844bcc5394aa82a
Showing with 6 additions and 68 deletions.
  1. 0 {c2hs/lib → }/C2HS.hs
  2. +1 −26 Setup.hs
  3. +2 −0 c2hs.cabal
  4. +0 −5 c2hs/c2hs-inplace.in
  5. +0 −7 c2hs/c2hs.in
  6. +0 −2 c2hs/state/Switches.hs
  7. +3 −14 c2hs/toplevel/Main.hs
  8. +0 −14 postInst.sh.in
File renamed without changes.
View
@@ -1,30 +1,5 @@
#!/usr/bin/env runhaskell
-import System (system, ExitCode)
-
import Distribution.Simple
--- for the argument types of the `postInst' hook
-import Distribution.Setup
-import Distribution.Simple.LocalBuildInfo
-import Distribution.PackageDescription
-
-main = defaultMainWithHooks defaultUserHooks {postInst = addWrapperAndLib}
-
--- Install the c2hs shell script wrapper that passes the --data options as
--- well as the `C2HS' library module.
---
--- * We need to do this via a shell script that has been munged by ./configure,
--- as Cabal doesn't give us enough info (eg, no package name and version) to
--- do it all in Haskell.
--- !FIXME not true anymore since GHC 6.4.2, but if we change that now, we
--- can't use the installation procedure on earlier GHC's anymore.
---
-addWrapperAndLib :: Args
- -> InstallFlags
- -> PackageDescription -- remove line for GHC 6.4.1 & earlier!
- -> LocalBuildInfo
- -> IO ExitCode
-addWrapperAndLib _ _ _ _ =
- -- ^remove this one underscore for GHC 6.4.1 & earlier!
- system "./postInst.sh"
+main = defaultMain
View
@@ -16,6 +16,8 @@ Description: C->Haskell assists in the development of Haskell bindings to C
files and generates marshaling and signature code in Haskell.
Category: Development tool
Build-Depends: base, haskell98
+--TODO: Cabal should allow 'Data-Files' in the executable stanza
+Data-Files: C2HS.hs
Executable: c2hs
Hs-Source-Dirs: base/admin
View
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-top=@TOP@
-
-exec $top/dist/build/c2hs/c2hs --data=$top/c2hs/lib ${1+"$@"}
View
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@/c2hs-@C2HS_VERSION@
-
-exec $libdir/c2hs --data=$libdir ${1+"$@"}
View
@@ -68,7 +68,6 @@ import C2HSConfig (PlatformSpec, defaultPlatformSpec)
data SwitchBoard = SwitchBoard {
cppOptsSB :: String, -- cpp options
cppSB :: FilePath, -- cpp executable
- dataSB :: FilePath, -- data directory
keepSB :: Bool, -- keep intermediate file
librarySB :: Bool, -- copy library in
tracesSB :: Traces, -- trace flags
@@ -85,7 +84,6 @@ initialSwitchBoard :: SwitchBoard
initialSwitchBoard = SwitchBoard {
cppOptsSB = "",
cppSB = "cpp",
- dataSB = "",
keepSB = False,
librarySB = False,
tracesSB = initialTraces,
View
@@ -130,6 +130,7 @@ import System.Console.GetOpt
(ArgOrder(..), OptDescr(..), ArgDescr(..), usageInfo, getOpt)
import FNameOps (suffix, basename, dirname, stripSuffix, addPath)
import Errors (interr)
+import StateBase (liftIO)
-- c2hs modules
import C2HSState (CST, nop, runC2HS, fatal, fatalsHandledBy, getId,
@@ -148,6 +149,7 @@ import GenBind (expandHooks)
import Version (version, copyright, disclaimer)
import C2HSConfig (cpp, cppopts, datadir, libfname, PlatformSpec(..),
defaultPlatformSpec, platformSpecDB)
+import Paths_c2hs (getDataDir)
-- wrapper running the compiler
@@ -183,7 +185,6 @@ errTrailer = "Try the option `--help' on its own for more information.\n"
--
data Flag = CPPOpts String -- additional options for C preprocessor
| CPP String -- program name of C preprocessor
- | Data String -- Data directory
| Dump DumpType -- dump internal information
| Help -- print brief usage information
| Keep -- keep the .i file
@@ -214,10 +215,6 @@ options = [
["cpp"]
(ReqArg CPP "CPP")
"use executable CPP to invoke C preprocessor",
- Option []
- ["data"]
- (ReqArg Data "DIR")
- "data directory (set by wrapper script)",
Option ['d']
["dump"]
(ReqArg dumpArg "TYPE")
@@ -294,7 +291,6 @@ compile =
(not . null) nonDataOpts &&
all (`elem` aloneOptions) nonDataOpts
where
- nonDataOrDir (Data _) = False
nonDataOrDir (OutDir _) = False
nonDataOrDir _ = True
--
@@ -328,7 +324,6 @@ compile =
setup :: CST s ()
setup = do
setCPP cpp
- setData datadir
addCPPOpts cppopts
-- output error message
@@ -399,7 +394,6 @@ help =
processOpt :: Flag -> CST s ()
processOpt (CPPOpts cppopts) = addCPPOpts cppopts
processOpt (CPP cpp ) = setCPP cpp
-processOpt (Data dir ) = setData dir
processOpt (Dump dt ) = setDump dt
processOpt (Keep ) = setKeep
processOpt (Library ) = setLibrary
@@ -449,7 +443,7 @@ copyLibrary =
do
outdir <- getSwitch outDirSB
library <- getSwitch librarySB
- datadir <- getSwitch dataSB
+ datadir <- liftIO getDataDir
let libFullName = datadir `addPath` libfname
libDestName = outdir `addPath` libfname
when library $
@@ -475,11 +469,6 @@ addCPPOpts opts =
setCPP :: FilePath -> CST s ()
setCPP fname = setSwitch $ \sb -> sb {cppSB = fname}
--- set the data directory
---
-setData :: FilePath -> CST s ()
-setData dir = setSwitch $ \sb -> sb {dataSB = dir}
-
-- set the given dump option
--
setDump :: DumpType -> CST s ()
View
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-bindir=@bindir@
-libdir=@libdir@/c2hs-@C2HS_VERSION@
-
-echo "Moving executable into $libdir/"
-/bin/sh install-sh -d $libdir
-/bin/sh install-sh -s -m 755 $bindir/c2hs $libdir/
-
-echo "Installing wrapper and C2HS.hs"
-/bin/sh install-sh -c -m 755 c2hs/c2hs $bindir/
-/bin/sh install-sh -c -m 644 c2hs/lib/C2HS.hs $libdir/

0 comments on commit fddacaa

Please sign in to comment.