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

Allow preprocessor-specific reorderings #6291

Closed
wants to merge 6 commits into from

Conversation

vmchale
Copy link
Contributor

@vmchale vmchale commented Oct 8, 2019

This is a slimmed-down version of #6233 that allows users to define a reordering function when they define a pre-processor, based on @DanielG's suggestion.

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • If the change is docs-only, [ci skip] is used to avoid triggering the build bots.

This was not tested; I do know it "intervenes" in the right place by the past pull request. It is one step towards handling c2hs correctly.

@DanielG
Copy link
Collaborator

DanielG commented Oct 9, 2019

Test failure:

/home/travis/build/haskell/cabal/cabal-testsuite/PackageTests/CustomPreProcess/Setup.hs:18:7: warning: [-Wmissing-fields]
    * Fields of `PreProcessor' not initialised: reorderPreProcessorDeps
    * In the expression:
        PreProcessor
          {platformIndependent = True,
           runPreProcessor = mkSimplePreProcessor
                               $ \ inFile outFile verbosity
                                   -> do info
                                           verbosity
                                           ("Preprocessing " ++ inFile ++ " to " ++ outFile)
                                         ....}
      In an equation for `myCustomPreprocessor':
          myCustomPreprocessor _bi lbi _clbi
            = PreProcessor
                {platformIndependent = True,
                 runPreProcessor = mkSimplePreProcessor
                                     $ \ inFile outFile verbosity -> do ...}
            where
                builddir = buildDir lbi
                progName = "my-custom-preprocessor"
                progPath = builddir </> progName </> progName
      In an equation for `main':
          main
            = defaultMainWithHooks
                simpleUserHooks
                  {hookedPreProcessors = [("pre", myCustomPreprocessor)]}
            where
                myCustomPreprocessor ::
                  BuildInfo
                  -> LocalBuildInfo -> ComponentLocalBuildInfo -> PreProcessor
                myCustomPreprocessor _bi lbi _clbi
                  = PreProcessor
                      {platformIndependent = True,
                       runPreProcessor = mkSimplePreProcessor
                                           $ \ inFile outFile verbosity -> ...}
                  where
                      builddir = buildDir lbi
                      progName = "my-custom-preprocessor"
                      ....
                callProcess :: FilePath -> [String] -> IO ()
                callProcess path args
                  = do exitCode <- rawSystem path args
                       ....
   |
18 |       PreProcessor {
   |       ^^^^^^^^^^^^^^...

@vmchale
Copy link
Contributor Author

vmchale commented Oct 9, 2019

Btw if others have further suggestions about design, I am open to other things here.

@vmchale
Copy link
Contributor Author

vmchale commented Oct 12, 2019

@DanielG thoughts? It is now passing CI.

@vmchale vmchale closed this Oct 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants