11-------------------------------------------------------------------------------
22-------------------------------------------------------------------------------
33{-# LANGUAGE RecordWildCards #-}
4+ {-# OPTIONS_GHC -Wno-unused-imports #-}
5+ {-# OPTIONS_GHC -Wno-unused-matches #-}
6+ {-# OPTIONS_GHC -Wno-unused-local-binds #-}
47
58-- |
69-- Module : Distribution.Client.Exec
@@ -45,8 +48,8 @@ import Distribution.Client.ProjectOrchestration
4548 )
4649import Distribution.Client.ProjectPlanOutput
4750 ( PostBuildProjectStatus
48- , argsEquivalentOfGhcEnvironmentFile
49- , createPackageEnvironment
51+ -- , argsEquivalentOfGhcEnvironmentFile
52+ -- , createPackageEnvironment
5053 , updatePostBuildProjectStatus
5154 )
5255import Distribution.Client.ProjectPlanning
@@ -55,7 +58,8 @@ import Distribution.Client.ProjectPlanning
5558 )
5659import qualified Distribution.Client.ProjectPlanning as Planning
5760import Distribution.Client.ProjectPlanning.Types
58- ( dataDirsEnvironmentForPlan
61+ ( Toolchain (.. )
62+ , dataDirsEnvironmentForPlan
5963 )
6064import Distribution.Client.Setup
6165 ( ConfigFlags (configCommonFlags )
@@ -108,6 +112,7 @@ import Prelude ()
108112import qualified Data.Map as M
109113import qualified Data.Set as S
110114import Distribution.Client.Errors
115+ import Distribution.Solver.Types.Stage
111116
112117execCommand :: CommandUI (NixStyleFlags () )
113118execCommand =
@@ -170,7 +175,9 @@ execAction flags@NixStyleFlags{..} extraArgs globalFlags = do
170175
171176 -- Some dependencies may have executables. Let's put those on the PATH.
172177 let extraPaths = pathAdditions baseCtx buildCtx
173- pkgProgs = pkgConfigCompilerProgs (elaboratedShared buildCtx)
178+ -- NOTE: only build-stage dependencies make sense here
179+ pkgProgs = toolchainProgramDb $ getStage (pkgConfigToolchains (elaboratedShared buildCtx)) Build
180+ --
174181 extraEnvVars =
175182 dataDirsEnvironmentForPlan
176183 (distDirLayout baseCtx)
@@ -179,53 +186,57 @@ execAction flags@NixStyleFlags{..} extraArgs globalFlags = do
179186 programDb <-
180187 prependProgramSearchPath verbosity extraPaths extraEnvVars pkgProgs
181188
182- -- Now that we have the packages, set up the environment. We accomplish this
183- -- by creating an environment file that selects the databases and packages we
184- -- computed in the previous step, and setting an environment variable to
185- -- point at the file.
186- -- In case ghc is too old to support environment files,
187- -- we pass the same info as arguments
188- let compiler = pkgConfigCompiler $ elaboratedShared buildCtx
189- envFilesSupported = supportsPkgEnvFiles (getImplInfo compiler)
190- case extraArgs of
191- [] -> dieWithException verbosity SpecifyAnExecutable
192- exe : args -> do
193- (program, _) <- requireProgram verbosity (simpleProgram exe) programDb
194- let argOverrides =
195- argsEquivalentOfGhcEnvironmentFile
196- compiler
197- (distDirLayout baseCtx)
198- (elaboratedPlanOriginal buildCtx)
199- buildStatus
200- programIsConfiguredCompiler =
201- matchCompilerPath
202- (elaboratedShared buildCtx)
203- program
204- argOverrides' =
205- if envFilesSupported
206- || not programIsConfiguredCompiler
207- then []
208- else argOverrides
189+ -- TODO
190+ error " Not implemented"
191+ where
192+ -- -- Now that we have the packages, set up the environment. We accomplish this
193+ -- -- by creating an environment file that selects the databases and packages we
194+ -- -- computed in the previous step, and setting an environment variable to
195+ -- -- point at the file.
196+ -- -- In case ghc is too old to support environment files,
197+ -- -- we pass the same info as arguments
198+ -- -- let compiler = toolchainCompiler $ buildToolchain $ pkgConfigToolchains $ elaboratedShared buildCtx
199+ -- -- envFilesSupported = supportsPkgEnvFiles (getImplInfo compiler)
200+ -- case extraArgs of
201+ -- [] -> dieWithException verbosity SpecifyAnExecutable
202+ -- exe : args -> do
203+ -- (program, _) <- requireProgram verbosity (simpleProgram exe) programDb
204+ -- let
205+ -- -- argOverrides =
206+ -- -- argsEquivalentOfGhcEnvironmentFile
207+ -- -- compiler
208+ -- -- (distDirLayout baseCtx)
209+ -- -- (elaboratedPlanOriginal buildCtx)
210+ -- -- buildStatus
211+ -- programIsConfiguredCompiler =
212+ -- matchCompilerPath
213+ -- (elaboratedShared buildCtx)
214+ -- program
215+ -- -- argOverrides' =
216+ -- -- if envFilesSupported
217+ -- -- || not programIsConfiguredCompiler
218+ -- -- then []
219+ -- -- else argOverrides
209220
210- ( if envFilesSupported
211- then withTempEnvFile verbosity baseCtx buildCtx buildStatus
212- else \ f -> f []
213- )
214- $ \ envOverrides -> do
215- let program' =
216- withOverrides
217- envOverrides
218- argOverrides'
219- program
220- invocation = programInvocation program' args
221- dryRun =
222- buildSettingDryRun (buildSettings baseCtx)
223- || buildSettingOnlyDownload (buildSettings baseCtx)
221+ -- -- ( if envFilesSupported
222+ -- -- then withTempEnvFile verbosity baseCtx buildCtx buildStatus
223+ -- -- else \f -> f []
224+ -- -- )
225+ -- -- $ \envOverrides -> do
226+ -- -- let program' =
227+ -- -- withOverrides
228+ -- -- envOverrides
229+ -- -- argOverrides'
230+ -- -- program
231+ -- -- invocation = programInvocation program' args
232+ -- -- dryRun =
233+ -- -- buildSettingDryRun (buildSettings baseCtx)
234+ -- -- || buildSettingOnlyDownload (buildSettings baseCtx)
235+
236+ -- -- if dryRun
237+ -- -- then notice verbosity "Running of executable suppressed by flag(s)"
238+ -- -- else runProgramInvocation verbosity invocation
224239
225- if dryRun
226- then notice verbosity " Running of executable suppressed by flag(s)"
227- else runProgramInvocation verbosity invocation
228- where
229240 verbosity = fromFlagOrDefault normal (setupVerbosity $ configCommonFlags configFlags)
230241 cliConfig =
231242 commandLineFlagsToProjectConfig
@@ -238,40 +249,40 @@ execAction flags@NixStyleFlags{..} extraArgs globalFlags = do
238249 , programDefaultArgs = programDefaultArgs program ++ args
239250 }
240251
241- matchCompilerPath :: ElaboratedSharedConfig -> ConfiguredProgram -> Bool
242- matchCompilerPath elaboratedShared program =
243- programPath program
244- `elem` (programPath <$> configuredCompilers)
245- where
246- configuredCompilers = configuredPrograms $ pkgConfigCompilerProgs elaboratedShared
252+ -- matchCompilerPath :: ElaboratedSharedConfig -> ConfiguredProgram -> Bool
253+ -- matchCompilerPath elaboratedShared program =
254+ -- programPath program
255+ -- `elem` (programPath <$> configuredCompilers)
256+ -- where
257+ -- configuredCompilers = configuredPrograms $ toolchainProgramDb $ buildToolchain $ pkgConfigToolchains elaboratedShared
247258
248- -- | Execute an action with a temporary .ghc.environment file reflecting the
249- -- current environment. The action takes an environment containing the env
250- -- variable which points ghc to the file.
251- withTempEnvFile
252- :: Verbosity
253- -> ProjectBaseContext
254- -> ProjectBuildContext
255- -> PostBuildProjectStatus
256- -> ([(String , Maybe String )] -> IO a )
257- -> IO a
258- withTempEnvFile verbosity baseCtx buildCtx buildStatus action = do
259- let tmpDirTemplate = distTempDirectory (distDirLayout baseCtx)
260- createDirectoryIfMissingVerbose verbosity True tmpDirTemplate
261- withTempDirectory
262- verbosity
263- tmpDirTemplate
264- " environment."
265- ( \ tmpDir -> do
266- envOverrides <-
267- createPackageEnvironment
268- verbosity
269- tmpDir
270- (elaboratedPlanToExecute buildCtx)
271- (elaboratedShared buildCtx)
272- buildStatus
273- action envOverrides
274- )
259+ -- -- | Execute an action with a temporary .ghc.environment file reflecting the
260+ -- -- current environment. The action takes an environment containing the env
261+ -- -- variable which points ghc to the file.
262+ -- withTempEnvFile
263+ -- :: Verbosity
264+ -- -> ProjectBaseContext
265+ -- -> ProjectBuildContext
266+ -- -> PostBuildProjectStatus
267+ -- -> ([(String, Maybe String)] -> IO a)
268+ -- -> IO a
269+ -- withTempEnvFile verbosity baseCtx buildCtx buildStatus action = do
270+ -- let tmpDirTemplate = distTempDirectory (distDirLayout baseCtx)
271+ -- createDirectoryIfMissingVerbose verbosity True tmpDirTemplate
272+ -- withTempDirectory
273+ -- verbosity
274+ -- tmpDirTemplate
275+ -- "environment."
276+ -- ( \tmpDir -> do
277+ -- envOverrides <-
278+ -- createPackageEnvironment
279+ -- verbosity
280+ -- tmpDir
281+ -- (elaboratedPlanToExecute buildCtx)
282+ -- (elaboratedShared buildCtx)
283+ -- buildStatus
284+ -- action envOverrides
285+ -- )
275286
276287-- | Get paths to all dependency executables to be included in PATH.
277288pathAdditions :: ProjectBaseContext -> ProjectBuildContext -> [FilePath ]
0 commit comments