Code Monkey home page Code Monkey logo

curry-ninja's Introduction

Ninja Generator for Curry

A small library for generating Ninja build files in Curry.

Background

Ninja is a modern, lightweight, low-level alternative to Make that encourages users to generate its build.ninja files rather than writing them by hand. The advantage of this approach is speed, simplicity and debuggability: Ninja can quickly parse the entire dependency graph without having to run through expensive shell calls/globs/etc and the user can easily see what the generated graph expands to. Additionally Ninja offers some conveniences over Make such as automatic folder creation, a nice progress line and better defaults (parallelism, immutable variables, ...). This makes it a great fit for large projects with heavily customized build setups, especially when they involve compiling multiple languages with different compilers and tools.

This Curry library came up as a byproduct from experimenting with a Ninja-based build system for use in the KiCS2 Curry compiler, mostly to see whether creating an expressive DSL for this purpose was possible.

Example

The following is an example of how a simple Ninja file can be expressed in Curry using the NinjaBuilder monad:

import Language.Ninja.Builder
import Language.Ninja.Pretty
import Language.Ninja.Types

main :: IO ()
main = writeFile "build.ninja" $ ppNinja $ execNinjaBuilder $ do
  comment "Flags"
  var $ "cflags" =. "-Wall"
  whitespace

  comment "Rules"
  rule $ (emptyRule "cc")
    { ruleCommand = Just "gcc $cflags -c $in -o $out"
    }
  whitespace

  comment "Builds"
  build $ ["foo.o"] :. ("cc", ["foo.c"])

generates

# Flags
cflags = -Wall

# Rules
rule cc
  command = gcc $cflags -c $in -o $out

# Builds
build foo.o: cc foo.c

Note: Since a transformer version of the monad is available too (NinjaBuilderT), it is easy to create a monad that supports IO (NinjaBuilderT IO) and e.g. generate build files depending on source files in a directory.

curry-ninja's People

Contributors

fwcd avatar

Watchers

 avatar  avatar

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.