<commit_before>{-# LANGUAGE RecordWildCards, OverloadedStrings #-}

module OS.Win.WinRules
    ( copyWinTargetExtras
    , pkgrootConfFixup
    , winGhcInstall
    , winRules
    )
  where

import qualified Data.ByteString as B
import qualified Data.Text as T
import qualified Data.Text.Encoding as E
import Development.Shake
import Development.Shake.FilePath ( (</>), takeDirectory )

import Dirs
import OS.Internal
import OS.Win.WinNsis
import OS.Win.WinPaths
import OS.Win.WinUtils
import Paths
import Types
import Utils


winRules :: Rules ()
winRules = do
    genNsisData
    genNsisFile
    copyInstExtras

winGhcInstall :: FilePath -> GhcInstallAction
winGhcInstall destDir bc distDir = do
    let untarDir = takeDirectory distDir

    -- (will this cause some race conditions, removing vs populating?)
    command_ [] "mv" [untarDir </> show (bcGhcVersion bc), destDir ]

    -- Install the GLUT components into destDir:
    --   lib, dll, ...
    let winGlutLibSrc = winExternalGlutLibDir bc </> winGlutLibFile
        winGlutDllSrc = winExternalGlutLibDir bc </> winGlutDllFile
        winGlutLibInstallDir = destDir </> winGlutLibDir
        winGlutDllInstallDir = destDir </> winGlutDllDir
    command_ [] "cp" [ "-p", winGlutLibSrc, winGlutLibInstallDir ]
    command_ [] "cp" [ "-p", winGlutDllSrc, winGlutDllInstallDir ]

    --   ... and the include files
    let setup = makeDirectory winGlutIncludeInstallDir
        winGlutIncludeInstallDir = destDir </> winGlutIncludeDir

    winGlutIncSrcs <- getDirectoryContents winExternalGlutIncDir
    copyFilesAction setup winExternalGlutIncDir winGlutIncludeInstallDir
        winGlutIncSrcs
    needContents winGlutIncludeInstallDir

    return destDir


copyWinTargetExtras :: BuildConfig -> Action ()
copyWinTargetExtras bc = do
    -- copy icons
    let mkIconsDir = makeDirectory $ winTargetDir </> "icons"
    copyFilesAction mkIconsDir winExtrasSrc winTargetDir winIconsFiles

    -- copy user's guide docs: ps, pdf, html, etc....
    copyDirAction winExternalDocs winDocTargetDir

    -- copy winghci pieces
    copyDirAction winExternalWinGhciDir winWinGhciTargetDir

    -- copy msys(msys2) pieces
    copyDirAction (winExternalMSysDir bc) winMSysTargetDir
<commit_msg>distribute stack with windows<commit_after>{-# LANGUAGE RecordWildCards, OverloadedStrings #-}

module OS.Win.WinRules
    ( copyWinTargetExtras
    , pkgrootConfFixup
    , winGhcInstall
    , winRules
    )
  where

import qualified Data.ByteString as B
import qualified Data.Text as T
import qualified Data.Text.Encoding as E
import Development.Shake
import Development.Shake.FilePath ( (</>), takeDirectory, takeFileName )

import Config
import Dirs
import OS.Internal
import OS.Win.WinNsis
import OS.Win.WinPaths
import OS.Win.WinUtils
import Paths
import Types
import Utils


winRules :: Rules ()
winRules = do
    genNsisData
    genNsisFile
    copyInstExtras

winGhcInstall :: FilePath -> GhcInstallAction
winGhcInstall destDir bc distDir = do
    let untarDir = takeDirectory distDir

    -- (will this cause some race conditions, removing vs populating?)
    command_ [] "mv" [untarDir </> show (bcGhcVersion bc), destDir ]

    -- Install the GLUT components into destDir:
    --   lib, dll, ...
    let winGlutLibSrc = winExternalGlutLibDir bc </> winGlutLibFile
        winGlutDllSrc = winExternalGlutLibDir bc </> winGlutDllFile
        winGlutLibInstallDir = destDir </> winGlutLibDir
        winGlutDllInstallDir = destDir </> winGlutDllDir
    command_ [] "cp" [ "-p", winGlutLibSrc, winGlutLibInstallDir ]
    command_ [] "cp" [ "-p", winGlutDllSrc, winGlutDllInstallDir ]

    --   ... and the include files
    let setup = makeDirectory winGlutIncludeInstallDir
        winGlutIncludeInstallDir = destDir </> winGlutIncludeDir

    winGlutIncSrcs <- getDirectoryContents winExternalGlutIncDir
    copyFilesAction setup winExternalGlutIncDir winGlutIncludeInstallDir
        winGlutIncSrcs
    needContents winGlutIncludeInstallDir

    return destDir


copyWinTargetExtras :: BuildConfig -> Action ()
copyWinTargetExtras bc = do
    -- copy icons
    let mkIconsDir = makeDirectory $ winTargetDir </> "icons"
    copyFilesAction mkIconsDir winExtrasSrc winTargetDir winIconsFiles

    -- copy user's guide docs: ps, pdf, html, etc....
    copyDirAction winExternalDocs winDocTargetDir

    -- copy winghci pieces
    copyDirAction winExternalWinGhciDir winWinGhciTargetDir

    -- copy msys(msys2) pieces
    copyDirAction (winExternalMSysDir bc) winMSysTargetDir

    -- copy stack executable
    stackFile <- askStackExe
    copyFileAction (return ()) (takeDirectory stackFile) (winHpTargetDir </> "bin") (takeFileName stackFile)


{'fraction_non_alphanumeric': 0.07369542066027689, 'fraction_numerical': 0.0004259850905218317, 'mean_word_length': 3.714859437751004, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5874078', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1421, 'n_words': 379}