summaryrefslogtreecommitdiff
path: root/hadrian/src/Target.hs
blob: 30c8d98d1442cceaa7390595efb5630ff9fa5e58 (plain)
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
module Target (
    Target, target, context, builder, inputs, outputs, trackArgument,
    module Builder
    ) where

import Data.Char
import Data.List.Extra

import qualified Hadrian.Target as H
import Hadrian.Target hiding (Target)

import Builder
import Context

type Target = H.Target Context Builder

-- | Some arguments do not affect build results and therefore do not need to be
-- tracked by the build system. A notable example is "-jN" that controls Make's
-- parallelism. Given a 'Target' and an argument, this function should return
-- 'True' only if the argument needs to be tracked.
trackArgument :: Target -> String -> Bool
trackArgument target arg = case builder target of
    (Make _) -> not $ threadArg arg
    _        -> True
  where
    threadArg s = dropWhileEnd isDigit s `elem` ["-j", "MAKEFLAGS=-j", "THREADS="]