From 1266b698b727c33d9c8e6948417feb5757ebf953 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Thu, 5 Apr 2018 21:13:48 -0700 Subject: [PATCH 01/13] Add `CInternalLib` constructor of `NamedComponent` to handle internal libraries. --- src/Stack/Build/Cache.hs | 1 + src/Stack/Build/Source.hs | 1 + src/Stack/Build/Target.hs | 1 + src/Stack/Ghci.hs | 1 + src/Stack/Package.hs | 9 +++++++++ src/Stack/Types/NamedComponent.hs | 2 ++ 6 files changed, 15 insertions(+) diff --git a/src/Stack/Build/Cache.hs b/src/Stack/Build/Cache.hs index 1247e8768f..2f60678906 100644 --- a/src/Stack/Build/Cache.hs +++ b/src/Stack/Build/Cache.hs @@ -120,6 +120,7 @@ buildCacheFile dir component = do let nonLibComponent prefix name = prefix <> "-" <> T.unpack name cacheFileName <- parseRelFile $ case component of CLib -> "lib" + CInternalLib name -> nonLibComponent "internal-lib" name CExe name -> nonLibComponent "exe" name CTest name -> nonLibComponent "test" name CBench name -> nonLibComponent "bench" name diff --git a/src/Stack/Build/Source.hs b/src/Stack/Build/Source.hs index a6fa561ff1..9917fdd6b8 100644 --- a/src/Stack/Build/Source.hs +++ b/src/Stack/Build/Source.hs @@ -167,6 +167,7 @@ splitComponents = where go a b c [] = (Set.fromList $ a [], Set.fromList $ b [], Set.fromList $ c []) go a b c (CLib:xs) = go a b c xs + go a b c (CInternalLib x:xs) = go (a . (x:)) b c xs go a b c (CExe x:xs) = go (a . (x:)) b c xs go a b c (CTest x:xs) = go a (b . (x:)) c xs go a b c (CBench x:xs) = go a b (c . (x:)) xs diff --git a/src/Stack/Build/Target.hs b/src/Stack/Build/Target.hs index 8e2f22166f..b5c314bcb5 100644 --- a/src/Stack/Build/Target.hs +++ b/src/Stack/Build/Target.hs @@ -230,6 +230,7 @@ resolveRawTarget globals snap deps locals (ri, rt) = -- Helper function: check if a 'NamedComponent' matches the given 'ComponentName' isCompNamed :: ComponentName -> NamedComponent -> Bool isCompNamed _ CLib = False + isCompNamed t1 (CInternalLib t2) = t1 == t2 isCompNamed t1 (CExe t2) = t1 == t2 isCompNamed t1 (CTest t2) = t1 == t2 isCompNamed t1 (CBench t2) = t1 == t2 diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 06f8c13f4a..0a29c372c4 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -520,6 +520,7 @@ figureOutMainFile bopts mainIsTargets targets0 packages = do renderComp c = case c of CLib -> "lib" + CInternalLib name -> "internal-lib:" <> name CExe name -> "exe:" <> name CTest name -> "test:" <> name CBench name -> "bench:" <> name diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs index 8d0fa92fd8..45c6f80b39 100644 --- a/src/Stack/Package.hs +++ b/src/Stack/Package.hs @@ -43,6 +43,7 @@ module Stack.Package import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as C8 import Data.List (isSuffixOf, isPrefixOf) +import Data.Maybe (fromJust) import qualified Data.Map.Strict as M import qualified Data.Set as S import qualified Data.Text as T @@ -580,6 +581,7 @@ fileGenDirFromComponentName fileGenDirFromComponentName namedComponent = case namedComponent of CLib -> return id + CInternalLib name -> makeTmp name CExe name -> makeTmp name CTest name -> makeTmp name CBench name -> makeTmp name @@ -683,6 +685,12 @@ packageDescModulesAndFiles pkg = do (return (M.empty, M.empty, [])) (asModuleAndFileMap libComponent libraryFiles) (library pkg) + (subLibrariesMods,subLibDotCabalFiles,subLibWarnings) <- + liftM + foldTuples + (mapM + (asModuleAndFileMap internalLibComponent libraryFiles) + (subLibraries pkg)) (executableMods,exeDotCabalFiles,exeWarnings) <- liftM foldTuples @@ -710,6 +718,7 @@ packageDescModulesAndFiles pkg = do return (modules, files, dfiles, warnings) where libComponent = const CLib + internalLibComponent = CInternalLib . T.pack . Cabal.unUnqualComponentName . fromJust . libName exeComponent = CExe . T.pack . Cabal.unUnqualComponentName . exeName testComponent = CTest . T.pack . Cabal.unUnqualComponentName . testName benchComponent = CBench . T.pack . Cabal.unUnqualComponentName . benchmarkName diff --git a/src/Stack/Types/NamedComponent.hs b/src/Stack/Types/NamedComponent.hs index 1199727d03..514aea6b44 100644 --- a/src/Stack/Types/NamedComponent.hs +++ b/src/Stack/Types/NamedComponent.hs @@ -24,6 +24,7 @@ import Data.Text.Encoding (encodeUtf8, decodeUtf8) -- | A single, fully resolved component of a package data NamedComponent = CLib + | CInternalLib !Text | CExe !Text | CTest !Text | CBench !Text @@ -31,6 +32,7 @@ data NamedComponent renderComponent :: NamedComponent -> ByteString renderComponent CLib = "lib" +renderComponent (CInternalLib x) = "internal-lib:" <> encodeUtf8 x renderComponent (CExe x) = "exe:" <> encodeUtf8 x renderComponent (CTest x) = "test:" <> encodeUtf8 x renderComponent (CBench x) = "bench:" <> encodeUtf8 x From 95348b9998b17e641fbfa4f5def1ae4645456442 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Thu, 5 Apr 2018 21:14:13 -0700 Subject: [PATCH 02/13] Propagate the sub-lib components. --- src/Stack/Package.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs index 45c6f80b39..5a3a333bef 100644 --- a/src/Stack/Package.hs +++ b/src/Stack/Package.hs @@ -710,11 +710,11 @@ packageDescModulesAndFiles pkg = do dfiles <- resolveGlobFiles (extraSrcFiles pkg ++ map (dataDir pkg FilePath.) (dataFiles pkg)) - let modules = libraryMods <> executableMods <> testMods <> benchModules + let modules = libraryMods <> subLibrariesMods <> executableMods <> testMods <> benchModules files = - libDotCabalFiles <> exeDotCabalFiles <> testDotCabalFiles <> + libDotCabalFiles <> subLibDotCabalFiles <> exeDotCabalFiles <> testDotCabalFiles <> benchDotCabalPaths - warnings = libWarnings <> exeWarnings <> testWarnings <> benchWarnings + warnings = libWarnings <> subLibWarnings <> exeWarnings <> testWarnings <> benchWarnings return (modules, files, dfiles, warnings) where libComponent = const CLib From b008a33b4f9499bc63ccb81f1df9441d3933494c Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Thu, 5 Apr 2018 21:15:06 -0700 Subject: [PATCH 03/13] Make sure sublibs are transfered from `getPackageFileForTargets`. --- src/Stack/Build/Source.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Stack/Build/Source.hs b/src/Stack/Build/Source.hs index 9917fdd6b8..8a268617bb 100644 --- a/src/Stack/Build/Source.hs +++ b/src/Stack/Build/Source.hs @@ -435,9 +435,9 @@ getPackageFilesForTargets -> Set NamedComponent -> RIO env (Map NamedComponent (Set (Path Abs File)), [PackageWarning]) getPackageFilesForTargets pkg cabalFP nonLibComponents = do - (_,compFiles,otherFiles,warnings) <- + (components',compFiles,otherFiles,warnings) <- getPackageFiles (packageFiles pkg) cabalFP - let components = Set.insert CLib nonLibComponents + let components = M.keysSet components' `Set.union` nonLibComponents componentsFiles = M.map (\files -> Set.union otherFiles (Set.map dotCabalGetPath files)) $ M.filterWithKey (\component _ -> component `Set.member` components) compFiles From abd2172ba377973ffab0e0ad92153dd4261e9378 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Fri, 6 Apr 2018 10:40:05 -0700 Subject: [PATCH 04/13] Extract checking validity of a package found in sourceMap to a where clause to be reused next --- src/Stack/Build/Installed.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Stack/Build/Installed.hs b/src/Stack/Build/Installed.hs index e73552f347..6ed5bf9beb 100644 --- a/src/Stack/Build/Installed.hs +++ b/src/Stack/Build/Installed.hs @@ -239,16 +239,18 @@ isAllowed opts mcache sourceMap mloc dp -- See: -- https://github.com/commercialhaskell/stack/issues/292 Just _ -> UnknownPkg - Just pii - | not (checkLocation (piiLocation pii)) -> WrongLocation mloc (piiLocation pii) - | version /= piiVersion pii -> WrongVersion version (piiVersion pii) - | otherwise -> Allowed + Just pii -> checkFound pii where PackageIdentifier name version = dpPackageIdent dp -- Ensure that the installed location matches where the sourceMap says it -- should be installed checkLocation Snap = mloc /= Just (InstalledTo Local) -- we can allow either global or snap checkLocation Local = mloc == Just (InstalledTo Local) || mloc == Just ExtraGlobal -- 'locally' installed snapshot packages can come from extra dbs + -- Check if a package is allowed if it is found in the sourceMap + checkFound pii + | not (checkLocation (piiLocation pii)) = WrongLocation mloc (piiLocation pii) + | version /= piiVersion pii = WrongVersion version (piiVersion pii) + | otherwise = Allowed data LoadHelper = LoadHelper { lhId :: !GhcPkgId From 4903a511df29752ac0ce3e62e19b4c7f016696fe Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Fri, 6 Apr 2018 10:41:10 -0700 Subject: [PATCH 05/13] Extract checking validity of a package not found in sourceMap to a where clause to be reused next --- src/Stack/Build/Installed.hs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Stack/Build/Installed.hs b/src/Stack/Build/Installed.hs index 6ed5bf9beb..2450a2282c 100644 --- a/src/Stack/Build/Installed.hs +++ b/src/Stack/Build/Installed.hs @@ -229,16 +229,7 @@ isAllowed opts mcache sourceMap mloc dp | getInstalledSymbols opts && isJust mcache && not (dpSymbols dp) = NeedsSymbols | otherwise = case Map.lookup name sourceMap of - Nothing -> - case mloc of - -- The sourceMap has nothing to say about this global - -- package, so we can use it - Nothing -> Allowed - Just ExtraGlobal -> Allowed - -- For non-global packages, don't include unknown packages. - -- See: - -- https://github.com/commercialhaskell/stack/issues/292 - Just _ -> UnknownPkg + Nothing -> checkNotFound Just pii -> checkFound pii where PackageIdentifier name version = dpPackageIdent dp @@ -251,6 +242,14 @@ isAllowed opts mcache sourceMap mloc dp | not (checkLocation (piiLocation pii)) = WrongLocation mloc (piiLocation pii) | version /= piiVersion pii = WrongVersion version (piiVersion pii) | otherwise = Allowed + -- check if a package is allowed if it is not found in the sourceMap + checkNotFound = case mloc of + -- The sourceMap has nothing to say about this global package, so we can use it + Nothing -> Allowed + Just ExtraGlobal -> Allowed + -- For non-global packages, don't include unknown packages. + -- See: https://github.com/commercialhaskell/stack/issues/292 + Just _ -> UnknownPkg data LoadHelper = LoadHelper { lhId :: !GhcPkgId From b201556d476c5abc0f7377a8ff2286eb62f1e986 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Fri, 6 Apr 2018 10:42:03 -0700 Subject: [PATCH 06/13] Parse the parent package info for sublibraries from the output of ghc-pkg. --- src/Stack/PackageDump.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Stack/PackageDump.hs b/src/Stack/PackageDump.hs index 9549e1b50d..31fc5da7fb 100644 --- a/src/Stack/PackageDump.hs +++ b/src/Stack/PackageDump.hs @@ -282,6 +282,7 @@ hasDebuggingSymbols dir lib = do data DumpPackage profiling haddock symbols = DumpPackage { dpGhcPkgId :: !GhcPkgId , dpPackageIdent :: !PackageIdentifier + , dpParentLibIdent :: !(Maybe PackageIdentifier) , dpLicense :: !(Maybe C.License) , dpLibDirs :: ![FilePath] , dpLibraries :: ![Text] @@ -356,6 +357,11 @@ conduitDumpPackage = (.| CL.catMaybes) $ eachSection $ do _ -> Nothing depends <- mapMaybeM parseDepend $ concatMap T.words $ parseM "depends" + -- Handle sublibs by recording the name of the parent library + -- If name of parent library is missing, this is not a sublib. + let mkParentLib n = PackageIdentifier n version + parentLib = mkParentLib <$> (parseS "package-name" >>= parsePackageName) + let parseQuoted key = case mapM (P.parseOnly (argsParser NoEscaping)) val of Left{} -> throwM (Couldn'tParseField key val) @@ -369,6 +375,7 @@ conduitDumpPackage = (.| CL.catMaybes) $ eachSection $ do return $ Just DumpPackage { dpGhcPkgId = ghcPkgId , dpPackageIdent = PackageIdentifier name version + , dpParentLibIdent = parentLib , dpLicense = license , dpLibDirs = libDirPaths , dpLibraries = T.words $ T.unwords libraries From d8c08f4f290b53519cb351ba1efdebe98f9e799d Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Fri, 6 Apr 2018 10:42:37 -0700 Subject: [PATCH 07/13] Properly handle sublibraries and make sure they are not ignored and rebuild. --- src/Stack/Build/Installed.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Stack/Build/Installed.hs b/src/Stack/Build/Installed.hs index 2450a2282c..0805ce50fc 100644 --- a/src/Stack/Build/Installed.hs +++ b/src/Stack/Build/Installed.hs @@ -229,7 +229,18 @@ isAllowed opts mcache sourceMap mloc dp | getInstalledSymbols opts && isJust mcache && not (dpSymbols dp) = NeedsSymbols | otherwise = case Map.lookup name sourceMap of - Nothing -> checkNotFound + Nothing -> + -- If the sourceMap has nothing to say about this package, + -- check if it represents a sublibrary first + -- See: https://github.com/commercialhaskell/stack/issues/3899 + case dpParentLibIdent dp of + Just (PackageIdentifier parentLibName version') -> + case Map.lookup parentLibName sourceMap of + Nothing -> checkNotFound + Just pii + | version' == version -> checkFound pii + | otherwise -> checkNotFound -- different versions + Nothing -> checkNotFound Just pii -> checkFound pii where PackageIdentifier name version = dpPackageIdent dp From 26f6b5e2f6bae072b9537f4926b388ae736257da Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Fri, 6 Apr 2018 11:01:56 -0700 Subject: [PATCH 08/13] Update ChangeLog.md --- ChangeLog.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 80a7f5bf6c..bd9a3797d6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -52,7 +52,9 @@ Other enhancements: Bug fixes: - +* When a package contained sublibraries, stack was always recompiling the + package. This has been fixed now, no recompilation is being done because of + sublibraries. See [#3899](https://github.com/commercialhaskell/stack/issues/3899). ## v1.6.5 From e23a34ff62e5cc8371cac3787845488602f6131b Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Fri, 6 Apr 2018 11:10:40 -0700 Subject: [PATCH 09/13] Update broken tests --- src/test/Stack/PackageDumpSpec.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/Stack/PackageDumpSpec.hs b/src/test/Stack/PackageDumpSpec.hs index 12c95b0873..69e99a164a 100644 --- a/src/test/Stack/PackageDumpSpec.hs +++ b/src/test/Stack/PackageDumpSpec.hs @@ -81,6 +81,7 @@ spec = do haskell2010 { dpExposedModules = [] } `shouldBe` DumpPackage { dpGhcPkgId = ghcPkgId , dpPackageIdent = packageIdent + , dpParentLibIdent = Nothing , dpLicense = Just BSD3 , dpLibDirs = ["/opt/ghc/7.8.4/lib/ghc-7.8.4/haskell2010-1.1.2.0"] , dpDepends = depends @@ -124,6 +125,7 @@ spec = do haskell2010 { dpExposedModules = [] } `shouldBe` DumpPackage { dpGhcPkgId = ghcPkgId , dpPackageIdent = pkgIdent + , dpParentLibIdent = Nothing , dpLicense = Just BSD3 , dpLibDirs = ["/opt/ghc/7.10.1/lib/ghc-7.10.1/ghc_EMlWrQ42XY0BNVbSrKixqY"] , dpHaddockInterfaces = ["/opt/ghc/7.10.1/share/doc/ghc/html/libraries/ghc-7.10.1/ghc.haddock"] @@ -160,6 +162,7 @@ spec = do hmatrix `shouldBe` DumpPackage { dpGhcPkgId = ghcPkgId , dpPackageIdent = pkgId + , dpParentLibIdent = Nothing , dpLicense = Just BSD3 , dpLibDirs = [ "/Users/alexbiehl/.stack/snapshots/x86_64-osx/lts-2.13/7.8.4/lib/x86_64-osx-ghc-7.8.4/hmatrix-0.16.1.5" @@ -197,6 +200,7 @@ spec = do ghcBoot `shouldBe` DumpPackage { dpGhcPkgId = ghcPkgId , dpPackageIdent = pkgId + , dpParentLibIdent = Nothing , dpLicense = Just BSD3 , dpLibDirs = ["/opt/ghc/head/lib/ghc-7.11.20151213/ghc-boot-0.0.0.0"] From 7f79d84b4a6aaf4b35592110092512859f9d2bd9 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Tue, 10 Apr 2018 08:31:39 -0700 Subject: [PATCH 10/13] Add missing case pattern after rebase. --- src/Stack/Package.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs index aae0a0686d..4188456cba 100644 --- a/src/Stack/Package.hs +++ b/src/Stack/Package.hs @@ -590,6 +590,7 @@ componentBuildDir cabalVer component distDir | otherwise = case component of CLib -> buildDir distDir + CInternalLib name -> buildDir distDir componentNameToDir name CExe name -> buildDir distDir componentNameToDir name CTest name -> buildDir distDir componentNameToDir name CBench name -> buildDir distDir componentNameToDir name From f4d9faca1dbb710a6edea54836959379e50e0548 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Mon, 16 Apr 2018 06:52:34 -0700 Subject: [PATCH 11/13] Solve merge conflict --- ChangeLog.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 158cbc02ac..5f7927fdfd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -12,6 +12,9 @@ Behavior changes: Other enhancements: Bug fixes: +* When a package contained sublibraries, stack was always recompiling the + package. This has been fixed now, no recompilation is being done because of + sublibraries. See [#3899](https://github.com/commercialhaskell/stack/issues/3899). ## v1.7.0.1 (releases candidate) @@ -64,16 +67,7 @@ Other enhancements: * Improved error messages for snapshot parse exceptions Bug fixes: -* When a package contained sublibraries, stack was always recompiling the - package. This has been fixed now, no recompilation is being done because of - sublibraries. See [#3899](https://github.com/commercialhaskell/stack/issues/3899). -## v1.6.5 - -Bug fixes: -* 1.6.1 introduced a change that made some precompiled cache files use - longer paths, sometimes causing builds to fail on windows. This has been - fixed. See [#3649](https://github.com/commercialhaskell/stack/issues/3649) * The script interpreter's implicit file arguments are now passed before other arguments. See [#3658](https://github.com/commercialhaskell/stack/issues/3658). In particular, this makes it possible to pass `-- +RTS ... -RTS` to specify From 1037447b4424afdad8c4f11c10d1c108c8274d85 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Mon, 16 Apr 2018 19:19:22 -0700 Subject: [PATCH 12/13] Don't use fromJust, prefer empty name of internal library instead --- src/Stack/Package.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs index 4188456cba..17776eaee2 100644 --- a/src/Stack/Package.hs +++ b/src/Stack/Package.hs @@ -42,7 +42,7 @@ module Stack.Package import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as C8 import Data.List (isSuffixOf, isPrefixOf) -import Data.Maybe (fromJust) +import Data.Maybe (maybe) import qualified Data.Map.Strict as M import qualified Data.Set as S import qualified Data.Text as T @@ -736,7 +736,7 @@ packageDescModulesAndFiles pkg = do return (modules, files, dfiles, warnings) where libComponent = const CLib - internalLibComponent = CInternalLib . T.pack . Cabal.unUnqualComponentName . fromJust . libName + internalLibComponent = CInternalLib . T.pack . maybe "" Cabal.unUnqualComponentName . libName exeComponent = CExe . T.pack . Cabal.unUnqualComponentName . exeName testComponent = CTest . T.pack . Cabal.unUnqualComponentName . testName benchComponent = CBench . T.pack . Cabal.unUnqualComponentName . benchmarkName From 78f3998331409b7891f2df2120436b44c197681d Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Mon, 16 Apr 2018 20:41:25 -0700 Subject: [PATCH 13/13] Add integration test --- .../3899-dont-rebuild-sublibraries/Main.hs | 14 ++++++++++++ .../files/Setup.hs | 2 ++ .../files/files.cabal | 22 +++++++++++++++++++ .../files/src-exe/Main.hs | 7 ++++++ .../files/src-internal/Internal.hs | 1 + .../files/src/Lib.hs | 3 +++ .../files/stack.yaml | 4 ++++ 7 files changed, 53 insertions(+) create mode 100644 test/integration/tests/3899-dont-rebuild-sublibraries/Main.hs create mode 100644 test/integration/tests/3899-dont-rebuild-sublibraries/files/Setup.hs create mode 100644 test/integration/tests/3899-dont-rebuild-sublibraries/files/files.cabal create mode 100644 test/integration/tests/3899-dont-rebuild-sublibraries/files/src-exe/Main.hs create mode 100644 test/integration/tests/3899-dont-rebuild-sublibraries/files/src-internal/Internal.hs create mode 100644 test/integration/tests/3899-dont-rebuild-sublibraries/files/src/Lib.hs create mode 100644 test/integration/tests/3899-dont-rebuild-sublibraries/files/stack.yaml diff --git a/test/integration/tests/3899-dont-rebuild-sublibraries/Main.hs b/test/integration/tests/3899-dont-rebuild-sublibraries/Main.hs new file mode 100644 index 0000000000..fa6835ebe7 --- /dev/null +++ b/test/integration/tests/3899-dont-rebuild-sublibraries/Main.hs @@ -0,0 +1,14 @@ +import Control.Monad (unless) +import Data.List (isInfixOf) +import StackTest + +main :: IO () +main = do + stack ["clean"] + stack ["build"] + res <- compilingModulesLines . snd <$> stackStderr ["build"] + unless (null res) $ fail "Stack recompiled code" + +-- Returns the lines where a module is compiled +compilingModulesLines :: String -> [String] +compilingModulesLines = filter (isInfixOf " Compiling ") . lines diff --git a/test/integration/tests/3899-dont-rebuild-sublibraries/files/Setup.hs b/test/integration/tests/3899-dont-rebuild-sublibraries/files/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/test/integration/tests/3899-dont-rebuild-sublibraries/files/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/test/integration/tests/3899-dont-rebuild-sublibraries/files/files.cabal b/test/integration/tests/3899-dont-rebuild-sublibraries/files/files.cabal new file mode 100644 index 0000000000..867797cb7b --- /dev/null +++ b/test/integration/tests/3899-dont-rebuild-sublibraries/files/files.cabal @@ -0,0 +1,22 @@ +name: files +version: 0.1.0.0 +build-type: Simple +cabal-version: >= 2.0 + +library + hs-source-dirs: src + exposed-modules: Lib + build-depends: base, lib + default-language: Haskell2010 + +library lib + hs-source-dirs: src-internal + exposed-modules: Internal + build-depends: base + default-language: Haskell2010 + +executable exe + hs-source-dirs: src-exe + main-is: Main.hs + build-depends: base, files + default-language: Haskell2010 diff --git a/test/integration/tests/3899-dont-rebuild-sublibraries/files/src-exe/Main.hs b/test/integration/tests/3899-dont-rebuild-sublibraries/files/src-exe/Main.hs new file mode 100644 index 0000000000..cafae24793 --- /dev/null +++ b/test/integration/tests/3899-dont-rebuild-sublibraries/files/src-exe/Main.hs @@ -0,0 +1,7 @@ +module Main where + +import Lib + +main :: IO () +main = do + putStrLn "hello world" diff --git a/test/integration/tests/3899-dont-rebuild-sublibraries/files/src-internal/Internal.hs b/test/integration/tests/3899-dont-rebuild-sublibraries/files/src-internal/Internal.hs new file mode 100644 index 0000000000..d066bb085e --- /dev/null +++ b/test/integration/tests/3899-dont-rebuild-sublibraries/files/src-internal/Internal.hs @@ -0,0 +1 @@ +module Internal where diff --git a/test/integration/tests/3899-dont-rebuild-sublibraries/files/src/Lib.hs b/test/integration/tests/3899-dont-rebuild-sublibraries/files/src/Lib.hs new file mode 100644 index 0000000000..1369151610 --- /dev/null +++ b/test/integration/tests/3899-dont-rebuild-sublibraries/files/src/Lib.hs @@ -0,0 +1,3 @@ +module Lib where + +import Internal diff --git a/test/integration/tests/3899-dont-rebuild-sublibraries/files/stack.yaml b/test/integration/tests/3899-dont-rebuild-sublibraries/files/stack.yaml new file mode 100644 index 0000000000..df13716817 --- /dev/null +++ b/test/integration/tests/3899-dont-rebuild-sublibraries/files/stack.yaml @@ -0,0 +1,4 @@ +resolver: ghc-8.2.2 +extra-deps: +- stm-2.4.4.1 +- mtl-2.2.1