File tree Expand file tree Collapse file tree 12 files changed +156
-6
lines changed
Cabal/src/Distribution/Simple/GHC
cabal-testsuite/PackageTests Expand file tree Collapse file tree 12 files changed +156
-6
lines changed Original file line number Diff line number Diff line change @@ -442,7 +442,8 @@ componentGhcOptions verbosity implInfo lbi bi clbi odir =
442
442
ghcOptSplitSections = toFlag (splitSections lbi),
443
443
ghcOptSplitObjs = toFlag (splitObjs lbi),
444
444
ghcOptSourcePathClear = toFlag True ,
445
- ghcOptSourcePath = toNubListR $ [odir] ++ (map getSymbolicPath (hsSourceDirs bi))
445
+ ghcOptSourcePath = toNubListR $ map getSymbolicPath (hsSourceDirs bi)
446
+ ++ [odir]
446
447
++ [autogenComponentModulesDir lbi clbi]
447
448
++ [autogenPackageModulesDir lbi],
448
449
ghcOptCppIncludePath = toNubListR $ [autogenComponentModulesDir lbi clbi
Original file line number Diff line number Diff line change
1
+ module Main (main ) where
2
+
3
+ import Lib (bar )
4
+
5
+ main :: IO ()
6
+ main = do
7
+ -- Make sure cabal sees this because this test is about which
8
+ -- 'Generated' module the 'Lib' was compiled against.
9
+ putStrLn " -----BEGIN CABAL OUTPUT-----"
10
+ putStrLn bar
11
+ putStrLn " -----END CABAL OUTPUT-----"
12
+
Original file line number Diff line number Diff line change
1
+
2
+ module Main (main ) where
3
+
4
+ import Distribution.Simple
5
+ import Distribution.Simple.LocalBuildInfo
6
+ import Distribution.Simple.PreProcess
7
+ import Distribution.Simple.Program
8
+ import Distribution.Types.BuildInfo
9
+ import Distribution.Verbosity
10
+
11
+ import System.Directory
12
+
13
+ ppHGen :: BuildInfo -> LocalBuildInfo -> ComponentLocalBuildInfo -> PreProcessor
14
+ ppHGen _bi lbi _clbi = PreProcessor
15
+ { platformIndependent = True
16
+ , ppOrdering = unsorted
17
+ , runPreProcessor = mkSimplePreProcessor $ \ inFile outFile verbosity ->
18
+ copyFile inFile outFile
19
+ }
20
+
21
+ main :: IO ()
22
+ main = defaultMainWithHooks simpleUserHooks
23
+ { hookedPreProcessors = (" hgen" , ppHGen) : hookedPreProcessors simpleUserHooks
24
+ }
Original file line number Diff line number Diff line change
1
+ # cabal v2-run
2
+ Resolving dependencies...
3
+ Build profile: -w ghc-<GHCVER> -O1
4
+ In order, the following will be built:
5
+ - test-0.1 (exe:autogen-toggle-test) (first run)
6
+ Configuring test-0.1...
7
+ Preprocessing library for test-0.1..
8
+ Building library for test-0.1..
9
+ Preprocessing executable 'autogen-toggle-test' for test-0.1..
10
+ Building executable 'autogen-toggle-test' for test-0.1..
11
+ The module says: Real module, ship to production
12
+ # cabal v2-run
13
+ Resolving dependencies...
14
+ Build profile: -w ghc-<GHCVER> -O1
15
+ In order, the following will be built:
16
+ - test-0.1 (exe:autogen-toggle-test) (configuration changed)
17
+ Configuring test-0.1...
18
+ Preprocessing library for test-0.1..
19
+ Building library for test-0.1..
20
+ Preprocessing executable 'autogen-toggle-test' for test-0.1..
21
+ Building executable 'autogen-toggle-test' for test-0.1..
22
+ The module says: Prebuilt module, don't use in production
Original file line number Diff line number Diff line change
1
+ packages : test.cabal
Original file line number Diff line number Diff line change
1
+ import Test.Cabal.Prelude
2
+
3
+ main :: IO ()
4
+ main = cabalTest . recordMode RecordMarked $ do
5
+ skipUnlessGhcVersion " >= 9.7"
6
+ cabal " v2-run" [" -fgenerate" , " autogen-toggle-test" ]
7
+ cabal " v2-run" [" -f-generate" , " autogen-toggle-test" ]
Original file line number Diff line number Diff line change
1
+ module Generated (foo ) where
2
+
3
+ foo :: String
4
+ foo = " Prebuilt module, don't use in production"
Original file line number Diff line number Diff line change
1
+ module Generated (foo) where
2
+
3
+ foo :: String
4
+ foo = "Real module, ship to production"
Original file line number Diff line number Diff line change
1
+ module Lib (bar ) where
2
+
3
+ import Generated (foo )
4
+
5
+ bar :: String
6
+ bar = " The module says: " ++ foo
Original file line number Diff line number Diff line change
1
+ cabal-version : 3.0
2
+
3
+ name : test
4
+ version : 0.1
5
+ category : Test
6
+ maintainer : S
7
+ synopsis : Test input
8
+ description : Test input
9
+ license : BSD-3-Clause
10
+
11
+ extra-source-files :
12
+ src-inputs/**/*.hgen
13
+
14
+ build-type : Custom
15
+
16
+ custom-setup
17
+ setup-depends : Cabal >= 3.9 , base, directory
18
+
19
+ flag generate
20
+ description :
21
+ Generate files instead of using pregenerated ones
22
+ default :
23
+ False
24
+ manual :
25
+ True
26
+
27
+ library
28
+ exposed-modules :
29
+ Lib
30
+ Generated
31
+
32
+ hs-source-dirs :
33
+ src
34
+
35
+ if flag(generate)
36
+ hs-source-dirs :
37
+ src-inputs
38
+ autogen-modules :
39
+ Generated
40
+ -- We don’t use any tools in this case but they’ll have to
41
+ -- go here
42
+ -- build-tool-depends:
43
+ -- alex:alex
44
+ else
45
+ hs-source-dirs :
46
+ gen
47
+
48
+ build-depends : base > 4
49
+ default-language : Haskell2010
50
+
51
+ executable autogen-toggle-test
52
+ main-is : Main.hs
53
+ hs-source-dirs : .
54
+ default-language : Haskell2010
55
+ build-depends :
56
+ , base > 4
57
+ , test
You can’t perform that action at this time.
0 commit comments