summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--python/makevars.py50
-rwxr-xr-xtools/symalyzer.py44
3 files changed, 53 insertions, 42 deletions
diff --git a/Makefile.am b/Makefile.am
index 6dc8e0d35..2937c2893 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -183,6 +183,7 @@ EXTRA_DIST += \
\
python/clidef.py \
python/clippy/__init__.py \
+ python/makevars.py \
\
redhat/frr.logrotate \
redhat/frr.pam \
diff --git a/python/makevars.py b/python/makevars.py
new file mode 100644
index 000000000..e0e2031a0
--- /dev/null
+++ b/python/makevars.py
@@ -0,0 +1,50 @@
+#
+# helper class to grab variables from FRR's Makefile
+#
+
+import os
+import subprocess
+
+class MakeVars(object):
+ '''
+ makevars['FOO_CFLAGS'] gets you "FOO_CFLAGS" from Makefile
+ '''
+ def __init__(self):
+ self._data = dict()
+
+ def getvars(self, varlist):
+ '''
+ get a batch list of variables from make. faster than individual calls.
+ '''
+ rdfd, wrfd = os.pipe()
+
+ shvars = ['shvar-%s' % s for s in varlist]
+ make = subprocess.Popen(['make', '-s', 'VARFD=%d' % wrfd] + shvars, pass_fds = [wrfd])
+ os.close(wrfd)
+ data = b''
+
+ rdf = os.fdopen(rdfd, 'rb')
+ while True:
+ rdata = rdf.read()
+ if len(rdata) == 0:
+ break
+ data += rdata
+
+ del rdf
+ make.wait()
+
+ data = data.decode('US-ASCII').strip().split('\n')
+ for row in data:
+ k, v = row.split('=', 1)
+ v = v[1:-1]
+ self._data[k] = v
+
+ def __getitem__(self, k):
+ if k not in self._data:
+ self.getvars([k])
+ return self._data[k]
+
+ def get(self, k, defval = None):
+ if k not in self._data:
+ self.getvars([k])
+ return self._data[k] or defval
diff --git a/tools/symalyzer.py b/tools/symalyzer.py
index b3b5c4e56..a067053ed 100755
--- a/tools/symalyzer.py
+++ b/tools/symalyzer.py
@@ -21,49 +21,9 @@ import sys, os, subprocess
import re
from collections import namedtuple
-class MakeVars(object):
- '''
- makevars['FOO_CFLAGS'] gets you "FOO_CFLAGS" from Makefile
- '''
- def __init__(self):
- self._data = dict()
+sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'python'))
- def getvars(self, varlist):
- '''
- get a batch list of variables from make. faster than individual calls.
- '''
- rdfd, wrfd = os.pipe()
-
- shvars = ['shvar-%s' % s for s in varlist]
- make = subprocess.Popen(['make', '-s', 'VARFD=%d' % wrfd] + shvars, pass_fds = [wrfd])
- os.close(wrfd)
- data = b''
-
- rdf = os.fdopen(rdfd, 'rb')
- while True:
- rdata = rdf.read()
- if len(rdata) == 0:
- break
- data += rdata
-
- del rdf
- make.wait()
-
- data = data.decode('US-ASCII').strip().split('\n')
- for row in data:
- k, v = row.split('=', 1)
- v = v[1:-1]
- self._data[k] = v
-
- def __getitem__(self, k):
- if k not in self._data:
- self.getvars([k])
- return self._data[k]
-
- def get(self, k, defval = None):
- if k not in self._data:
- self.getvars([k])
- return self._data[k] or defval
+from makevars import MakeVars
SymRowBase = namedtuple('SymRow', ['target', 'object', 'name', 'address', 'klass', 'typ', 'size', 'line', 'section', 'loc'])
class SymRow(SymRowBase):