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
--- Module for simpler generation of Ninja build files for Extended ICurry
--- @author Marc Andre Wittorf

module ICurry.Extended.Build(
  generateExtendedICurryEdges,
  eicyRule,
  cToEicy
) where

import FilePath
import Ninja.Types
import ICurry.DependencyResolution
import ICurry.Build

--- Generate build edges to translate ICurry to Extended ICurry
--- @param prefix the icy and eicy files are here
--- @param depd   modules with their dependencies
--- @return       (build edge) ninja declarations
generateExtendedICurryEdges :: FilePath -> [ModuleDep] -> [Decl]
generateExtendedICurryEdges = generateEdges "eicy" "icy" "eicy" True Nothing

--- Ninja rule to compile ICurry to Extended ICurry
--- @return the rule declaration
eicyRule :: FilePath -> Decl
eicyRule path = Rule "eicy"
  [("command", "icurry i2e -I \"" ++ path ++ "\" $in $out")]

--- Rules and Edges to compile Curry modules to Extended ICurry
--- @param buildDir the path where I- and Extended ICurry files will be stored
--- @param dg       all modules with their dependencies
--- @return         ninja declarations
cToEicy :: String -> [ModuleDep] -> [Decl]
cToEicy buildDir dg = [tfcyRule, icyRule buildDir, eicyRule buildDir]
                      ++ generateFlatCurryEdges dg
                      ++ generateICurryEdges buildDir dg
                      ++ generateExtendedICurryEdges buildDir dg