<commit_before>import os
import itertools
import platform
import subprocess
import sys

import lit.util
from lit.llvm import llvm_config
from lit.llvm.subst import FindTool
from lit.llvm.subst import ToolSubst

def use_lldb_substitutions(config):
    # Set up substitutions for primary tools.  These tools must come from config.lldb_tools_dir
    # which is basically the build output directory.  We do not want to find these in path or
    # anywhere else, since they are specifically the programs which are actually being tested.

    dsname = 'debugserver' if platform.system() in ['Darwin'] else 'lldb-server'
    dsargs = [] if platform.system() in ['Darwin'] else ['gdbserver']
    lldbmi = ToolSubst('%lldbmi',
                       command=FindTool('lldb-mi'),
                       extra_args=['--synchronous'],
                       unresolved='ignore')


    build_script = os.path.dirname(__file__)
    build_script = os.path.join(build_script, 'build.py')
    build_script_args = [build_script,
                        '--compiler=any', # Default to best compiler
                        '--arch=' + str(config.lldb_bitness)]
    if config.lldb_lit_tools_dir:
        build_script_args.append('--tools-dir={0}'.format(config.lldb_lit_tools_dir))
    if config.lldb_tools_dir:
        build_script_args.append('--tools-dir={0}'.format(config.lldb_tools_dir))
    if config.llvm_libs_dir:
        build_script_args.append('--libs-dir={0}'.format(config.llvm_libs_dir))

    primary_tools = [
        ToolSubst('%lldb',
                  command=FindTool('lldb'),
                  extra_args=['--no-lldbinit', '-S',
                              os.path.join(config.test_exec_root,
                                           'lit-lldb-init')]),
        ToolSubst('%lldb-init',
                  command=FindTool('lldb'),
                  extra_args=['-S',
                              os.path.join(config.test_exec_root,
                                           'lit-lldb-init')]),
        lldbmi,
        ToolSubst('%debugserver',
                  command=FindTool(dsname),
                  extra_args=dsargs,
                  unresolved='ignore'),
        ToolSubst('%platformserver',
                  command=FindTool('lldb-server'),
                  extra_args=['platform'],
                  unresolved='ignore'),
        'lldb-test',<commit_msg>[lit] Deduplicate logic in toolchain.py<commit_after>import os
import itertools
import platform
import subprocess
import sys

import lit.util
from lit.llvm import llvm_config
from lit.llvm.subst import FindTool
from lit.llvm.subst import ToolSubst

def use_lldb_substitutions(config):
    # Set up substitutions for primary tools.  These tools must come from config.lldb_tools_dir
    # which is basically the build output directory.  We do not want to find these in path or
    # anywhere else, since they are specifically the programs which are actually being tested.

    dsname = 'debugserver' if platform.system() in ['Darwin'] else 'lldb-server'
    dsargs = [] if platform.system() in ['Darwin'] else ['gdbserver']
    lldbmi = ToolSubst('%lldbmi',
                       command=FindTool('lldb-mi'),
                       extra_args=['--synchronous'],
                       unresolved='ignore')


    build_script = os.path.dirname(__file__)
    build_script = os.path.join(build_script, 'build.py')
    build_script_args = [build_script,
                        '--compiler=any', # Default to best compiler
                        '--arch=' + str(config.lldb_bitness)]
    if config.lldb_lit_tools_dir:
        build_script_args.append('--tools-dir={0}'.format(config.lldb_lit_tools_dir))
    if config.lldb_tools_dir:
        build_script_args.append('--tools-dir={0}'.format(config.lldb_tools_dir))
    if config.llvm_libs_dir:
        build_script_args.append('--libs-dir={0}'.format(config.llvm_libs_dir))

    lldb_init = os.path.join(config.test_exec_root, 'lit-lldb-init')

    primary_tools = [
        ToolSubst('%lldb',
                  command=FindTool('lldb'),
                  extra_args=['--no-lldbinit', '-S', lldb_init]),
        ToolSubst('%lldb-init',
                  command=FindTool('lldb'),
                  extra_args=['-S', lldb_init]),
        lldbmi,
        ToolSubst('%debugserver',
                  command=FindTool(dsname),
                  extra_args=dsargs,
                  unresolved='ignore'),
        ToolSubst('%platformserver',
                  command=FindTool('lldb-server'),
                  extra_args=['platform'],
                  unresolved='ignore'),
        'lldb-test',
{'fraction_non_alphanumeric': 0.11578490893321769, 'fraction_numerical': 0.0013009540329575022, 'mean_word_length': 2.2168758716875874, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2607625', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1347, 'n_words': 270}