1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- Module to represent the structure of Ninja build files
--- @author Marc Andre Wittorf
--- @version 0.1

module Ninja.Types(
  File(..), Decl(..),
  Def, Target, RuleName
) where

import FilePath

-- This tries to be as close as possible to Ninja file reference
-- https://ninja-build.org/manual.html#_Ninja_file_reference
-- Also names are, if possible, taken or derived from those notations

--- A Ninja file
data File = File [Decl]

--- A Ninja declaration
--- @cons Rule     a build rule
--- @cons Edge     a build edge
--- @cons Var      a global variable definition
--- @cons Default  a default edge specification
--- @cons Subninja a subninja directive
--- @cons Include  an include directive
--- @cons Pool     a pool section
data Decl
  = Rule RuleName -- name
         [Def]    -- variable definitions
  | Edge RuleName -- rule name
         [Target] -- outputs
         [Target] -- implicit outputs
         [Target] -- dependencies
         [Target] -- implicit dependencies
         [Target] -- order only dependencies
         [Def]    -- variable definitions for this build
  | Var Def
  | Default Target
  | Subninja FilePath
  | Include FilePath
  | Pool String
         [Def]

--- A Ninja definition (variable, value)
type Def = (String, String)

--- A Ninja target
type Target = String

--- A Ninja rule name
type RuleName = String