3 import Test
.Cabal
.Prelude
4 import Control
.Monad
.IO.Class
6 import Distribution
.System
(buildPlatform
)
7 import Distribution
.Package
8 import Distribution
.Simple
.Configure
9 import Distribution
.Simple
.BuildPaths
10 import Distribution
.Simple
.LocalBuildInfo
11 import Distribution
.Simple
.InstallDirs
12 import Distribution
.Simple
.Compiler
13 import Distribution
.Types
.TargetInfo
14 import Distribution
.Types
.LocalBuildInfo
15 import Distribution
.Types
.UnqualComponentName
16 #if MIN_VERSION_Cabal
(3,11,0)
17 import Distribution
.Utils
.Path
(makeSymbolicPath
)
20 import System
.Directory
22 -- Internal libraries used by a statically linked executable:
23 -- no libraries should get installed or registered. (Note,
24 -- this does build shared libraries just to make sure they
25 -- don't get installed, so this test doesn't work on Windows.)
26 main
= setupAndCabalTest
$ do
27 skipIfNoSharedLibraries
30 forM_
[False, True] $ \is_dynamic
-> do
31 setup_install
$ [ if is_dynamic
then "--enable-executable-dynamic"
32 else "--disable-executable-dynamic"
34 dist_dir
<- fmap testDistDir getTestEnv
37 #if MIN_VERSION_Cabal
(3,11,0)
38 Nothing
$ makeSymbolicPath
41 let pkg_descr
= localPkgDescr lbi
42 compiler_id
= compilerId
(compiler lbi
)
43 cname
= CLibName
$ LSubLibName
$ mkUnqualComponentName
"foo-internal"
44 [target
] = componentNameTargets
' pkg_descr lbi cname
45 uid
= componentUnitId
(targetCLBI target
)
46 InstallDirs
{libdir
=dir
,dynlibdir
=dyndir
} =
47 absoluteComponentInstallDirs pkg_descr lbi uid NoCopyDest
48 assertBool
"interface files should be installed"
49 =<< liftIO
(doesFileExist (dir
</> "Foo.hi"))
50 assertBool
"static library should be installed"
51 =<< liftIO
(doesFileExist (dir
</> mkLibName uid
))
54 assertBool
"dynamic library MUST be installed"
55 =<< liftIO
(doesFileExist (dyndir
</> mkSharedLibName
56 buildPlatform compiler_id uid
))
58 assertBool
"dynamic library should be installed"
59 =<< liftIO
(doesFileExist (dyndir
</> mkSharedLibName
60 buildPlatform compiler_id uid
))
61 fails
$ ghcPkg
"describe" ["foo"]
62 -- clean away the dist directory so that we catch accidental
63 -- dependence on the inplace files
65 runInstalledExe
' "foo" [] >>= assertOutputContains
"46"