Skip to content

glob expand extra-src-files when tracking for rebuild #7608

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

Merged
merged 2 commits into from
Oct 22, 2021

Conversation

gbaz
Copy link
Collaborator

@gbaz gbaz commented Aug 31, 2021

Fixes partially the issue discussed in #4746 by expanding globs when tracking extra-src-files

@@ -138,13 +142,14 @@ needBuildInfo pkg_descr bi modules = do
-- A.hs-boot; need to track both.
findNeededModules ["hs", "lhs", "hsig", "lhsig"]
findNeededModules ["hs-boot", "lhs-boot"]
expandedExtraSrcFiles <- liftIO $ fmap concat . for (extraSrcFiles pkg_descr) $ \fpath -> matchDirFileGlobWithDie silent (\ _ _ -> return []) (specVersion pkg_descr) "." fpath
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we don't want to die with an error message? Is there any risk of false positives that would justify that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this setting where we're just tracking setting stuff, dying seems weird.

The only other place this gets glob expanded is in the sdist step, where dying makes sense, because you're sdisting something with missing files. But here we're just checking if we need to trigger a reconfigure...

Copy link
Member

@Mikolaj Mikolaj Aug 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, if the user thinks the compiler rebuilds his stuff, but in fact it's not, because the glob is incorrect, we should die ASAP, right? Unless false positives are possible. E.g., the user writes too general globs predicting some files/directories that are not all there yet [edit: and so it dies, even though it won't once the files are in]. Is that or any other false positive possible and likely?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only error would be if the glob matches nothing. I'm extremely chary of having any sort of death or error reporting on a purely administrative step. I don't think there's anywhere else inside the Rebuild monad that we die, so it seems like it would be a significant change from how things now occur. A user will notice if a rebuild happens or not. The behavior no rebuild happening is not substantially different than if they put nothing at all in their extra-src-files, or put in something that matches but doesn't match everything they intended, etc.

That it so say, we're not in a good position here to catch if this is correct. The only way to catch if it is correct is to see if the tarball generated by sdist actually builds.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point about sdist tarball building. Let it be so.

Regarding possible errors, I thought it can fail in a variety of ways, both due to a syntax error in the glob and due to misssing directories, etc., as in https://github.com/haskell/cabal/blob/master/Cabal/src/Distribution/Simple/Glob.hs#L243-L250

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the clarification on possible errors, I'm not particularly familiar with the glob code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second thought, I hope syntax errors in globs are caught already when .cabal file is parsed (it definitely is at cabal check, but that would not be enough). So, no point preparing to handle these errors again.

Copy link
Member

@fgaz fgaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need a changelog entry, especially since it fixes an issue that we're tracking

@gbaz
Copy link
Collaborator Author

gbaz commented Sep 13, 2021

added

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @fgaz: would be this ready to go after the changelog note?

@Mikolaj
Copy link
Member

Mikolaj commented Oct 15, 2021

@fgaz: ping :)

Copy link
Member

@fgaz fgaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, thank you!

@fgaz fgaz added squash+merge me Tell Mergify Bot to squash-merge and removed attention: needs-review labels Oct 22, 2021
@fgaz
Copy link
Member

fgaz commented Oct 22, 2021

@Mergifyio backport 3.6

@mergify
Copy link
Contributor

mergify bot commented Oct 22, 2021

backport 3.6

🟠 Waiting for conditions

  • merged [:pushpin: backport requirement]

@fgaz
Copy link
Member

fgaz commented Oct 22, 2021

Hmm, I think this needs a rebase for CI to start

@Mergifyio rebase

@mergify
Copy link
Contributor

mergify bot commented Oct 22, 2021

rebase

✅ Branch has been successfully rebased

@byorgey byorgey force-pushed the gb/glob-extra-src-tracking branch from a72bbd9 to 6644c24 Compare October 22, 2021 13:30
@mergify mergify bot merged commit 751308c into master Oct 22, 2021
mergify bot pushed a commit that referenced this pull request Oct 22, 2021
* glob expand extra-src-files when tracking for rebuild

* changelog

Co-authored-by: Gershom Bazerman <gershom@arista.com>
(cherry picked from commit 751308c)
@mergify
Copy link
Contributor

mergify bot commented Oct 22, 2021

backport 3.6

✅ Backports have been created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
squash+merge me Tell Mergify Bot to squash-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants