Skip to content

Commit

Permalink
Merge branch 'master' into fix/curl-transport-support-basic
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabedini authored Jun 17, 2024
2 parents 5fc9672 + e1f73a4 commit 36faf8b
Show file tree
Hide file tree
Showing 41 changed files with 627 additions and 201 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ jobs:
needs: validate
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, windows-latest]
# We only use one ghc version the used one for the next release (defined at top of the workflow)
# We need to build an array dynamically to inject the appropiate env var in a previous job,
# see https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson
Expand Down
1 change: 1 addition & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
- ignore: {name: "Use unwords"} # 8 hints
- ignore: {name: "Use void"} # 22 hints
- ignore: {name: "Use when"} # 1 hint
- ignore: {name: "Use uncurry"} # 1 hint

- arguments:
- --ignore-glob=Cabal-syntax/src/Distribution/Fields/Lexer.hs
Expand Down
3 changes: 2 additions & 1 deletion Cabal-syntax/src/Distribution/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ data CompilerFlavor
| LHC
| UHC
| Eta
| MHS -- MicroHS, see https://github.com/augustss/MicroHs
| HaskellSuite String -- string is the id of the actual compiler
| OtherCompiler String
deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)
Expand All @@ -85,7 +86,7 @@ instance NFData CompilerFlavor where rnf = genericRnf

knownCompilerFlavors :: [CompilerFlavor]
knownCompilerFlavors =
[GHC, GHCJS, NHC, YHC, Hugs, HBC, Helium, JHC, LHC, UHC, Eta]
[GHC, GHCJS, NHC, YHC, Hugs, HBC, Helium, JHC, LHC, UHC, Eta, MHS]

instance Pretty CompilerFlavor where
pretty (OtherCompiler name) = Disp.text name
Expand Down
8 changes: 4 additions & 4 deletions Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ md5Check proxy md5Int = structureHash proxy @?= md5FromInteger md5Int
md5CheckGenericPackageDescription :: Proxy GenericPackageDescription -> Assertion
md5CheckGenericPackageDescription proxy = md5Check proxy
#if MIN_VERSION_base(4,19,0)
0x4acd7857947385180d814f36dc1a759e
0x44f8430d7366cf849e09669627573040
#else
0x3ff3fa6c3c570bcafa10b457b1208cc8
0x8ed837568017bde3abb4fcee244b9c9f
#endif

md5CheckLocalBuildInfo :: Proxy LocalBuildInfo -> Assertion
md5CheckLocalBuildInfo proxy = md5Check proxy
#if MIN_VERSION_base(4,19,0)
0x552eca9ce2e4a34e74deff571f279fc4
0xdff58fe5e7f9568c67cd982eaba7edc2
#else
0x48497d6b3f15df06f1107b81b98febe1
0x4e50a4a95779b862edde3d6696797251
#endif
76 changes: 66 additions & 10 deletions Cabal/src/Distribution/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module Distribution.Simple
-- ** Standard sets of hooks
, simpleUserHooks
, autoconfUserHooks
, autoconfSetupHooks
, emptyUserHooks
) where

Expand Down Expand Up @@ -110,6 +111,7 @@ import Distribution.Simple.SetupHooks.Internal
)
import Distribution.Simple.Test
import Distribution.Simple.Utils
import qualified Distribution.Types.LocalBuildConfig as LBC
import Distribution.Utils.Path
import Distribution.Verbosity
import Distribution.Version
Expand Down Expand Up @@ -935,16 +937,11 @@ autoconfUserHooks =
let common = configCommonFlags flags
verbosity = fromFlag $ setupVerbosity common
mbWorkDir = flagToMaybe $ setupWorkingDir common
baseDir = packageRoot common
confExists <- doesFileExist $ baseDir </> "configure"
if confExists
then
runConfigureScript
verbosity
flags
lbi
else dieWithException verbosity ConfigureScriptNotFound

runConfigureScript
flags
(flagAssignment lbi)
(withPrograms lbi)
(hostPlatform lbi)
pbi <- getHookedBuildInfo verbosity mbWorkDir (buildDir lbi)
sanityCheckHookedBuildInfo verbosity pkg_descr pbi
let pkg_descr' = updatePackageDescription pbi pkg_descr
Expand Down Expand Up @@ -991,6 +988,65 @@ getHookedBuildInfo verbosity mbWorkDir build_dir = do
info verbosity $ "Reading parameters from " ++ getSymbolicPath infoFile
readHookedBuildInfo verbosity mbWorkDir infoFile

autoconfSetupHooks :: SetupHooks
autoconfSetupHooks =
SetupHooks.noSetupHooks
{ SetupHooks.configureHooks =
SetupHooks.noConfigureHooks
{ SetupHooks.postConfPackageHook = Just post_conf_pkg
, SetupHooks.preConfComponentHook = Just pre_conf_comp
}
}
where
post_conf_pkg
:: SetupHooks.PostConfPackageInputs
-> IO ()
post_conf_pkg
( SetupHooks.PostConfPackageInputs
{ SetupHooks.localBuildConfig =
LBC.LocalBuildConfig{LBC.withPrograms = progs}
, SetupHooks.packageBuildDescr =
LBC.PackageBuildDescr
{ LBC.configFlags = cfg
, LBC.flagAssignment = flags
, LBC.hostPlatform = plat
}
}
) = runConfigureScript cfg flags progs plat

pre_conf_comp
:: SetupHooks.PreConfComponentInputs
-> IO SetupHooks.PreConfComponentOutputs
pre_conf_comp
( SetupHooks.PreConfComponentInputs
{ SetupHooks.packageBuildDescr =
LBC.PackageBuildDescr
{ LBC.configFlags = cfg
, localPkgDescr = pkg_descr
}
, SetupHooks.component = component
}
) = do
let verbosity = fromFlag $ configVerbosity cfg
mbWorkDir = flagToMaybe $ configWorkingDir cfg
distPref = configDistPref cfg
dist_dir <- findDistPrefOrDefault distPref
-- Read the ".buildinfo" file and use that to update
-- the components (main library + executables only).
hbi <- getHookedBuildInfo verbosity mbWorkDir (dist_dir </> makeRelativePathEx "build")
sanityCheckHookedBuildInfo verbosity pkg_descr hbi
-- SetupHooks TODO: we are reading getHookedBuildInfo once
-- for each component. I think this is inherent to the SetupHooks
-- approach.
let comp_name = componentName component
diff <- case SetupHooks.hookedBuildInfoComponentDiff_maybe hbi comp_name of
Nothing -> return $ SetupHooks.emptyComponentDiff comp_name
Just do_diff -> do_diff
return $
SetupHooks.PreConfComponentOutputs
{ SetupHooks.componentDiff = diff
}

defaultTestHook
:: Args
-> PackageDescription
Expand Down
118 changes: 70 additions & 48 deletions Cabal/src/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2210,55 +2210,77 @@ configureRequiredProgram
verbosity
progdb
(LegacyExeDependency progName verRange) =
case lookupKnownProgram progName progdb of
Nothing ->
-- Try to configure it as a 'simpleProgram' automatically
--
-- There's a bit of a story behind this line. In old versions
-- of Cabal, there were only internal build-tools dependencies. So the
-- behavior in this case was:
--
-- - If a build-tool dependency was internal, don't do
-- any checking.
--
-- - If it was external, call 'configureRequiredProgram' to
-- "configure" the executable. In particular, if
-- the program was not "known" (present in 'ProgramDb'),
-- then we would just error. This was fine, because
-- the only way a program could be executed from 'ProgramDb'
-- is if some library code from Cabal actually called it,
-- and the pre-existing Cabal code only calls known
-- programs from 'defaultProgramDb', and so if it
-- is calling something else, you have a Custom setup
-- script, and in that case you are expected to register
-- the program you want to call in the ProgramDb.
--
-- OK, so that was fine, until I (ezyang, in 2016) refactored
-- Cabal to support per-component builds. In this case, what
-- was previously an internal build-tool dependency now became
-- an external one, and now previously "internal" dependencies
-- are now external. But these are permitted to exist even
-- when they are not previously configured (something that
-- can only occur by a Custom script.)
case lookupProgramByName progName progdb of
Just prog ->
-- If the program has already been configured, use it
-- (as long as the version is compatible).
--
-- So, I decided, "Fine, let's just accept these in any
-- case." Thus this line. The alternative would have been to
-- somehow detect when a build-tools dependency was "internal" (by
-- looking at the unflattened package description) but this
-- would also be incompatible with future work to support
-- external executable dependencies: we definitely cannot
-- assume they will be preinitialized in the 'ProgramDb'.
configureProgram verbosity (simpleProgram progName) progdb
Just prog
-- requireProgramVersion always requires the program have a version
-- but if the user says "build-depends: foo" ie no version constraint
-- then we should not fail if we cannot discover the program version.
| verRange == anyVersion -> do
(_, progdb') <- requireProgram verbosity prog progdb
return progdb'
| otherwise -> do
(_, _, progdb') <- requireProgramVersion verbosity prog verRange progdb
return progdb'
-- Not doing so means falling back to the "simpleProgram" path below,
-- which might fail if the program has custom logic to find a version
-- (such as hsc2hs).
let loc = locationPath $ programLocation prog
in case programVersion prog of
Nothing
| verRange == anyVersion ->
return progdb
| otherwise ->
dieWithException verbosity $!
UnknownVersionDb (programId prog) verRange loc
Just version
| withinRange version verRange ->
return progdb
| otherwise ->
dieWithException verbosity $!
BadVersionDb (programId prog) version verRange loc
Nothing ->
-- Otherwise, try to configure it as a 'simpleProgram' automatically
case lookupKnownProgram progName progdb of
Nothing ->
-- There's a bit of a story behind this line. In old versions
-- of Cabal, there were only internal build-tools dependencies. So the
-- behavior in this case was:
--
-- - If a build-tool dependency was internal, don't do
-- any checking.
--
-- - If it was external, call 'configureRequiredProgram' to
-- "configure" the executable. In particular, if
-- the program was not "known" (present in 'ProgramDb'),
-- then we would just error. This was fine, because
-- the only way a program could be executed from 'ProgramDb'
-- is if some library code from Cabal actually called it,
-- and the pre-existing Cabal code only calls known
-- programs from 'defaultProgramDb', and so if it
-- is calling something else, you have a Custom setup
-- script, and in that case you are expected to register
-- the program you want to call in the ProgramDb.
--
-- OK, so that was fine, until I (ezyang, in 2016) refactored
-- Cabal to support per-component builds. In this case, what
-- was previously an internal build-tool dependency now became
-- an external one, and now previously "internal" dependencies
-- are now external. But these are permitted to exist even
-- when they are not previously configured (something that
-- can only occur by a Custom script.)
--
-- So, I decided, "Fine, let's just accept these in any
-- case." Thus this line. The alternative would have been to
-- somehow detect when a build-tools dependency was "internal" (by
-- looking at the unflattened package description) but this
-- would also be incompatible with future work to support
-- external executable dependencies: we definitely cannot
-- assume they will be preinitialized in the 'ProgramDb'.
configureProgram verbosity (simpleProgram progName) progdb
Just prog
-- requireProgramVersion always requires the program have a version
-- but if the user says "build-depends: foo" ie no version constraint
-- then we should not fail if we cannot discover the program version.
| verRange == anyVersion -> do
(_, progdb') <- requireProgram verbosity prog progdb
return progdb'
| otherwise -> do
(_, _, progdb') <- requireProgramVersion verbosity prog verRange progdb
return progdb'

-- -----------------------------------------------------------------------------
-- Configuring pkg-config package dependencies
Expand Down
Loading

0 comments on commit 36faf8b

Please sign in to comment.