Commit a090a494 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

One-component configure, fixes #2802.

Described in: https://github.com/ghc-proposals/ghc-proposals/pull/4



./Setup configure now takes an argument to specify a specific
component name that should solely be configured.

Most of the gyrations in Configure are all about making it so that
we can feed in internal dependencies via --dependency.

I dropped the package name match sanity check to handle convenience
library package name munging.  Consider an internal library named
'q' in package 'p'.  When we install it to the package database,
we munged the package name into 'z-p-z-q', so that it doesn't
conflict with the actual package named 'q'.  Now consider when
we feed it in with --dependency q=p-0.1-hash-q.  Previously,
Cabal checked that the 'q' in --dependency matched the package
name in the database... which it doesn't. So I dropped the check.

I also had to make register/copy unconditionally install internal
libraries; otherwise you can't refer to them from later builds.

Also a miscellaneous refactor: convenience libraries are printed with a
"header" stanza now (not really a stanza header).
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent a06460c3
name: test-for-cabal
version: 0.1.0.0
license: BSD3
author: Edward Z. Yang
maintainer: ezyang@cs.stanford.edu
build-type: Simple
cabal-version: >=1.10
library
exposed-modules: Lib
build-depends: base
default-language: Haskell2010
test-suite testsuite
build-depends: test-for-cabal, testlib, base
type: exitcode-stdio-1.0
main-is: Test.hs
hs-source-dirs: tests
name: testlib
version: 0.1.0.0
license: BSD3
author: Edward Z. Yang
maintainer: ezyang@cs.stanford.edu
build-type: Simple
cabal-version: >=1.10
library
exposed-modules: TestLib
build-depends: test-for-cabal, base
default-language: Haskell2010
......@@ -439,6 +439,31 @@ tests config = do
_ <- shell "autoreconf" ["-i"]
cabal_build []
tc "ConfigureComponent/Exe" $ do
withPackageDb $ do
cabal_install ["goodexe"]
runExe' "goodexe" [] >>= assertOutputContains "OK"
tcs "ConfigureComponent/SubLib" "sublib-explicit" $ do
withPackageDb $ do
cabal_install ["sublib", "--cid", "sublib-0.1-abc"]
cabal_install ["exe", "--dependency", "sublib=sublib-0.1-abc"]
runExe' "exe" [] >>= assertOutputContains "OK"
tcs "ConfigureComponent/SubLib" "sublib" $ do
withPackageDb $ do
cabal_install ["sublib"]
cabal_install ["exe"]
runExe' "exe" [] >>= assertOutputContains "OK"
tcs "ConfigureComponent/Test" "test" $ do
withPackageDb $ do
cabal_install ["test-for-cabal"]
withPackage "testlib" $ cabal_install []
cabal "configure" ["testsuite"]
cabal "build" []
cabal "test" []
-- Test that per-component copy works, when only building library
tc "CopyComponent/Lib" $
withPackageDb $ do
......@@ -580,9 +605,9 @@ tests config = do
uid = componentUnitId (targetCLBI target)
dir = libdir (absoluteComponentInstallDirs pkg_descr lbi uid
NoCopyDest)
assertBool "interface files should NOT be installed" . not
assertBool "interface files should be installed"
=<< liftIO (doesFileExist (dir </> "Foo.hi"))
assertBool "static library should NOT be installed" . not
assertBool "static library should be installed"
=<< liftIO (doesFileExist (dir </> mkLibName uid))
if is_dynamic
then
......@@ -590,7 +615,7 @@ tests config = do
=<< liftIO (doesFileExist (dir </> mkSharedLibName
compiler_id uid))
else
assertBool "dynamic library should NOT be installed" . not
assertBool "dynamic library should be installed"
=<< liftIO (doesFileExist (dir </> mkSharedLibName
compiler_id uid))
shouldFail $ ghcPkg "describe" ["foo"]
......
......@@ -302,6 +302,7 @@ instance Semigroup SavedConfig where
-- TODO: NubListify
configExtraIncludeDirs = lastNonEmpty configExtraIncludeDirs,
configIPID = combine configIPID,
configCID = combine configCID,
configDistPref = combine configDistPref,
configCabalFilePath = combine configCabalFilePath,
configVerbosity = combine configVerbosity,
......
......@@ -489,6 +489,7 @@ configureInstallPlan solverPlan =
ConfiguredPackage {
confPkgId = SimpleUnitId
$ Configure.computeComponentId
Cabal.NoFlag
Cabal.NoFlag
(packageId spkg)
PD.CLibName
......
......@@ -569,6 +569,7 @@ convertToLegacyAllPackageConfig
configDependencies = mempty,
configExtraIncludeDirs = mempty,
configIPID = mempty,
configCID = mempty,
configConfigurationsFlags = mempty,
configTests = mempty,
configCoverage = mempty, --TODO: don't merge
......@@ -633,6 +634,7 @@ convertToLegacyPerPackageConfig PackageConfig {..} =
configDependencies = mempty,
configExtraIncludeDirs = packageConfigExtraIncludeDirs,
configIPID = mempty,
configCID = mempty,
configConfigurationsFlags = packageConfigFlagAssignment,
configTests = packageConfigTests,
configCoverage = packageConfigCoverage, --TODO: don't merge
......
......@@ -1941,6 +1941,7 @@ setupHsConfigureFlags (ReadyPackage
configVerbosity = toFlag verbosity
configIPID = toFlag (display (installedUnitId pkg))
configCID = mempty
configProgramPaths = Map.toList pkgProgramPaths
configProgramArgs = Map.toList pkgProgramArgs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment