Skip to content

Instantly share code, notes, and snippets.

@fendor
Created April 11, 2019 17:05
Show Gist options
  • Save fendor/7403d5815f4fc30b4d946bab2d10069e to your computer and use it in GitHub Desktop.
Save fendor/7403d5815f4fc30b4d946bab2d10069e to your computer and use it in GitHub Desktop.
-- Pretty nasty piecemeal out of json, but I can't see a way to retrieve output of the setupWrapper'd tasks
showTargets :: Verbosity -> ProjectBaseContext -> ProjectBuildContext -> Lock -> IO ()
showTargets verbosity baseCtx buildCtx lock = do
putStr "["
mapM_ doShowInfo targets
putStrLn "]"
where configured = [p | InstallPlan.Configured p <- InstallPlan.toList (elaboratedPlanOriginal buildCtx)]
targets = fst <$> (Map.toList . targetsMap $ buildCtx)
doShowInfo unitId = showInfo verbosity baseCtx buildCtx lock configured unitId
showInfo :: Verbosity -> ProjectBaseContext -> ProjectBuildContext -> Lock -> [ElaboratedConfiguredPackage] -> UnitId -> IO ()
showInfo verbosity baseCtx buildCtx lock pkgs targetUnitId
| Nothing <- mbPkg = die' verbosity $ "No unit " ++ show targetUnitId
| Just pkg <- mbPkg = do
let shared = elaboratedShared buildCtx
install = elaboratedPlanOriginal buildCtx
dirLayout = distDirLayout baseCtx
buildDir = distBuildDirectory dirLayout (elabDistDirParams shared pkg)
flags = setupHsBuildFlags pkg shared verbosity buildDir
args = setupHsBuildArgs pkg
srcDir = case (elabPkgSourceLocation pkg) of
LocalUnpackedPackage fp -> fp
_ -> ""
scriptOptions = setupHsScriptOptions
(ReadyPackage pkg)
install
shared
dirLayout
srcDir
buildDir
False
lock
configureFlags = setupHsConfigureFlags (ReadyPackage pkg) shared verbosity buildDir
configureArgs = setupHsConfigureArgs pkg
--Configure the package if there's no existing config
lbi <- tryGetPersistBuildConfig buildDir
case lbi of
Left _ -> setupWrapper
verbosity
scriptOptions
(Just $ elabPkgDescription pkg)
(Cabal.configureCommand defaultProgramDb)
(const configureFlags)
(const configureArgs)
Right _ -> pure ()
setupWrapper
verbosity
scriptOptions
(Just $ elabPkgDescription pkg)
(Cabal.showBuildInfoCommand defaultProgramDb)
(const flags)
(const args)
where mbPkg = find ((targetUnitId ==) . elabUnitId) pkgs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment