Skip to content

Commit 539cb7b

Browse files
mpickeringMikolaj
authored andcommitted
Add extra ghc options to multi-repl file
These options are configured into the program by Cabal, so we also need to extract these and put them into the mutli-file. Fixes #10015
1 parent ab4c137 commit 539cb7b

File tree

10 files changed

+124
-1
lines changed

10 files changed

+124
-1
lines changed

Cabal/src/Distribution/Simple/GHC/Build/Link.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,9 @@ runReplOrWriteFlags ghcProg lbi rflags ghcOpts pkg_name target =
711711
writeFileAtomic (out_dir </> this_unit) $
712712
BS.pack $
713713
escapeArgs $
714-
extra_opts ++ renderGhcOptions comp platform (ghcOpts{ghcOptMode = NoFlag})
714+
extra_opts
715+
++ renderGhcOptions comp platform (ghcOpts{ghcOptMode = NoFlag})
716+
++ programOverrideArgs ghcProg
715717

716718
replNoLoad :: Ord a => ReplOptions -> NubListR a -> NubListR a
717719
replNoLoad replFlags l
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for extra-options
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (c) 2024, Matthew Pickering
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Matthew Pickering nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Main where
2+
3+
import qualified MyLib (someFunc)
4+
5+
#ifdef FOO
6+
main :: IO ()
7+
main = do
8+
putStrLn "Hello, Haskell!"
9+
MyLib.someFunc
10+
#endif
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# cabal v2-repl
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- extra-options-0.1.0.0 (interactive) (lib) (first run)
6+
- extra-options-0.1.0.0 (interactive) (test:extra-options-test) (first run)
7+
- extra-options-0.1.0.0 (interactive) (exe:extra-options) (first run)
8+
Configuring library for extra-options-0.1.0.0...
9+
Preprocessing library for extra-options-0.1.0.0...
10+
Configuring test suite 'extra-options-test' for extra-options-0.1.0.0...
11+
Preprocessing test suite 'extra-options-test' for extra-options-0.1.0.0...
12+
Configuring executable 'extra-options' for extra-options-0.1.0.0...
13+
Preprocessing executable 'extra-options' for extra-options-0.1.0.0...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
packages: .
2+
3+
tests: True
4+
5+
program-options
6+
ghc-options: -XCPP -DFOO
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Test.Cabal.Prelude
2+
3+
main = do
4+
cabalTest $ do
5+
skipUnlessGhcVersion ">= 9.4"
6+
void $ cabalWithStdin "v2-repl" ["--enable-multi-repl","all"] ""
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
cabal-version: 3.0
2+
name: extra-options
3+
version: 0.1.0.0
4+
license: BSD-3-Clause
5+
license-file: LICENSE
6+
author: Matthew Pickering
7+
maintainer: matthewtpickering@gmail.com
8+
build-type: Simple
9+
extra-doc-files: CHANGELOG.md
10+
11+
common warnings
12+
ghc-options: -Wall
13+
14+
library
15+
import: warnings
16+
exposed-modules: MyLib
17+
build-depends: base
18+
hs-source-dirs: src
19+
default-language: Haskell2010
20+
21+
executable extra-options
22+
import: warnings
23+
main-is: Main.hs
24+
build-depends:
25+
base,
26+
extra-options
27+
28+
hs-source-dirs: app
29+
default-language: Haskell2010
30+
31+
test-suite extra-options-test
32+
import: warnings
33+
default-language: Haskell2010
34+
type: exitcode-stdio-1.0
35+
hs-source-dirs: test
36+
main-is: Main.hs
37+
build-depends:
38+
base,
39+
extra-options
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module MyLib (someFunc) where
2+
3+
#ifdef FOO
4+
someFunc :: IO ()
5+
someFunc = putStrLn "someFunc"
6+
#endif
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Main (main) where
2+
3+
#ifdef FOO
4+
main :: IO ()
5+
main = putStrLn "Test suite not yet implemented."
6+
#endif

0 commit comments

Comments
 (0)