<commit_before>from SCons.Script import *
import tempfile
from util import replace_suffix, replace_path

#----------------------------------------------------------
# builder: Coregen .xco -> .v, .ngc, .xco, .log
# intermediate step: create .cgp file
#----------------------------------------------------------

def coregen_targets(env, target, source):
    v_file = replace_path(str(target[0]), env['outdir'])
    target = [v_file] + [replace_suffix(v_file, suf)
                         for suf in ['.ngc', '.xco', '.log']]
    return target, source

def run_coregen(env, target, source):
    xco_file = str(source[0])
    work_dir = tempfile.mkdtemp(dir='.')
    out_dir = tempfile.mkdtemp(dir='.')
    options = env['options']
    options['workingdirectory'] = work_dir
    options['outputdirectory'] = out_dir

    # enforce generation of .v file
    options['implementationfiletype']='Ngc'
    options['simulationfiles']='Behavioral'
    options['verilogsim']='true'

    with tempfile.NamedTemporaryFile(suffix='.cgp', dir='.') as f:
        cgp_file = f.name
        for (k, v) in options.iteritems():
            print >> f, "SET %s = %s" % (k, str(v))
        f.flush()
        env.Execute('coregen -b %s -p %s' % (xco_file, cgp_file))

    for t in target[:-1]: # .v, .ngc, .xco<commit_msg>cosmetic changes in coregen options<commit_after>from SCons.Script import *
import tempfile
from util import replace_suffix, replace_path

#----------------------------------------------------------
# builder: Coregen .xco -> .v, .ngc, .xco, .log
# intermediate step: create .cgp file
#----------------------------------------------------------

# enforce generation of .v file
enforced_options = {
    'implementationfiletype': 'Ngc',
    'simulationfiles': 'Behavioral',
    'verilogsim': 'true'
}

def coregen_targets(env, target, source):
    v_file = replace_path(str(target[0]), env['outdir'])
    target = [v_file] + [replace_suffix(v_file, suf)
                         for suf in ['.ngc', '.xco', '.log']]
    return target, source

def run_coregen(env, target, source):
    xco_file = str(source[0])
    work_dir = tempfile.mkdtemp(dir='.')
    out_dir = tempfile.mkdtemp(dir='.')
    options = env['options']
    options['workingdirectory'] = work_dir
    options['outputdirectory'] = out_dir
    options.update(enforced_options)

    with tempfile.NamedTemporaryFile(suffix='.cgp', dir='.') as f:
        cgp_file = f.name
        for (k, v) in options.iteritems():
            print >> f, "SET %s = %s" % (k, str(v))
        f.flush()
        env.Execute('coregen -b %s -p %s' % (xco_file, cgp_file))

    for t in target[:-1]: # .v, .ngc, .xco
{'fraction_non_alphanumeric': 0.2310007524454477, 'fraction_numerical': 0.002257336343115124, 'mean_word_length': 2.258578431372549, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3355428', 'n_tokens_mistral': 869, 'n_tokens_neox': 847, 'n_words': 208}