Skip to content
Snippets Groups Projects
Duncan Coutts's avatar
Duncan Coutts authored
The addBuildableCondition function was added to solve the problem with
"buildable: False". The problem was that we would solve or check
dependencies on the basis of the component in question being needed, and
then at the end discover that the component is actually not buildable at
all, and if we'd known that up front we would not have solved for the
component's dependencies.

The trick that addBuildableCondition does is a syntactic transformation,
from components like:

executable blah
  buildable: False
  build-depends: foo >= 1, bar < 2
  something-else: whatever

to:

executable blah
  -- empty!

Or at least, that's the intention. In the above situation the
implementation of addBuildableCondition returns an empty CondNode:

CondNode mempty mempty []

The type at which mempty is used is important here. This transformation
is used in two places: one in the solver and the other in finalizePD.
In the solver the mempty is used at types from the PackageDescription:
Library, Executable, TestSuite etc. So in this case the transformation
works fine we end up with empty executables, test suites etc.

In finalizePD however the mempty gets used at type PDTagged (which is
sort of a union of Library, Executable etc plus none/null) and the
mempty for PDTagged is PDNull which means it does not even specify
which component we're referring to. So effectively that means instead of
ending up with an empty executable in the above example, we end up
deleting the executable entirely!

This was a change in behaviour. Prior to adding addBuildableCondition
the result of finalizePD would include non-buildable components and the
rest of the build system infrastructure was set up to skip over them
when building. The change was not noticed precisely because the rest of
the system was already set up to ignore non-buildable components.

This is not however a benign change in behaviour. In particular in
cabal-install in the install plan we end up completley forgetting about
all the non-buildable components. This means we cannot even report that
components are non-buildable when users ask to build them, because we've
completely forgotten that they exist.

So this patch keeps the original addBuildableCondition for use by the
solver since the solver uses it at sensible monoid types. The patch adds
a special version for the PDTagged type which changes the transformation
so that in the above example we end up with:

executable blah
  buildable: False
  something-else: whatever

So we've stripped out all the build-depends but we keep everything else,
including of course the "buildable: False".
40d1b4f1
History

Cabal Hackage version Stackage version Build Status Windows build status Documentation Status

This Cabal Git repository contains the following packages:

The canonical upstream repository is located at https://github.com/haskell/cabal.

Installing Cabal

Assuming that you have a pre-existing, older version of cabal-install, run:

cabal install cabal-install

To get the latest version of cabal-install. (You may want to cabal update first.)

To install the latest version from the Git repository, clone the Git repository and then run:

(cd Cabal; cabal install)
(cd cabal-install; cabal install)

Building Cabal for hacking

The current recommended way of developing Cabal is to use the new-build feature which shipped in cabal-install-1.24. Assuming that you have a sufficiently recent cabal-install (see above), it is sufficient to run:

cabal new-build cabal-install

To build a local, development copy of cabal-install. The binary will be located at dist-newstyle/build/cabal-install-$VERSION/build/cabal/cabal; you can determine the $VERSION of cabal-install by looking at cabal-install/cabal-install.cabal.

Here are some other useful variations on the commands:

cabal new-build Cabal # build library only
cabal new-build Cabal:package-tests # build Cabal's package test suite
cabal new-build cabal-install:integration-tests # etc...

Running tests

Using Travis and AppVeyor. The easiest way to run tests on Cabal is to make a branch on GitHub and then open a pull request; our continuous integration service on Travis and AppVeyor will build and test your code. Title your PR with WIP so we know that it does not need code review. Alternately, you can enable Travis on your fork in your own username and Travis should build your local branches.

Some tips for using Travis effectively:

  • Watch over your jobs on the Travis website. If you know a build of yours is going to fail (because one job has already failed), be nice to others and cancel the rest of the jobs, so that other commits on the build queue can be processed.

  • If you want realtime notification when builds of your PRs finish, we have a Slack team. To get issued an invite, fill in your email at this sign up page.

  • If you enable Travis for the fork of Cabal in your local GitHub, you can have builds done automatically for your local branch seperate from Cabal. This is an alternative to opening a PR.

Running tests locally. To run tests locally with new-build, you will need to know the name of the test suite you want. Cabal and cabal-install have several. In general, the test executable for {Cabal,cabal-install}:$TESTNAME will be stored at dist-newstyle/build/{Cabal,cabal-install}-$VERSION/build/$TESTNAME/$TESTNAME.

To run a single test, use -p which applies a regex filter to the test names.

  • Cabal:package-tests are out-of-process integration tests on the top-level Setup command line interface. If you are hacking on the Cabal library you want to run this test suite. It must be run from the Cabal subdirectory (ugh!) This test suite can be a bit touchy; see Cabal/tests/README.md for more information. Build products and test logs are generated and stored in Cabal/tests/PackageTests under folders named dist-test and dist-test.$subname.

    Handy command line spell to find test logs is:

    find . -name test.log|grep test-name

    test.sh in the same directory as test.log is intended to let you rerun the test without running the actual test driver.

  • Cabal:unit-tests are small, quick-running unit tests on small pieces of functionality in Cabal. If you are working on some utility functions in the Cabal library you should run this test suite.

  • cabal-install:unit-tests are small, quick-running unit tests on small pieces of functionality in cabal-install. If you are working on some utility functions in cabal-install you should run this test suite.

  • cabal-install:solver-quickcheck are QuickCheck tests on cabal-install's dependency solver. If you are working on the solver you should run this test suite.

  • cabal-install:integration-tests are out-of-process integration tests on the top-level cabal command line interface. The coverage is not very good but it attempts to exercise most of cabal-install.

  • cabal-install:integration-tests2 are integration tests on some top-level API functions inside the cabal-install source code. You should also run this test suite.

Conventions

  • Spaces, not tabs.

  • Try to follow style conventions of a file you are modifying, and avoid gratuitous reformatting (it makes merges harder!)

  • A lot of Cabal does not have top-level comments. We are trying to fix this. If you add new top-level definitions, please Haddock them; and if you spend some time understanding what a function does, help us out and add a comment. We'll try to remind you during code review.

  • If you do something tricky or non-obvious, add a comment.

  • For local imports (Cabal module importing Cabal module), import lists are NOT required (although you may use them at your discretion.) For third-party and standard library imports, please use explicit import lists.

  • You can use basically any GHC extension supported by a GHC in our support window, except Template Haskell, which would cause bootstrapping problems in the GHC compilation process.

  • Our GHC support window is five years for the Cabal library and three years for cabal-install: that is, the Cabal library must be buildable out-of-the-box with the dependencies that shipped with GHC for at least five years. The Travis CI checks this, so most developers submit a PR to see if their code works on all these versions of GHC. cabal-install must also be buildable on all supported GHCs, although it does not have to be buildable out-of-the-box. Instead, the cabal-install/bootstrap.sh script must be able to download and install all of the dependencies. (This is also checked by CI!)

  • Cabal has its own Prelude, in Distribution.Compat.Prelude, that provides a compatibility layer and exports some commonly used additional functions. Use it in all new modules.

  • As far as possible, please do not use CPP. If you must use it, try to put it in a Compat module, and minimize the amount of code that is enclosed by CPP. For example, prefer:

    f :: Int -> Int
    #ifdef mingw32_HOST_OS
    f = (+1)
    #else
    f = (+2)
    #endif

    over:

    #ifdef mingw32_HOST_OS
    f :: Int -> Int
    f = (+1)
    #else
    f :: Int -> Int
    f = (+2)
    #endif

We like this style guide.

Communicating

There are a few main venues of communication:

  • Most developers subscribe to receive messages from all issues; issues can be used to open discussion. If you know someone who should hear about a message, CC them explicitly using the @username GitHub syntax.

  • For more organizational concerns, the mailing list is used.

  • Many developers idle on #hackage on irc.freenode.net. #ghc is also a decently good bet.

Releases

Notes for how to make a release are at the wiki page "Making a release". Currently, @23Skidoo, @rthomas, @tibbe and @dcoutts have access to haskell.org/cabal, and @davean is the point of contact for getting permissions.

API Documentation

Auto-generated API documentation for the master branch of Cabal is automatically uploaded here: http://haskell.github.io/cabal-website/doc/html/Cabal/.