Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use the same custom hook for `cabal copy` #2

Merged
merged 1 commit into from

3 participants

@myme

It seems like cabal uses copy rather than install when installing
inside of a sandbox from a package linked in using add-source. This
means that myInstHook is never called when running
cabal install wxc inside of a sandbox and so the shared library is
not properly copied over to the sandbox's wxc lib folder.

I found #56 over at sourceforge and think that this (or some modification of it) will do the trick: https://sourceforge.net/p/wxhaskell/bugs/56/

@myme myme Use the same custom hook for `cabal copy`
It seems like `cabal` uses `copy` rather than `install` when installing
inside of a sandbox from a package linked in using `add-source`. This
means that `myInstHook` is never called when running
`cabal install wxc` inside of a sandbox and so the shared library is
not properly copied over to the sandbox's wxc lib folder.
ab687a6
@mlacorte

I also had this problem when trying to install the latest wxHaskell in a cabal-dev environment on Ubuntu 14.04. Martin's patch solved the issue for me.

@HJvT HJvT merged commit 7735736 into from
@HJvT HJvT referenced this pull request from a commit
@HJvT HJvT Use the same custom hook for `cabal copy` in wxc/Setup.hs
This copies the changes from pull request #2 to the master branch
#2
and probably solves bug ticket 56
https://sourceforge.net/p/wxhaskell/bugs/56/
002e6f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 25, 2014
  1. @myme

    Use the same custom hook for `cabal copy`

    myme authored
    It seems like `cabal` uses `copy` rather than `install` when installing
    inside of a sandbox from a package linked in using `add-source`. This
    means that `myInstHook` is never called when running
    `cabal install wxc` inside of a sandbox and so the shared library is
    not properly copied over to the sandbox's wxc lib folder.
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 7 deletions.
  1. +25 −7 wxc/Setup.hs
View
32 wxc/Setup.hs
@@ -11,10 +11,14 @@ import Distribution.Simple.InstallDirs (InstallDirs(..))
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo, localPkgDescr, installedPkgs, withPrograms, buildDir, absoluteInstallDirs)
import Distribution.Simple.PackageIndex(SearchResult (..), searchByName )
import Distribution.Simple.Program (ConfiguredProgram (..), lookupProgram, runProgram, simpleProgram, locationPath)
-import Distribution.Simple.Setup (ConfigFlags, BuildFlags, InstallFlags, CopyDest(..), fromFlag, installVerbosity)
+import Distribution.Simple.Setup ( BuildFlags, ConfigFlags
+ , CopyDest(..), CopyFlags, copyVerbosity
+ , InstallFlags, installVerbosity
+ , fromFlag
+ )
import Distribution.Simple.Utils (installOrdinaryFile)
import Distribution.System (OS (..), Arch (..), buildOS, buildArch)
-import Distribution.Verbosity (normal, verbose)
+import Distribution.Verbosity (Verbosity, normal, verbose)
import System.Cmd (system)
import System.Directory ( createDirectoryIfMissing, doesFileExist
, findExecutable, getCurrentDirectory
@@ -43,7 +47,12 @@ whenM mp e = mp >>= \p -> when p e
main :: IO ()
-main = defaultMainWithHooks simpleUserHooks { confHook = myConfHook, buildHook = myBuildHook, instHook = myInstHook }
+main = defaultMainWithHooks simpleUserHooks
+ { confHook = myConfHook
+ , buildHook = myBuildHook
+ , copyHook = myCopyHook
+ , instHook = myInstHook
+ }
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
@@ -439,11 +448,20 @@ ldconfig path = case buildOS of
ExitSuccess -> return ()
otherwise -> error "Couldn't execute ldconfig, ensure it is on your path"
+myCopyHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()
+myCopyHook = hookHelper (fromFlag . copyVerbosity) (copyHook simpleUserHooks)
+
myInstHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO ()
-myInstHook pkg_descr local_bld_info user_hooks inst_flags =
+myInstHook = hookHelper (fromFlag . installVerbosity) (instHook simpleUserHooks)
+
+hookHelper ::
+ (a -> Verbosity) ->
+ (PackageDescription -> LocalBuildInfo -> UserHooks -> a -> IO ()) ->
+ PackageDescription -> LocalBuildInfo -> UserHooks -> a -> IO ()
+hookHelper verbosity origHook pkg_descr local_bld_info user_hooks flags =
do
- -- Perform simpleUserHooks instHook (to copy installIncludes)
- instHook simpleUserHooks pkg_descr local_bld_info user_hooks inst_flags
+ -- Perform simpleUserHooks (copyHook/instHook => to copy installIncludes)
+ origHook pkg_descr local_bld_info user_hooks flags
-- Copy shared library
let bld_dir = buildDir local_bld_info
@@ -457,6 +475,6 @@ myInstHook pkg_descr local_bld_info user_hooks inst_flags =
inst_lib_dir = libdir $ absoluteInstallDirs pkg_descr local_bld_info NoCopyDest
- installOrdinaryFile (fromFlag (installVerbosity inst_flags)) (bld_dir </> lib_name) (inst_lib_dir </> lib_name)
+ installOrdinaryFile (verbosity flags) (bld_dir </> lib_name) (inst_lib_dir </> lib_name)
ldconfig inst_lib_dir
Something went wrong with that request. Please try again.