Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter Setup flags: filter working dir on < 3.13 #9951

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cabal-install/src/Distribution/Client/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -635,22 +635,22 @@ filterCommonFlags :: CommonSetupFlags -> Version -> CommonSetupFlags
filterCommonFlags flags cabalLibVersion
-- NB: we expect the latest version to be the most common case,
-- so test it first.
| cabalLibVersion >= mkVersion [3, 11, 0] = flags_latest
| cabalLibVersion >= mkVersion [3, 13, 0] = flags_latest
| cabalLibVersion < mkVersion [1, 2, 5] = flags_1_2_5
| cabalLibVersion < mkVersion [2, 1, 0] = flags_2_1_0
| cabalLibVersion < mkVersion [3, 11, 0] = flags_3_11_0
| cabalLibVersion < mkVersion [3, 13, 0] = flags_3_13_0
| otherwise = error "the impossible just happened" -- see first guard
where
flags_latest = flags
flags_3_11_0 =
flags_3_13_0 =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how we are going to backport this. Probably this one stays, but the 3.11 above is not changed to 3.13? Or is it about which version is the last know version of flags, not last known version of cabal at all, so no problem if the flags version is in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right... I think we might not even need to backport anything, because cabal-install-3.12.x will not attempt to pass any --working-dir arguments because it doesn't have the working directory patch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, great! Regardless, let's merge this one. @sheaf: could you kindly set the merge_me or squash+merge_me label?

flags_latest
{ setupWorkingDir = NoFlag
}
-- Cabal < 3.11 does not support the --working-dir flag.
-- Cabal < 3.13 does not support the --working-dir flag.
flags_2_1_0 =
flags_3_11_0
flags_3_13_0
{ -- Cabal < 2.1 doesn't know about -v +timestamp modifier
setupVerbosity = fmap verboseNoTimestamp (setupVerbosity flags_3_11_0)
setupVerbosity = fmap verboseNoTimestamp (setupVerbosity flags_3_13_0)
}
flags_1_2_5 =
flags_2_1_0
Expand Down
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/WorkingDir/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main where

import Dep(foo)

main :: IO ()
main = print foo
7 changes: 7 additions & 0 deletions cabal-testsuite/PackageTests/WorkingDir/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Main where

import Distribution.Simple ( defaultMain )

main :: IO ()
main = defaultMain

1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/WorkingDir/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: ., dep
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/WorkingDir/dep/Dep.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Dep where

foo :: Int
foo = 17
7 changes: 7 additions & 0 deletions cabal-testsuite/PackageTests/WorkingDir/dep/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Main where

import Distribution.Simple ( defaultMain )

main :: IO ()
main = defaultMain

18 changes: 18 additions & 0 deletions cabal-testsuite/PackageTests/WorkingDir/dep/dep.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cabal-version: 2.4
name: dep
version: 0.1.0.0
synopsis: Test that we don't pass --working-dir when unsupported
license: BSD-3-Clause
author: NA
maintainer: NA
category: Testing
build-type: Custom

custom-setup
setup-depends: base, Cabal >= 2.4 && < 3.13

library
build-depends: base
default-language: Haskell2010
hs-source-dirs: .
exposed-modules: Dep
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/WorkingDir/setup.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

main = cabalTest $ recordMode DoNotRecord $ do
skipUnlessAnyCabalVersion "< 3.13"
cabalWithStdin "v2-build" [] ""
return ()
18 changes: 18 additions & 0 deletions cabal-testsuite/PackageTests/WorkingDir/working-dir-test.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cabal-version: 2.4
name: working-dir-test
version: 0.1.0.0
synopsis: Test that we don't pass --working-dir when unsupported
license: BSD-3-Clause
author: NA
maintainer: NA
category: Testing
build-type: Custom

custom-setup
setup-depends: base, Cabal >= 2.4 && < 3.13

executable Exe
default-language: Haskell2010
build-depends: base, dep
hs-source-dirs: .
main-is: Main.hs
Loading