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

cabal v2-clean does not run pre or postClean nor use the field extra-tmp-files. #6112

Open
mdgabriel opened this issue Jun 26, 2019 · 5 comments

Comments

@mdgabriel
Copy link

Describe the bug
For cabal 2.4.1.0, cabal v2-clean does not execute the preClean nor the postClean hooks whereas cabal v1-clean does execute them. Also, cabal v2-clean does not use the field extra-tmp-files in the project.cabal file whereas cabal v1-clean does use it to remove temporary files.

Note that cabal v2-build and cabal v1-build both execute the preBuild and postBuild hooks.

To Reproduce
Setup.hs:

main = defaultMainWithHooks simpleUserHooks
{preBuild = do { putStrLn "My preBuild"; return emptyHookedBuildInfo}
,postBuild = putStrLn "My postBuild"
,preClean = do { putStrLn "My preClean"; return emptyHookedBuildInfo}
,postClean = putStrLn "My postClean"
}

project.cabal:

extra-tmp-files:
aTmpFileToRemoveOnClean

Essentially, cabal v1-build and cabal v2-build will both print "My preBuild" and "My postBuild" whereas cabal v1-clean will print "My preClean" and "My postClean" but cabal v2-clean will not print these two messages. Finally, cabal v1-clean will remove "aTmpFileToRemoveOnClean" but cabal v2-clean will not remove the file.

Expected behavior
I expect cabal v2-clean to execute the preClean and postClean hooks and to use the field
extra-tmp-files of the package.cabal file as does cabal v1-clean. If this is not the goal for v2, then I need a procedure to clean up after a cabal v2-build with cabal v2-clean.

System informataion

  • Operating system
    Ubuntu 16.04.6 LTS (Xenial Xerus)
  • cabal, ghc versions
    $ cabal --version
    cabal-install version 2.4.1.0
    compiled using version 2.4.1.0 of the Cabal library
    $ ghc --version
    The Glorious Glasgow Haskell Compilation System, version 8.6.5

Additional context
The issue was discovered with a cabal package that I am creating that uses bnfc --haskell via the hookedPreProcessors record.

@typedrat
Copy link
Collaborator

D'oh! My bad, largely because I didn't know that extra-tmp-files existed.

@mdgabriel
Copy link
Author

Not a problem. I too was not aware of extra-tmp-files either until my postClean did not work with cabal v2-clean. Actually, for me and for my package extra-tmp-files is the better solution than postClean.

@phadej
Copy link
Collaborator

phadej commented Jun 27, 2019 via email

@mdgabriel
Copy link
Author

you rather should generate files in autogen directory

Well ... that is rather obvious. Thank you. I followed this advice since bnfc can set its output directory and so I used the autogenComponentModulesDir function. Now cabal v2-clean cleans up as needed.

This is to say, I need neither postClean nor extra-tmp-files to clean up my build.

Given my new understanding of how v2 commands work, I would say that extra-tmp-files does not need to be and should not be implemented in v2-clean.

I do not have an opinion about preClean or postClean for the moment.

@MathiasSven
Copy link

MathiasSven commented Dec 29, 2023

How should one handle the *.buildinfo file produced by a potential configure script under build-type: Configure? According to the docs:

If the package root directory contains a file called package.buildinfo after the configuration step, subsequent steps will read it to obtain additional settings for build information fields,to be merged with the ones given in the .cabal file.

So moving the file to a different directory doesn't seem to be an option.

EDIT: It might have been a documentation issue, it does seem to work when the buildinfo file isn't at the root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants