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

Convenience libraries #3022

Merged
merged 30 commits into from
Mar 29, 2016
Merged

Convenience libraries #3022

merged 30 commits into from
Mar 29, 2016

Conversation

ezyang
Copy link
Contributor

@ezyang ezyang commented Jan 3, 2016

Implement "convenience libraries", fixes #269.

Convenience libraries are package-private libraries
that can be used as part of executables, libraries, etc
without being exposed to the external world. Private
libraries are signified using the

library foo

stanza. Within a Cabal package, the name convenience library
shadows the conventional meaning of package name in
build-depends, so that references to "foo" do not indicate
foo in Hackage, but the convenience library defined in the
same package. (So, don't shadow Hackage packages!)

This commit implements convenience libraries such that they
ARE installed the package database (this prevents us from
having to special case dynamically linked executables);
in GHC 7.10 and later they are installed under the same
package name as the package that contained them, but have
a distinct "component ID" (one pay off of making the distinction
between component IDs and installed package IDs.)

There is a "default" library which is identified by the fact
that its library name coincides with the package name. There
are some new convenience functions to permit referencing this.

TODO: if we REALLY don't want to install a convenience library,
we could add a "installable:" flag which toggles whether or
not copy/register should install it. Extra sanity checking
is necessary in this case.

TODO: docs

TODO: cabal-install must ignore convenience libraries when
dep solving

NB: there are a few extra commits in this PR which should be split into their own PRs. Annoying to do slightly.

Signed-off-by: Edward Z. Yang ezyang@cs.stanford.edu

@ezyang ezyang force-pushed the convenience-libraries branch 4 times, most recently from a2ae14b to 735d7cb Compare January 8, 2016 22:00
@dcoutts
Copy link
Contributor

dcoutts commented Jan 10, 2016

In principle this is a great feature.

From brief discussion we think not installing the convenience library when it's not needed is a good improvement, and we can determine exactly when it's needed or not so no user visible flag is needed.

@dcoutts
Copy link
Contributor

dcoutts commented Jan 10, 2016

For other people reviewing this: the important point is that these libs are not available for other packages to depend on, so it's still the case that one package provides at most one library. And the installed package id for private libs is picked such that it can never clash with primary public libs from any other package.

@23Skidoo
Copy link
Member

@ezyang Do you want this to go into 1.24? Otherwise I think I'll postpone merging this PR until the 1.24 branch is created.

@ezyang
Copy link
Contributor Author

ezyang commented Jan 11, 2016

Yeah, I'm fine with postponing this after 1.24.

@ezyang
Copy link
Contributor Author

ezyang commented Jan 11, 2016

Found a bug: internal libraries and the main libraries all get installed to the same directory.

@ezyang
Copy link
Contributor Author

ezyang commented Jan 12, 2016

So, I fixed all those bugs, and along the way also fixed #1893 and also did a bit of refactoring. The patchset got longer but these are all self-contained commits.

@ezyang
Copy link
Contributor Author

ezyang commented Jan 14, 2016

Blah, I broke buildinfo parsing. I'll fix it and add a test.

@ezyang ezyang force-pushed the convenience-libraries branch 2 times, most recently from 9a0936c to 2389f80 Compare January 15, 2016 04:35
@ezyang
Copy link
Contributor Author

ezyang commented Jan 15, 2016

(NB: this branch has been rebased on top of #3047)

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
This test-case was lifted straight from the Cabal manual.
It also tests if buildinfo is handled correctly.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
@23Skidoo
Copy link
Member

@ezyang

Can you please create tickets for the remaining TODOs?

As far as I can tell (it's a little difficult since when I rebased we lost the old comments) all comments have been addressed. I'll merge.

I meant the TODOs you mentioned in the top comment, i.e. docs, a change to the solver and the "installable" flag. Though I see that docs have now been added.

@ezyang
Copy link
Contributor Author

ezyang commented Apr 1, 2016

Oh yeah, those comments are out of date. The "installable" flag is irrelevant now, since Cabal just "does the right thing" now to determine if a library should be installed or not. Solver changes are being tracked at #3264/#3257.

@23Skidoo
Copy link
Member

23Skidoo commented Apr 1, 2016

Great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cabal: other re: internal library Concerning internal libraries in packages type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for convenience libraries
5 participants