<commit_before>-------------------------------------------------------------------------
-- Copyright (c) 2007-2011, 2012 ETH Zurich.
-- All rights reserved.
--
-- This file is distributed under the terms in the attached LICENSE file.
-- If you do not find this file, copies can be found by writing to:-
-- ETH Zurich D-INFK CAB F.78, Universitaetstr 6, CH-8092 Zurich. 
-- Attn: Systems Group.
--
-- Basic Hake rule definitions and combinators
--
--------------------------------------------------------------------------

module RuleDefs where
import Data.List (intersect, isSuffixOf, union, (\\), nub, sortBy, elemIndex)
import Path
import qualified X86_64
import qualified K1om
import qualified X86_32
import qualified SCC
import qualified ARMv5
import qualified ARM11MP
import qualified XScale
import qualified ARMv7
import qualified ARMv7_M
import HakeTypes
import qualified Args
import qualified Config

import Debug.Trace
-- enable debug spew
-- should we move this to Config.hs? -AB
debugFlag = False

--
-- Is a token to be displayed in a rule?
--
inRule :: RuleToken -> Bool
inRule (Dep _ _ _) = False
inRule (PreDep _ _ _) = False
inRule (Target _ _) = False
inRule _ = True

--
-- Look for a set of files: this is called using the "find" combinator
--
withSuffix :: [String] -> String -> String -> [String]
withSuffix af tf arg =
    [ basename f | f <- af, f `isInSameDirAs` tf, isSuffixOf arg f ]
withSuffices :: [String] -> String -> [String] -> [String]
withSuffices af tf args =
    concat [ withSuffix af tf arg | arg <- args ]

--
-- Find files with a given suffix in a given dir
--
inDir :: [String] -> String -> String -> String -> [String]
inDir af tf dir suffix =
    -- Dummy is here so that we can find files in the same dir :-/
    let subdir = (if head dir == '/' then absdir else reldir) ./. "dummy"
        absdir = if head tf == '/' then dir else '.':dir
        reldir = (dirname tf) ./. dir
        files = withSuffix af subdir suffix
    in
        [ dir ./. f | f <- files ]

cInDir :: [String] -> String -> String -> [String]
cInDir af tf dir = inDir af tf dir ".c"
cxxInDir :: [String] -> String -> String -> [String]
cxxInDir af tf dir = inDir af tf dir ".cpp"
sInDir :: [String] -> String -> String -> [String]
sInDir af tf dir = inDir af tf dir ".S"

-------------------------------------------------------------------------
--
-- Architecture specific definitions
--<commit_msg>hake: added *.cc endings for finding C++ files.<commit_after>-------------------------------------------------------------------------
-- Copyright (c) 2007-2011, 2012 ETH Zurich.
-- All rights reserved.
--
-- This file is distributed under the terms in the attached LICENSE file.
-- If you do not find this file, copies can be found by writing to:-
-- ETH Zurich D-INFK CAB F.78, Universitaetstr 6, CH-8092 Zurich. 
-- Attn: Systems Group.
--
-- Basic Hake rule definitions and combinators
--
--------------------------------------------------------------------------

module RuleDefs where
import Data.List (intersect, isSuffixOf, union, (\\), nub, sortBy, elemIndex)
import Path
import qualified X86_64
import qualified K1om
import qualified X86_32
import qualified SCC
import qualified ARMv5
import qualified ARM11MP
import qualified XScale
import qualified ARMv7
import qualified ARMv7_M
import HakeTypes
import qualified Args
import qualified Config

import Debug.Trace
-- enable debug spew
-- should we move this to Config.hs? -AB
debugFlag = False

--
-- Is a token to be displayed in a rule?
--
inRule :: RuleToken -> Bool
inRule (Dep _ _ _) = False
inRule (PreDep _ _ _) = False
inRule (Target _ _) = False
inRule _ = True

--
-- Look for a set of files: this is called using the "find" combinator
--
withSuffix :: [String] -> String -> String -> [String]
withSuffix af tf arg =
    [ basename f | f <- af, f `isInSameDirAs` tf, isSuffixOf arg f ]
withSuffices :: [String] -> String -> [String] -> [String]
withSuffices af tf args =
    concat [ withSuffix af tf arg | arg <- args ]

--
-- Find files with a given suffix in a given dir
--
inDir :: [String] -> String -> String -> String -> [String]
inDir af tf dir suffix =
    -- Dummy is here so that we can find files in the same dir :-/
    let subdir = (if head dir == '/' then absdir else reldir) ./. "dummy"
        absdir = if head tf == '/' then dir else '.':dir
        reldir = (dirname tf) ./. dir
        files = withSuffix af subdir suffix
    in
        [ dir ./. f | f <- files ]

cInDir :: [String] -> String -> String -> [String]
cInDir af tf dir = inDir af tf dir ".c"
cxxInDir :: [String] -> String -> String -> [String]
cxxInDir af tf dir = (inDir af tf dir ".cpp") ++ (inDir af tf dir ".cc")
sInDir :: [String] -> String -> String -> [String]
sInDir af tf dir = inDir af tf dir ".S"

-------------------------------------------------------------------------
--
-- Architecture specific definitions
--
{'fraction_non_alphanumeric': 0.1960824321567027, 'fraction_numerical': 0.013466639461334421, 'mean_word_length': 2.1005692599620494, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7611821', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1404, 'n_words': 608}