Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#27: Added parsing of Synplify Pro log files. #28

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/source/vendors/synopsys/synopsys.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Synopsys
--------

.. include:: synplify_pro.rst

28 changes: 28 additions & 0 deletions docs/source/vendors/synopsys/synplify_pro.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Synplify Pro
~~~~~~~~~~~~

Synplify Pro provides warnings on a single line with the line starting with :code:`@W`.

<warning keyword> : <ID> : <message>

where:

+-------------------------------+-------------------------------------------------+
| Item | Regular Expression Match |
+===============================+=================================================+
| warning keyword | @W |
+-------------------------------+-------------------------------------------------+
| ID | \\W+ |
+-------------------------------+-------------------------------------------------+
| message | .*$ |
+-------------------------------+-------------------------------------------------+

Extracting Warnings
^^^^^^^^^^^^^^^^^^^

Extraction of warnings from the logfile will follow this process:

1. Search for lines starting with **@W**
2. Extract warning keyword
3. Extract message

1 change: 1 addition & 0 deletions docs/source/vendors/vendors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ The following sections contain information about each vendor tool supported by E

mentor_graphics/mentor_graphics.rst
microsemi/microsemi.rst
synopsys/synopsys.rst
xilinx/xilinx.rst
Empty file.
34 changes: 34 additions & 0 deletions elfws/vendor/synopsys/synplify_pro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

from elfws import warning
from elfws import warning_list


def get_vendor():
return ['Synopsys']


def get_tool_name():
return 'Synplify Pro'


def is_logfile(lFile):
for iLineNumber, sLine in enumerate(lFile):
if sLine.startswith('#Build: Synplify Pro (R)'):
return True
if iLineNumber == 5:
return False
return False


def extract_warnings(lFile):
oReturn = warning_list.create()

for iLineNumber, sLine in enumerate(lFile):
if sLine.startswith('@W'):
iColon1Index = sLine.find(':')
iColon2Index = sLine.find(':', iColon1Index+1)
sID = sLine[iColon1Index+1:iColon2Index].strip()
sMessage = sLine[iColon2Index+1:].strip()
oWarning = warning.create(sID, sMessage, None, iLineNumber + 1)
oReturn.add_warning(oWarning)
return oReturn
3 changes: 2 additions & 1 deletion tests/utils/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,10 @@ def test_import_vendor_module(self):

def test_get_vendors(self):
lActual = utils.get_vendors()
self.assertEqual(3, len(lActual))
self.assertEqual(4, len(lActual))
self.assertTrue('mentor_graphics' in lActual)
self.assertTrue('microsemi' in lActual)
self.assertTrue('synopsys' in lActual)
self.assertTrue('xilinx' in lActual)

def test_get_tools(self):
Expand Down
Empty file.
Empty file.
51 changes: 51 additions & 0 deletions tests/vendor/synopsys/synplify_pro/test_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

import os
import unittest

from elfws.vendor.synopsys import synplify_pro
from tests import test_utils

lLogFile = test_utils.read_file(os.path.join(os.path.dirname(__file__), 'warning_messages.log'))

class testFunctions(unittest.TestCase):

def test_extract_warnings(self):
oWarningList = synplify_pro.extract_warnings(lLogFile)

oWarning = oWarningList.warnings[0]
self.assertEqual('ID1', oWarning.get_id())
self.assertEqual('"file name" some message', oWarning.get_message())
self.assertEqual(None, oWarning.get_filename())
self.assertEqual(7, oWarning.get_linenumber())

oWarning = oWarningList.warnings[1]
self.assertEqual('ID1', oWarning.get_id())
self.assertEqual('"file name" some other message', oWarning.get_message())
self.assertEqual(None, oWarning.get_filename())
self.assertEqual(10, oWarning.get_linenumber())

oWarning = oWarningList.warnings[2]
self.assertEqual('ID2', oWarning.get_id())
self.assertEqual('Some message without a file', oWarning.get_message())
self.assertEqual(None, oWarning.get_filename())
self.assertEqual(11, oWarning.get_linenumber())

def test_is_logfile(self):
lLogFile = []
lLogFile.append('#Build: Synplify Pro (R)')
lLogFile.append('#OS:')

self.assertTrue(synplify_pro.is_logfile(lLogFile))

lLogFile = []
lLogFile.append('#OS: ')
lLogFile.append('#install')

self.assertFalse(synplify_pro.is_logfile(lLogFile))

lLogFile = []
lLogFile.append('#Build: Synplify (R)')
lLogFile.append('#OS:')

self.assertFalse(synplify_pro.is_logfile(lLogFile))