MyNixOS website logo
Description

A library and an executable that provide an easy API for a Haskell IDE.

Buildwrapper is an alternative to scion. It provides services to configure, build and give information on source files to help IDEs manage Haskell projects. You can use buildwrapper to build project and retrieve errors, get outline for each module source, get the type of something inside a source file, get lexer tokens, etc. Buildwrapper is used in the EclipseFP project (Eclipse plugins for Haskell development)

BuildWrapper

Build Status

BuildWrapper is a program designed to help an IDE deal with a Haskell project. It combines several tools under a simple API:

  • Cabal to configure and build the project. BuildWrapper works best on project that provide a cabal file.
  • GHC to load a particular file or buffer and generate a typechecked AST
  • Haskell-src-exts to parse a particular file and generate an outline

BuildWrapper provides a library and an executable. Intended usage is mostly through the executable. This is how it's used by EclipseFP, the set of Haskell development plugins for the Eclipse IDE. This executable is short-lived, it is not a running server as scion (the project BuildWrapper is an evolution of) or scion-browser. You launch it with parameters, it perform some work, and returns a JSON result. BuildWrapper uses a temporary work folder inside the project to store both a copy of the source files and the result of its operations. In an IDE setting, the content of the temporary folder may contain files representing unsaved data, which allow BuildWrapper to use Cabal and file based operations regardless.

You can run buildwrapper --help to get a feel for the different options you can call buildwrapper with. You can also run EclipseFP with the debug mode preference on to see the BuildWrapper interaction in an Eclipse console view.

Generic options

These options are available to all commands.

  • tempfolder: the name of the temporary folder, relative to the location of the project cabal file. Usually .dist-buildwrapper
  • cabalpath: the location of the cabal executable
  • cabalfile: the location of the project cabal file
  • cabalflags: the flags to pass to cabal when configuring
  • logcabal: should the call to the cabal executable be logged?

synchronize

Synchronize ensures that all the files in the temporary work folder represent the up to date version of the source files. It returns the list of files actually copied from the main folder to the work folder.

  • force: true/false: copies files even if destination (in temporary folder) is newer

Example: buildwrapper synchronize --force=false --tempfolder=.dist-buildwrapper --cabalpath=/home/myuser/.cabal/bin/cabal --cabalfile=/home/myuser/myproject/myproject.cabal --cabalflags= --logcabal=true

synchronize1

Synchronizes only one file.

  • file: the relative path of the file to synchronize (relative to the project root)
  • force: true/false: copies files even if destination (in temporary folder) is newer

write

Updates the content of the file in the work folder. Note that an external tool could also write directly in the work folder.

  • file: the relative path of the file to update (relative to the project root)
  • contents: the contents to write

configure

Runs cabal configure on the project. This command usually is not needed, as the build command will trigger a configure if needed. Returns the errors encountered, if any.

  • verbosity: the verbosity of Cabal output
  • cabaltarget: Source|Target: use the original cabal file or the one in the work folder

build

Runs cabal build on the project. Returns the errors encountered, if any, and the files processed during that build.

  • verbosity: the verbosity of Cabal output
  • cabaltarget: Source|Target: use the original cabal file or the one in the work folder
  • output: true|false: should we actually run the linker and generates output

Example: buildwrapper build --output=true --cabaltarget=Source --tempfolder=.dist-buildwrapper --cabalpath=/home/myuser/.cabal/bin/cabal --cabalfile=/home/myuser/myproject/myproject.cabal --cabalflags= --logcabal=true

build1

Build one file using the GHC API. BuildWrapper takes care of calling the API with the proper flags from the cabal file. Returns the errors encountered during the build, if any. The AST and the build flags used are stored in a hidden file alongside the source file in the work folder. This file, with the .bwinfo extension, is plain JSON and can be parsed by an external tool if need be.

  • file: the relative path of the file to update (relative to the project root)

getbuildflags

Returns the build flags use to build a particular file

  • file: the relative path of the file to update (relative to the project root)

outline

Returns an outline of the file: the top level declarations, the import and export statements. This is generated using haskell-src-exts so the file does not need to be correct in respect to the typechecker, but needs to be valid Haskell syntax. If need be, the file is pre-processed by cpp2hs.

  • file: the relative path of the file to update (relative to the project root)

tokentypes

Returns a collection of lexer tokens for a particular file. The tokens have a type assigned to them (documentation, symbols, etc). This is used to provide syntax coloring in an IDE. If need be, the file is pre-processed and the preprocessor tokens are returned in the collection too.

  • file: the relative path of the file to update (relative to the project root)

occurrences

Find all occurrences of the given text in lexer tokens. Only fully matching tokens are retrieved.

  • file: the relative path of the file to update (relative to the project root)
  • token: the token text to search for

thingatpoint

Returns the object found at a particular point in a source. Information can include a name, a module, a type, a haddock type code. This uses the generated .bwinfo file to perform the search so does not invoke the GHC API unless necessary (.bwinfo file missing or older than source)

  • file: the relative path of the file to update (relative to the project root)
  • line: the line to look at
  • column: the column to look at

namesinscope

Returns the list of names in scope (GHC API call)

  • file: the relative path of the file to update (relative to the project root)

locals

Returns the list of names defined locally to a point in the source (inside the function, say)

  • file: the relative path of the file to update (relative to the project root)
  • sline: the start line of the defining scope
  • scolumn: the start column of the defining scope
  • eline: the end line of the defining scope
  • ecolumn: the end column of the defining scope

cleanimports

Returns the cleaned imports line: the location and import text for the minimal required imports

  • file: the relative path of the file to update (relative to the project root)

dependencies

Returns the list of all package dependencies for all cabal components in the cabal file, with the package database they are registered in

components

Returns the list of all components of the cabal file (executables, library, test suites)

Metadata

Version

0.9.1

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows