<commit_before>{-# LANGUAGE RecordWildCards #-}
module Rules.Register (registerPackage) where

import Data.Char

import Base
import Context
import Expression
import GHC
import Rules.Actions
import Rules.Libffi
import Settings
import Settings.Packages.Rts
import Target

-- Build package-data.mk by using GhcCabal to process pkgCabal file
registerPackage :: [(Resource, Int)] -> Context -> Rules ()
registerPackage rs context @ (Context {..}) = do
    let oldPath = pkgPath package -/- targetDirectory stage package -- TODO: remove, #113
        pkgConf = packageDbDirectory stage -/- pkgNameString package
        match f = case stripPrefix (pkgConf ++ "-") f of
            Nothing  -> False
            Just suf -> dropWhile (\c -> isDigit c || c == '.') suf == "conf"

    when (stage <= Stage1) $ match ?> \conf -> do
        -- This produces pkgConfig. TODO: Add explicit tracking
        need [pkgDataFile stage package]<commit_msg>Use matchVersionedFilePath in registerPackage build rule.<commit_after>{-# LANGUAGE RecordWildCards #-}
module Rules.Register (registerPackage) where

import Base
import Context
import Expression
import GHC
import Rules.Actions
import Rules.Libffi
import Settings
import Settings.Packages.Rts
import Target

-- Build package-data.mk by using GhcCabal to process pkgCabal file
registerPackage :: [(Resource, Int)] -> Context -> Rules ()
registerPackage rs context @ (Context {..}) = do
    let oldPath = pkgPath package -/- targetDirectory stage package -- TODO: remove, #113
        pkgConf = packageDbDirectory stage -/- pkgNameString package

    when (stage <= Stage1) $ matchVersionedFilePath pkgConf "conf" ?> \conf -> do
        -- This produces inplace-pkg-config. TODO: Add explicit tracking
        need [pkgDataFile stage package]
{'fraction_non_alphanumeric': 0.09786276715410573, 'fraction_numerical': 0.0044994375703037125, 'mean_word_length': 3.492424242424242, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '1511214', 'n_tokens_mistral': 495, 'n_tokens_neox': 469, 'n_words': 178}