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

Disable library building, only build other components #2775

Open
snoyberg opened this issue Aug 18, 2015 · 5 comments
Open

Disable library building, only build other components #2775

snoyberg opened this issue Aug 18, 2015 · 5 comments

Comments

@snoyberg
Copy link
Collaborator

(I may be missing something obvious, in which case, please let me know how this should be handled.)

When you specify components, you can get fine-grained control over which executables are built. However, there seems to be no way to control the library component. This has a number of repercussions:

  • No way to build only the library: cabal build will build all components
  • No way to build just an executable/test suite/benchmark without building the library
  • Due to the fact that --enable-tests or --enable-benchmarks can modify the cabal_macros.h file, building your library and then rebuilding with test suites enabled can force the entire library to be recompiled, even though that's not necessary (this may actually be worth opening as a separate bug report).

Backwards compatibility will be a problem for any changes we want to make here. Ideally, I'd have said that lib is its own component, and a command cabal build lib would build only the library, whereas cabal build exe:foo would not build the library. However, the latter would be a breaking change. So perhaps we can add a --no-build-library flag?

(And I've referred to cabal the executable here, but I'd really like to see this in Cabal-the-library.)

@snoyberg
Copy link
Collaborator Author

After working through the codebase, it seems like one part of this is in fact supported: cabal build packagename will build only the library, with none of the other components. Can someone confirm that that's intended behavior?

This addresses some of my need, but I do still need a way to disable building the library.

@snoyberg
Copy link
Collaborator Author

And after a little more experimentation: this is specifically in the case where the executable/test suite/benchmark depends on the local library. Nonetheless, for that case, I'd like the ability to turn off rebuilding of the local library and use the already built copy. Figuring out a fix for the cabal_macros.h issue would go a long way to making such a change unnecessary.

@hvr
Copy link
Member

hvr commented Sep 4, 2015

Can someone confirm that that's intended behavior?

Afaik yes, but you can be more explicit by saying cabal build lib:<packagename (you may have seen there's a bit of machinery in Distribution.Simple.BuildTarget). It was planned to have cabal build also be able to build single modules of components at some point.

/cc @dcoutts

@ezyang
Copy link
Contributor

ezyang commented Jan 19, 2016

The macros issue is #1893, there's a patch in the works.

@ezyang
Copy link
Contributor

ezyang commented Apr 5, 2016

The macro issue has been fixed in HEAD.

If you still want to build an executable against an external copy of the library, I feel that #3286 should solve this case.

ezyang added a commit to ezyang/cabal that referenced this issue Apr 6, 2016
…#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 6, 2016
…#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 6, 2016
…#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 7, 2016
…#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 7, 2016
…askell#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 7, 2016
…askell#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 7, 2016
…askell#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 8, 2016
…askell#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 8, 2016
…askell#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 8, 2016
…askell#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 8, 2016
…askell#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 8, 2016
…askell#3287)

--one-shot lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 11, 2016
…askell#2775 (haskell#3287)

--assume-deps-up-to-date lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 11, 2016
…askell#2775 (haskell#3287)

--assume-deps-up-to-date lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 12, 2016
…askell#2775 (haskell#3287)

--assume-deps-up-to-date lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Apr 12, 2016
…askell#2775 (haskell#3287)

--assume-deps-up-to-date lets you compile a single component without
building its dependencies.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
ezyang added a commit to ezyang/cabal that referenced this issue Oct 18, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Oct 19, 2016
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

4 participants