<commit_before>#! /usr/bin/env python2

import argparse
import os
import os.path
import subprocess
import sys


ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))

def run_program(*argv):
    print "$ %s" % " ".join(argv)
    p = subprocess.Popen(
        argv,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE
    )
    stdout, stderr = p.communicate()

    try:
        stdout = stdout.decode('ascii')
    except UnicodeError:
        return 'stdout is not ASCII'

    try:
        stderr = stderr.decode('ascii')
    except UnicodeError:
        return 'stderr is not ASCII'

    return (p.returncode, stdout, stderr)


def gprbuild(project_file, debug=False, rts_profile=None):
    extra_args = []

    if rts_profile:
        extra_args = extra_args + ["-XRTS=" + rts_profile]

    extra_args = extra_args + ["-XPLATFORM_BUILD=" + ("Debug" if debug else "Production")]

    print "Building '%s'" % project_file

    # Build the project
    returncode, stdout, stderr = run_program(
        'gprbuild', '-j0', '-p', '-q', '-P', project_file, *extra_args
    )

    print stdout

    if returncode:
        print 'Build error (gprbuild returned {}):\n{}'.format(
            returncode, stderr
        )

    # Clean to avoid error in the next build with a different run-time or
    # compile switches.
    run_program ('gprclean', "-P",  project_file, *extra_args)

    return returncode
<commit_msg>when building all the examples, now use RTS_Profile instead of RTS<commit_after>#! /usr/bin/env python2

import argparse
import os
import os.path
import subprocess
import sys


ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))

def run_program(*argv):
    print "$ %s" % " ".join(argv)
    p = subprocess.Popen(
        argv,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE
    )
    stdout, stderr = p.communicate()

    try:
        stdout = stdout.decode('ascii')
    except UnicodeError:
        return 'stdout is not ASCII'

    try:
        stderr = stderr.decode('ascii')
    except UnicodeError:
        return 'stderr is not ASCII'

    return (p.returncode, stdout, stderr)


def gprbuild(project_file, debug=False, rts_profile=None):
    extra_args = []

    if rts_profile:
        extra_args = extra_args + ["-XRTS_Profile=" + rts_profile]

    extra_args = extra_args + ["-XPLATFORM_BUILD=" + ("Debug" if debug else "Production")]

    print "Building '%s'" % project_file

    # Build the project
    returncode, stdout, stderr = run_program(
        'gprbuild', '-j0', '-p', '-q', '-P', project_file, *extra_args
    )

    print stdout

    if returncode:
        print 'Build error (gprbuild returned {}):\n{}'.format(
            returncode, stderr
        )

    # Clean to avoid error in the next build with a different run-time or
    # compile switches.
    run_program ('gprclean', "-P",  project_file, *extra_args)

    return returncode

{'fraction_non_alphanumeric': 0.12198436969079171, 'fraction_numerical': 0.0013591573224600749, 'mean_word_length': 2.769526248399488, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1855662', 'n_tokens_mistral': 998, 'n_tokens_neox': 939, 'n_words': 256}