From a65efc2566dd4aa60380da8c03b878131095eea3 Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Sun, 18 Nov 2018 15:14:27 +0100 Subject: Include package.yaml in Unit modification times for Stack projects --- lib/Distribution/Helper.hs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'lib/Distribution/Helper.hs') diff --git a/lib/Distribution/Helper.hs b/lib/Distribution/Helper.hs index 0c2fddb..fb6fb7a 100644 --- a/lib/Distribution/Helper.hs +++ b/lib/Distribution/Helper.hs @@ -213,15 +213,22 @@ getUnitModTimes Unit { uDistDir=DistDirLib distdirv1 , uCabalFile=CabalFile cabal_file_path + , uPackageDir + , uImpl } = do - cabal_file_mtime <- getFileModTime cabal_file_path - let setup_config = distdirv1 "setup-config" - setup_config_mtime <- (traverse getFileModTime <=< mightExist) setup_config - return UnitModTimes - { umtCabalFile = cabal_file_mtime - , umtSetupConfig = setup_config_mtime - } + umtPkgYaml <- + case uImpl of + UnitImplStack{} + -> traverse getFileModTime =<< mightExist package_yaml_path + _ -> return Nothing + umtCabalFile <- getFileModTime cabal_file_path + umtSetupConfig <- (traverse getFileModTime <=< mightExist) setup_config_path + return UnitModTimes {..} + where + package_yaml_path = uPackageDir "package.yaml" + setup_config_path = distdirv1 "setup-config" + -- | The version of GHC the project is configured to use compilerVersion :: Query pt (String, Version) @@ -326,9 +333,10 @@ shallowReconfigureProject QueryEnv ["new-build", "--dry-run", "all"] "" return () shallowReconfigureProject QueryEnv - { qeProjLoc = ProjLocStackDir _projdir, .. } = - -- TODO: do we need to do anything here? Maybe package.yaml support needs to - -- do stuff here? + { qeProjLoc = ProjLocStackDir projdir, .. } = do + -- -- In case we ever need to read the cabal files before the Unit stage, this command regenerates them from package.yaml + -- _ <- liftIO $ qeReadProcess (Just projdir) (stackProgram qePrograms) + -- ["build", "--dry-run"] "" return () reconfigureUnit :: QueryEnvI c pt -> Unit pt -> IO () -- cgit v1.2.3