-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
When converting the component graph to operate in terms of UnitIds instead of CNames I accidentally introduced a regression where we stopped respecting build-tools when determining an ordering to build things. This commit fixes the regression (though perhaps not in the most clean/performant way you could manage it.) It also fixes a latent bug if internal libraries aren't processed in the correct order. Signed-off-by: Edward Z. Yang <[email protected]>
- Loading branch information
Showing
9 changed files
with
114 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module A where | ||
|
||
a :: String | ||
a = "hello from A" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Main where | ||
|
||
import A | ||
|
||
main :: IO () | ||
main = putStrLn a |
9 changes: 9 additions & 0 deletions
9
Cabal/tests/PackageTests/CustomPreProcess/MyCustomPreprocessor.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Main where | ||
|
||
import System.Directory | ||
import System.Environment | ||
|
||
main :: IO () | ||
main = do | ||
(source:target:_) <- getArgs | ||
copyFile source target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{-# OPTIONS_GHC -Wall #-} | ||
|
||
import Distribution.PackageDescription | ||
import Distribution.Simple | ||
import Distribution.Simple.LocalBuildInfo | ||
import Distribution.Simple.PreProcess | ||
import Distribution.Simple.Utils | ||
import System.Exit | ||
import System.FilePath | ||
import System.Process (rawSystem) | ||
|
||
main :: IO () | ||
main = defaultMainWithHooks | ||
simpleUserHooks { hookedPreProcessors = [("pre", myCustomPreprocessor)] } | ||
where | ||
myCustomPreprocessor :: BuildInfo -> LocalBuildInfo -> ComponentLocalBuildInfo -> PreProcessor | ||
myCustomPreprocessor _bi lbi _clbi = | ||
PreProcessor { | ||
platformIndependent = True, | ||
runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -> | ||
do info verbosity ("Preprocessing " ++ inFile ++ " to " ++ outFile) | ||
callProcess progPath [inFile, outFile] | ||
} | ||
where | ||
builddir = buildDir lbi | ||
progName = "my-custom-preprocessor" | ||
progPath = builddir </> progName </> progName | ||
|
||
-- Backwards compat with process < 1.2. | ||
callProcess :: FilePath -> [String] -> IO () | ||
callProcess path args = | ||
do exitCode <- rawSystem path args | ||
case exitCode of ExitSuccess -> return () | ||
f@(ExitFailure _) -> fail $ "callProcess " ++ show path | ||
++ " " ++ show args ++ " failed: " | ||
++ show f |
31 changes: 31 additions & 0 deletions
31
Cabal/tests/PackageTests/CustomPreProcess/internal-preprocessor-test.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: internal-preprocessor-test | ||
version: 0.1.0.0 | ||
synopsis: Internal custom preprocessor example. | ||
description: See https://github.com/haskell/cabal/issues/1541#issuecomment-30155513 | ||
license: GPL-3 | ||
author: Mikhail Glushenkov | ||
maintainer: [email protected] | ||
category: Testing | ||
build-type: Custom | ||
cabal-version: >=1.10 | ||
|
||
-- Note that exe comes before the library. | ||
-- The reason is backwards compat: old versions of Cabal (< 1.18) | ||
-- don't have a proper component build graph, so components are | ||
-- built in declaration order. | ||
executable my-custom-preprocessor | ||
main-is: MyCustomPreprocessor.hs | ||
build-depends: base, directory | ||
default-language: Haskell2010 | ||
|
||
library | ||
exposed-modules: A | ||
build-depends: base | ||
build-tools: my-custom-preprocessor | ||
-- ^ Note the internal dependency. | ||
default-language: Haskell2010 | ||
|
||
executable hello-world | ||
main-is: Hello.hs | ||
build-depends: base, internal-preprocessor-test | ||
default-language: Haskell2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters