<commit_before>import os
import subprocess
from .simulator import Simulator
import logging

logger = logging.getLogger(__name__)

class SimulatorIcarus(Simulator):

    def __init__(self, system):
        logger.debug('__init__() *Entered*')
        super(SimulatorIcarus, self).__init__(system)
        self.sim_root = os.path.join(self.build_root, 'sim-icarus')

        if system.config.has_option('icarus', 'iverilog_options'):
            self.iverilog_options = system.config.get('icarus','iverilog_options').split()
            logger.debug("self.iverilog_options=" + str(self.iverilog_options))
        else:
            self.iverilog_options = []
            logger.debug("No icarus iverilog_options"); # TODO: Remove this temporary line
        logger.debug('__init__() -Done-')

    def configure(self):
        logger.debug('configure() *Entered*')
        super(SimulatorIcarus, self).configure()
        self._write_config_files()
        logger.debug('configure()  -Done-')

    def _write_config_files(self):
        logger.debug('_write_config_files() *Entered*')
        icarus_file = 'icarus.scr'

        f = open(os.path.join(self.sim_root,icarus_file),'w')

        for include_dir in self.include_dirs:
            f.write("+incdir+" + include_dir + '\n')
        for src_file in self.src_files:
            f.write(src_file + '\n')

        f.close()
        logger.debug('_write_config_files() -Done-')

    def build(self):
        logger.debug('build() *Entered*')
        super(SimulatorIcarus, self).build()
        
        #Build VPI modules
        for vpi_module in self.vpi_modules:
            try:
                subprocess.check_call(['iverilog-vpi', '--name='+vpi_module['name']] +
                                      ['-I' + s for s in vpi_module['include_dirs']] +
                                      vpi_module['src_files'],
                                      stderr = open(os.path.join(self.sim_root,vpi_module['name']+'.log'),'w'),
                                      cwd = os.path.join(self.sim_root))
            except OSError:
                print("Error: Command iverilog-vpi not found. Make sure it is in $PATH")
                exit(1)
            except subprocess.CalledProcessError:<commit_msg>Use absolute path for files in icarus cmdfile<commit_after>import os
import subprocess
from .simulator import Simulator
import logging

logger = logging.getLogger(__name__)

class SimulatorIcarus(Simulator):

    def __init__(self, system):
        logger.debug('__init__() *Entered*')
        super(SimulatorIcarus, self).__init__(system)
        self.sim_root = os.path.join(self.build_root, 'sim-icarus')

        if system.config.has_option('icarus', 'iverilog_options'):
            self.iverilog_options = system.config.get('icarus','iverilog_options').split()
            logger.debug("self.iverilog_options=" + str(self.iverilog_options))
        else:
            self.iverilog_options = []
            logger.debug("No icarus iverilog_options"); # TODO: Remove this temporary line
        logger.debug('__init__() -Done-')

    def configure(self):
        logger.debug('configure() *Entered*')
        super(SimulatorIcarus, self).configure()
        self._write_config_files()
        logger.debug('configure()  -Done-')

    def _write_config_files(self):
        logger.debug('_write_config_files() *Entered*')
        icarus_file = 'icarus.scr'

        f = open(os.path.join(self.sim_root,icarus_file),'w')

        for include_dir in self.include_dirs:
            f.write("+incdir+" + os.path.abspath(include_dir) + '\n')
        for src_file in self.src_files:
            f.write(os.path.abspath(src_file) + '\n')

        f.close()
        logger.debug('_write_config_files() -Done-')

    def build(self):
        logger.debug('build() *Entered*')
        super(SimulatorIcarus, self).build()
        
        #Build VPI modules
        for vpi_module in self.vpi_modules:
            try:
                subprocess.check_call(['iverilog-vpi', '--name='+vpi_module['name']] +
                                      ['-I' + s for s in vpi_module['include_dirs']] +
                                      vpi_module['src_files'],
                                      stderr = open(os.path.join(self.sim_root,vpi_module['name']+'.log'),'w'),
                                      cwd = os.path.join(self.sim_root))
            except OSError:
                print("Error: Command iverilog-vpi not found. Make sure it is in $PATH")
                exit(1)
            except subprocess.CalledProcessError:
{'fraction_non_alphanumeric': 0.12789175032736796, 'fraction_numerical': 0.00043649061545176777, 'mean_word_length': 2.204895104895105, '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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '486921', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1379, 'n_words': 244}