<commit_before>#!/usr/bin/runghc

import System.Environment (getArgs)
import System.Process (system)
import Data.List (intercalate)
import System.Exit (exitFailure, exitWith, ExitCode(..))

data BuildEnv =
  BuildEnv
    { ghcPath :: String
    , ghcJs :: String
    , dstPath :: String
    }

main = do
    args <- getArgs
    putStrLn $ show args
    let (conv, ghcp) = case args of
            (conv:ghcp:_) -> (conv, ghcp)
            []            -> ("trampoline", "../ghc")
            _             -> error "Invalid arguments for BuildTest"
        env =
               BuildEnv
                 { ghcPath = ghcp
                 , ghcJs = "dist/build/ghcjs/ghcjs"
                 , dstPath = "examples"
                 }
    mapM_ (checkExit . system . uncurry (buildCommand conv env)) packages
    checkExit . system . intercalate " " $ [ ghcJs env, "--calling-convention="++conv,
        "-o", concat [dstPath env, "/main.js"],
        concat ["-i", dstPath env, "/main"], "Test" ]
    checkExit . system . intercalate " " $ [
        "dist/build/ghcjs-link/ghcjs-link",
        "-Xmx1G", "-jar", "~/closure-compiler/compiler.jar",
        "--pages_module", "Test",
        "--js", "~/closure-library/closure/goog/base.js",
        "--js", "../ghcjs-rts/rts-common.js",
        "--define='HS_DEBUG=false'",
        "--js", concat ["../ghcjs-rts/rts-", conv, ".js"],
        "--module", "rts:3:",
        "--hjs", concat [dstPath env, "/ghc-prim"],
        "--hjs", concat [dstPath env, "/integer-simple"],
        "--hjs", concat [dstPath env, "/base"],
        "--hjs", concat [dstPath env, "/main"],
        "--js", "examples/TestJS.js",
        "--module", "test:2:rts",
        "--module_output_path_prefix", concat [dstPath env, "/"],
        "--compilation_level", "ADVANCED_OPTIMIZATIONS",
        "--manage_closure_dependencies"]
    checkExit $ system "open examples/test.html"
  where
    checkExit f = do
        result <- f
        case result of
            ExitSuccess -> return ()
            _           -> exitWith result

packages =
  [ ( "ghc-prim"
    , [ "GHC.Debug"
      , "GHC.Generics"
      , "GHC.IntWord64"
      , "GHC.Tuple"
      , "GHC.Types"
      , "GHC.Classes"
      ]<commit_msg>Fix paths to rts files and don't use --manage_closure_dependencies in test<commit_after>#!/usr/bin/runghc

import System.Environment (getArgs)
import System.Process (system)
import Data.List (intercalate)
import System.Exit (exitFailure, exitWith, ExitCode(..))

data BuildEnv =
  BuildEnv
    { ghcPath :: String
    , ghcJs :: String
    , dstPath :: String
    }

main = do
    args <- getArgs
    putStrLn $ show args
    let (conv, ghcp) = case args of
            (conv:ghcp:_) -> (conv, ghcp)
            []            -> ("trampoline", "../ghc")
            _             -> error "Invalid arguments for BuildTest"
        env =
               BuildEnv
                 { ghcPath = ghcp
                 , ghcJs = "dist/build/ghcjs/ghcjs"
                 , dstPath = "examples"
                 }
    mapM_ (checkExit . system . uncurry (buildCommand conv env)) packages
    checkExit . system . intercalate " " $ [ ghcJs env, "--calling-convention="++conv,
        "-o", concat [dstPath env, "/main.js"],
        concat ["-i", dstPath env, "/main"], "Test" ]
    checkExit . system . intercalate " " $ [
        "dist/build/ghcjs-link/ghcjs-link",
        "-Xmx1G", "-jar", "~/closure-compiler/compiler.jar",
        "--pages_module", "Test",
        "--js", "~/closure-library/closure/goog/base.js",
        "--js", concat [dstPath env, "/rts-common.js"],
        "--define='HS_DEBUG=false'",
        "--js", concat [dstPath env, "/rts-", conv, ".js"],
        "--module", "rts:3:",
        "--hjs", concat [dstPath env, "/ghc-prim"],
        "--hjs", concat [dstPath env, "/integer-simple"],
        "--hjs", concat [dstPath env, "/base"],
        "--hjs", concat [dstPath env, "/main"],
        "--js", "examples/TestJS.js",
        "--module", "test:2:rts",
        "--module_output_path_prefix", concat [dstPath env, "/"],
        "--compilation_level", "ADVANCED_OPTIMIZATIONS"]
    checkExit $ system "open examples/test.html"
  where
    checkExit f = do
        result <- f
        case result of
            ExitSuccess -> return ()
            _           -> exitWith result

packages =
  [ ( "ghc-prim"
    , [ "GHC.Debug"
      , "GHC.Generics"
      , "GHC.IntWord64"
      , "GHC.Tuple"
      , "GHC.Types"
      , "GHC.Classes"
      ]
{'fraction_non_alphanumeric': 0.16967267869071476, 'fraction_numerical': 0.00222667557336896, 'mean_word_length': 1.8813341885824246, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '3474839', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1454, 'n_words': 328}