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

Implement build-tool-depends #4104

Merged
merged 9 commits into from
Jan 7, 2017
Merged

Conversation

Ericson2314
Copy link
Collaborator

@Ericson2314 Ericson2314 commented Nov 12, 2016

Implements much of #3708

Note the the exe component name is currently mandatory, unlike as specified in the original issue.

@mention-bot
Copy link

@Ericson2314, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ezyang, @dcoutts and @phadej to be potential reviewers.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

Commit 1 review.

-- | Describes a legacy `build-tools`-style dependency on an executable
--
-- It is "legacy" because we do not know what the build-tool referred to. It
-- could refer to a pkg-config executable (PkgconfigName), or an internal
-- executable (UnqualComponentName). Thus the name is stringly typed.
--
--g
Copy link
Contributor

Choose a reason for hiding this comment

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

oops

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

:)

PackageName
UnqualComponentName -- name of executable component of package
VersionRange
deriving (Generic, Read, Show, Eq, Typeable, Data)
Copy link
Contributor

Choose a reason for hiding this comment

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

It is possible that you may want a helper function that takes an ExeDependency and gives a ComponentName (since the UnqualComponentName is only "implicitly" qualified.) I don't know if you'd actually use it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, doesn't hurt to add it now. Good hint on unqual vs qual for anyone working with the code base.


parse = do name <- parse
_ <- Parse.char ':'
exe <- parse
Copy link
Contributor

Choose a reason for hiding this comment

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

OK, so right now you are forced to specify the executable name. That's fine (although our users might complain :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Besides laziness, I figured a blanket depend-on-all-the-exes dependency might complicate making the solver use deps on specific components. Then again we may need a blanket package dep anyways.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

Commit 3 (commit 2 was obvious, no problem.)

-- that we know how to desugar.
--
-- This should almost always be used instead of just accessing the
-- `toolDepends` field directly.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, if that's true there better be a comment on toolDepends telling people about it, or rename that field to something to discourage people from using it directoy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added some longer documentation to the relevant fields in the top commit. I'll also grep at the end to make sure nothing is lurking.

Copy link
Collaborator Author

@Ericson2314 Ericson2314 Nov 26, 2016

Choose a reason for hiding this comment

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

I could sed the field names too, but probably easiest to do that last.

--
-- This is a tiny function, but used in a number of places. Note that the
-- version bounds and components of the package are unchecked. This is because
-- we sanitize exe deps so that the matching name implies these other
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this sanitizing happen.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PackageDescription.Check does sanitation happen in places besides that?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the overall codebase doesn't use "sanitization" as the term here. Furthermore, not all checks in PackageDescription.Check are necessarily run all the time: a package can still be built even if some of the checks fail. It is better to say that there is some invariant that is expected to hold; in that case the invariant description should be at the data type definition.

@@ -524,13 +525,42 @@ checkFields pkg =
++ "for example 'tested-with: GHC==6.10.4, GHC==6.12.3' and not "
++ "'tested-with: GHC==6.10.4 && ==6.12.3'."

, check (not (null buildDependsRangeOnInternalLibrary)) $
, check (not (null depInternalLibraryWithExtraVersion)) $
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't read this code carefully. Good tests would tickle all of these cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whew! A lot of copy pasta but tested everything.

@ezyang
Copy link
Contributor

ezyang commented Nov 12, 2016

Looking good. Obviously you still need to do the cabal-install bits.

@Ericson2314 Ericson2314 force-pushed the tool-depends branch 4 times, most recently from f6d7e02 to 3269f83 Compare November 16, 2016 13:54
@Ericson2314
Copy link
Collaborator Author

How should I write the (presumably system) tests for those tests? I see the cabal files in PackageTests, but not sure where the code verifying stdout / stderr is.

@Ericson2314 Ericson2314 force-pushed the tool-depends branch 2 times, most recently from b1487b4 to fd11fbc Compare November 16, 2016 16:29
@23Skidoo
Copy link
Member

You may want to wait until #4095 is merged.

@Ericson2314
Copy link
Collaborator Author

Hmm good idea

@Ericson2314
Copy link
Collaborator Author

Ericson2314 commented Nov 17, 2016

Hmm, so InternalLibrary4 explicitly tests that version bounds can trigger the use of an external library instead of internal one. This is in direct conflict with the buildDependsRangeOnInternalLibrary test this patch expands---it says version bounds don't matter because the internal library is always used. I don't really care which semantics we go with, except that we should be consistent for all 3 of "build-tools", "build-depends", and "tool-depends".

@ezyang
Copy link
Contributor

ezyang commented Nov 17, 2016

@Ericson2314 We got rid of this feature in af24cef. Internal library should always be used.

@Ericson2314
Copy link
Collaborator Author

Ericson2314 commented Nov 26, 2016

Ok things left: edit see new list in comment below

  • cabal-install's init
  • cabal-install's tests
  • Real name for Distribution.FooBar :D

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

It's helpful if the commit message mentions the overall code motion that occurred; especially here were some things got deleted, and other things got added.

@ezyang
Copy link
Contributor

ezyang commented Nov 26, 2016

Lookin' good!

, let toolname = mkUnqualComponentName name
, toolname `elem` map exeName (executables pkg_descr) ]
| (ExeDependency _ toolname _)
<- getAllInternalToolDependencies pkg_descr bi ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Good.

-- precisely specify an executable in a package.
--
-- Unless use are very sure what you are doing, use the function in
-- `Distribution.FooBar` rather than accessing this field directly.
Copy link
Contributor

Choose a reason for hiding this comment

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

But... which function/!

@ezyang
Copy link
Contributor

ezyang commented Nov 28, 2016

NB: this shouldn't be merged until "Ok things left:" list is done.

@hvr
Copy link
Member

hvr commented Nov 28, 2016

@ezyang what's the first todo item about? if it's about cabal init I don't think it's essential for this PR

@ezyang
Copy link
Contributor

ezyang commented Nov 28, 2016

Looking at the source code, it doesn't look like the new-build code has been adjusted for tool-depends yet. But maybe no changes were needed; I don't know if it works or not; the tests would be able to say so.

@Ericson2314 Ericson2314 force-pushed the tool-depends branch 4 times, most recently from 30e62d9 to 0b62af1 Compare December 6, 2016 16:19
Ericson2314 and others added 2 commits January 6, 2017 16:50
Modeled after the extern_build_tools test
…ild-tools`

`build-tools` is described in terms of `build-tool-depends`, just as it is
implemented in terms of it.
@Ericson2314
Copy link
Collaborator Author

Ericson2314 commented Jan 6, 2017

Ok, docs are done also all that remains is cabal init, and making the PATH more fine-grained a la #4104 (comment) . OK to do those in future PRs?

@ezyang
Copy link
Contributor

ezyang commented Jan 6, 2017

Yep. Anything in particular you want reviewed before merging?

@hvr
Copy link
Member

hvr commented Jan 7, 2017

let's get this merged soon before the PR starts to "conflict-rot" :-)

@Ericson2314 Ericson2314 merged commit 5e4377b into haskell:master Jan 7, 2017
@Ericson2314 Ericson2314 deleted the tool-depends branch January 7, 2017 16:09
@Ericson2314 Ericson2314 changed the title [WIP] implement tool-depends implement tool-depends Jan 9, 2017
@Ericson2314 Ericson2314 changed the title implement tool-depends Implement tool-depends Jan 9, 2017
Ericson2314 added a commit to Ericson2314/cabal that referenced this pull request Jan 11, 2017
This is a bug from `first build-tool-depends` PR: haskell#4104
Ericson2314 added a commit to Ericson2314/cabal that referenced this pull request Jan 12, 2017
This is a bug from `first build-tool-depends` PR: haskell#4104

Also, remove TODO about factoring things out. The exact set of deps filter
here is no longer so globally relevant, and
`Distribution.Simple.BuildToolDepends` exposes better filters which are.
@ezyang
Copy link
Contributor

ezyang commented Jan 13, 2017

@Ericson2314 It would be great if we could have a changelog entry too!

@phadej
Copy link
Collaborator

phadej commented Jan 13, 2017

I can't wait till this gets to hvr's ppa repository so I can try it out wild!

@hvr
Copy link
Member

hvr commented Jan 14, 2017

@phadej ...I got the hint ;-)

@Ericson2314
Copy link
Collaborator Author

@ezyang OK I will do that in the PR that https://github.com/Ericson2314/cabal/tree/build-tool-depends-glob turns into.

@ezyang
Copy link
Contributor

ezyang commented Jan 16, 2017

Thanks!

Ericson2314 added a commit to Ericson2314/cabal that referenced this pull request Jan 17, 2017
This is a bug from `first build-tool-depends` PR: haskell#4104

Also, remove TODO about factoring things out. The exact set of deps filter
here is no longer so globally relevant, and
`Distribution.Simple.BuildToolDepends` exposes better filters which are.
@Ericson2314 Ericson2314 mentioned this pull request Jan 17, 2017
Ericson2314 added a commit to Ericson2314/cabal that referenced this pull request Jan 17, 2017
This is a bug from `first build-tool-depends` PR: haskell#4104

Also, remove TODO about factoring things out. The exact set of deps filter
here is no longer so globally relevant, and
`Distribution.Simple.BuildToolDepends` exposes better filters which are.
Ericson2314 added a commit to Ericson2314/cabal that referenced this pull request Jan 17, 2017
This is a bug from `first build-tool-depends` PR: haskell#4104

Also, remove TODO about factoring things out. The exact set of deps filter
here is no longer so globally relevant, and
`Distribution.Simple.BuildToolDepends` exposes better filters which are.
Ericson2314 added a commit to Ericson2314/cabal that referenced this pull request Jan 18, 2017
This is a bug from `first build-tool-depends` PR: haskell#4104

Also, remove TODO about factoring things out. The exact set of deps filter
here is no longer so globally relevant, and
`Distribution.Simple.BuildToolDepends` exposes better filters which are.
Ericson2314 added a commit to Ericson2314/cabal that referenced this pull request Jan 18, 2017
This is a bug from `first build-tool-depends` PR: haskell#4104

Also, remove TODO about factoring things out. The exact set of deps filter
here is no longer so globally relevant, and
`Distribution.Simple.BuildToolDepends` exposes better filters which are.
Ericson2314 added a commit to Ericson2314/cabal that referenced this pull request Jan 18, 2017
This is a bug from `first build-tool-depends` PR: haskell#4104

Also, remove TODO about factoring things out. The exact set of deps filter
here is no longer so globally relevant, and
`Distribution.Simple.BuildToolDepends` exposes better filters which are.
Ericson2314 added a commit to Ericson2314/cabal that referenced this pull request Jan 20, 2017
This is a bug from `first build-tool-depends` PR: haskell#4104

Also, remove TODO about factoring things out. The exact set of deps filter
here is no longer so globally relevant, and
`Distribution.Simple.BuildToolDepends` exposes better filters which are.
Ericson2314 added a commit to Ericson2314/cabal that referenced this pull request Jan 23, 2017
This is a bug from `first build-tool-depends` PR: haskell#4104

Also, remove TODO about factoring things out. The exact set of deps filter
here is no longer so globally relevant, and
`Distribution.Simple.BuildToolDepends` exposes better filters which are.
@Ericson2314 Ericson2314 changed the title Implement tool-depends Implement build-tool-depends Jan 24, 2017
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.

6 participants