Git Product home page Git Product logo

cabal2bazel's Introduction

cabal2bazel

A tool to help with fetching Cabal packages from Hackage and importing them as packages into cabal2bazel.

Usage: cabal2bazel --fetch

Examples: cabal2bazel --fetch binary cabal2bazel --fetch binary-0.5.0.2 cabal2bazel --recursive --fetch lens

The process for installing third-party Haskell packages is specified at: https://opensource.google.com/docs/thirdparty/haskell/ cabal2bazel does not (yet) capture all the subtleties of this process, and is no substitute for code review. But it will automate the bulk of chores, including:

  • fetching the Cabal package;
  • unpacking it into an appropriate directory;
  • ensuring the license file is in the expected location;
  • generating a BUILD file with suitable rules.
  • if --recursive is specified, traversing graph of all dependencies of selected package and importing all of them.

cabal2bazel attempts to map the dependencies of a Cabal library or executable to the 'deps' attribute of the resulting Bazel target.

Things that still need manual attention include:

  • optimization modes need to be removed from ghcopts, because Bazel chooses them itself;
  • cabal2bazel adds '-Wwarn' to all rules' ghcopts; this might not be desired;
  • correct choice of license attributes should be checked;
  • generated dependencies might need to be adjusted to point to specific versions of the packages depended upon.

NOTE: You will need an appropriate version of 'cabal' to be available on your path; cabal2bazel uses it for downloading and unpacking packages.

NOTE: Sometimes it is necessary to edit the cabal file and re-run cabal2bazel. In such cases rerun cabal2bazel as follows to resume installation:

cabal2bazel --wire-up

Example: cabal2bazel --wire-up //third_party/haskell/binary/v0_5_0_2

cabal2bazel's People

Contributors

blackgnezdo avatar judah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cabal2bazel's Issues

Sharding support for `haskell_library`

Some haskell libraries are big atomic units (e.g. ghc-lib-parser). This causes their build times to grow beyond the limits allowed by certain build platforms, especially in optimized mode. It would be great to have support for chopping up such libraries into smaller units to support building them as a chain of smaller actions culminating in a library which combines all the targets. It's not clear if this is practical to do automatically. I would be happy enough with providing some hints to cabal_haskell_package rule if I can avoid opening up the box and fully expand the generated macros manually.

hsc2hs support is limited

We have incomplete support for hsc2hs. In particular:

  • Pre-procesor defines aren't passed through
  • {MIN_,}VERSION macros aren't passed

The former is easy and requires a simple patch I already developed and can commit soon. The latter required special sorcery in rules_haskell which later was replaced with a different kind of sorcery.

The reason this became a problem is zlib uses MIN_VERSION_base leading to unpleasant errors like

VersionHsc2Hs.hsc:6:5: error: function-like macro 'MIN_VERSION_base' is not defined
#if MIN_VERSION_base(1,2,3)
    ^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.