Skip to content

Commit 4f4b1bf

Browse files
authored
Merge pull request travitch#54 from SRI-CSL/master
Linting and a fix to the travis CI configuration.
2 parents 915e224 + 12a87a9 commit 4f4b1bf

21 files changed

+843
-372
lines changed

.pylintrc

Lines changed: 412 additions & 0 deletions
Large diffs are not rendered by default.

.travis.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,35 @@ sudo: required
44
dist: trusty
55

66
python:
7+
- "3.5"
8+
- "3.4"
79
- "3.3"
810
- "2.7"
9-
- "2.6"
1011

1112

1213
# command to install dependencies
1314
install:
1415
- sudo apt-get update
15-
# to install wllvm
16-
- sudo apt-get install -y python-pip
1716
# apache prerequisites
1817
- sudo apt-get install -y libapr1-dev libaprutil1-dev
1918
# for the clang build
2019
- sudo apt-get install -y llvm-3.5 clang-3.5
2120
# dragonegg prereqs. dragonegg and llvm-gcc use llvm 3.3
2221
- sudo apt-get install -y llvm-3.3 llvm-gcc-4.7
23-
- sudo pip install -e .
24-
- export WLLVM_HOME=`pwd`
25-
- export APACHE_VER=2.4.18
22+
# Install wllvm
23+
# Report the version of pip being used for debugging purposes.
24+
# It should report the site-packages directory and the version
25+
# of python it is working with.
26+
- pip --version
27+
- pip install -e .
2628

2729

2830
# command to run tests
2931
script:
32+
# Run unittests
33+
- python -m unittest discover test/ || exit 1
34+
- export WLLVM_HOME=`pwd`
35+
- export APACHE_VER=2.4.18
3036
# build apache with clang
3137
- ${WLLVM_HOME}/.travis/apache_clang.sh
3238
# build apache with gcc and dragonegg

.travis/apache_clang.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export PATH=/usr/lib/llvm-3.5/bin:${PATH}
77
export LLVM_COMPILER=clang
88
export WLLVM_OUTPUT=WARNING
99

10+
wllvm-sanity-checker
11+
1012
wget https://archive.apache.org/dist/httpd/httpd-${APACHE_VER}.tar.gz
1113

1214
tar xfz httpd-${APACHE_VER}.tar.gz

.travis/apache_dragonegg.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export LLVM_DRAGONEGG_PLUGIN=/usr/lib/gcc/x86_64-linux-gnu/4.7/plugin/dragonegg.
1111

1212
export WLLVM_OUTPUT=WARNING
1313

14+
wllvm-sanity-checker
15+
1416
wget https://archive.apache.org/dist/httpd/httpd-${APACHE_VER}.tar.gz
1517

1618

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ all:
2727

2828

2929
#local editable install for developing
30-
develop:
30+
develop:
3131
pip install -e .
3232

3333

@@ -36,7 +36,7 @@ dist: clean
3636

3737
# If you need to push this project again,
3838
# INCREASE the version number in wllvm/version.py,
39-
# otherwise the server will give you an error.
39+
# otherwise the server will give you an error.
4040

4141
testpublish: dist
4242
python setup.py register -r https://testpypi.python.org/pypi
@@ -50,7 +50,7 @@ publish: dist
5050
python setup.py sdist upload -r https://pypi.python.org/pypi
5151

5252
install:
53-
pip install
53+
pip install
5454

5555
check_clang:
5656
cd test; python -m unittest -v test_base_driver test_clang_driver
@@ -74,4 +74,6 @@ lint:
7474
ifeq ($(PYLINT),)
7575
$(error lint target requires pylint)
7676
endif
77-
@ $(PYLINT) -E wllvm/*.py
77+
# @ $(PYLINT) -E wllvm/*.py
78+
# for detecting more than just errors:
79+
@ $(PYLINT) --rcfile=.pylintrc wllvm/*.py

img/dragon100x100.png

-12.1 KB
Binary file not shown.

img/dragon256x256.png

-46.9 KB
Binary file not shown.

setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
# use the in house version number so we stay in synch with ourselves.
1515
from wllvm.version import wllvm_version
16-
16+
1717
setup(
1818
name='wllvm',
19-
version=wllvm_version,
19+
version=wllvm_version,
2020
description='Whole Program LLVM',
2121
long_description=long_description,
2222
url='https://github.com/SRI-CSL/whole-program-llvm',
@@ -25,9 +25,9 @@
2525

2626

2727
include_package_data=True,
28-
28+
2929
packages=find_packages(),
30-
30+
3131
entry_points = {
3232
'console_scripts': [
3333
'wllvm-as = wllvm.as:main',
@@ -39,7 +39,7 @@
3939
},
4040

4141
license='MIT',
42-
42+
4343
classifiers=[
4444
'Development Status :: 4 - Beta',
4545
'Natural Language :: English',

wllvm/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

wllvm/arglistfilter.py

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import logging, collections, os, re, sys
1+
import logging
2+
import collections
3+
import os
4+
import re
5+
import sys
26

37
# Internal logger
48
_logger = logging.getLogger(__name__)
@@ -123,8 +127,8 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
123127
# Debug
124128
'-g' : (0, ArgumentListFilter.compileUnaryCallback),
125129
'-g0' : (0, ArgumentListFilter.compileUnaryCallback), #iam: clang not gcc
126-
'-ggdb' : (0, ArgumentListFilter.compileUnaryCallback),
127-
'-ggdb3' : (0, ArgumentListFilter.compileUnaryCallback),
130+
'-ggdb' : (0, ArgumentListFilter.compileUnaryCallback),
131+
'-ggdb3' : (0, ArgumentListFilter.compileUnaryCallback),
128132
'-gdwarf-2' : (0, ArgumentListFilter.compileUnaryCallback),
129133
'-gdwarf-3' : (0, ArgumentListFilter.compileUnaryCallback),
130134
'-gline-tables-only' : (0, ArgumentListFilter.compileUnaryCallback),
@@ -185,7 +189,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
185189
# (the Darwin ld is a bit single minded)
186190
#
187191
# 1) compilation with -fvisibility=hidden causes trouble when we try to
188-
# attach bitcode filenames to an object file. The global symbols in object
192+
# attach bitcode filenames to an object file. The global symbols in object
189193
# files get turned into local symbols when we invoke 'ld -r'
190194
#
191195
# 2) all stripping commands (e.g., -dead_strip) remove the __LLVM segment after
@@ -195,8 +199,8 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
195199
# calling ld -r.
196200
#
197201
'-Wl,-dead_strip' : (0, ArgumentListFilter.darwinWarningLinkUnaryCallback),
198-
199-
}
202+
203+
}
200204

201205
#
202206
# Patterns for other command-line arguments:
@@ -227,15 +231,15 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
227231
r'^--sysroot=.+$' : (0, ArgumentListFilter.compileUnaryCallback),
228232
r'^-print-prog-name=.*$' : (0, ArgumentListFilter.compileUnaryCallback),
229233
r'^-print-file-name=.*$' : (0, ArgumentListFilter.compileUnaryCallback),
230-
234+
231235
}
232236

233237
#iam: try and keep track of the files, input object, and output
234238
self.inputList = inputList
235239
self.inputFiles = []
236240
self.objectFiles = []
237241
self.outputFilename = None
238-
242+
239243
#iam: try and split the args into linker and compiler switches
240244
self.compileArgs = []
241245
self.linkArgs = []
@@ -256,10 +260,10 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
256260
self._inputArgs = collections.deque(inputList)
257261

258262
#iam: parse the cmd line, bailing if we discover that there will be no second phase.
259-
while ( len(self._inputArgs) > 0 and
260-
not (self.isAssembly or
261-
self.isAssembleOnly or
262-
self.isPreprocessOnly ) ):
263+
while (len(self._inputArgs) > 0 and
264+
not (self.isAssembly or
265+
self.isAssembleOnly or
266+
self.isPreprocessOnly)):
263267
# Get the next argument
264268
currentItem = self._inputArgs.popleft()
265269
_logger.debug('Trying to match item ' + currentItem)
@@ -281,7 +285,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
281285
# If no action has been specified, this is a zero-argument
282286
# flag that we should just keep.
283287
if not matched:
284-
_logger.warning('Did not recognize the compiler flag "{0}"'.format(currentItem))
288+
_logger.warning('Did not recognize the compiler flag "%s"', currentItem)
285289
self.compileUnaryCallback(currentItem)
286290

287291
if DUMPING:
@@ -296,69 +300,83 @@ def _shiftArgs(self, nargs):
296300
return ret
297301

298302
def abortUnaryCallback(self, flag):
299-
_logger.warning('Out of context experience: "{0}"'.format(str(self.inputList)))
303+
_logger.warning('Out of context experience: "%s" "%s"', str(self.inputList), flag)
300304
sys.exit(1)
301305

302306
def inputFileCallback(self, infile):
303-
_logger.debug('Input file: ' + infile)
307+
_logger.debug('Input file: %s', infile)
304308
self.inputFiles.append(infile)
305309
if re.search('\\.(s|S)$', infile):
306310
self.isAssembly = True
307311

308312
def outputFileCallback(self, flag, filename):
313+
_logger.debug('outputFileCallback: %s %s', flag, filename)
309314
self.outputFilename = filename
310315

311316
def objectFileCallback(self, objfile):
317+
_logger.debug('objectFileCallback: %s', objfile)
312318
self.objectFiles.append(objfile)
313319

314320
def preprocessOnlyCallback(self, flag):
321+
_logger.debug('preprocessOnlyCallback: %s', flag)
315322
self.isPreprocessOnly = True
316323

317324
def dependencyOnlyCallback(self, flag):
325+
_logger.debug('dependencyOnlyCallback: %s', flag)
318326
self.isDependencyOnly = True
319327
self.compileArgs.append(flag)
320328

321329
def assembleOnlyCallback(self, flag):
330+
_logger.debug('assembleOnlyCallback: %s', flag)
322331
self.isAssembleOnly = True
323332

324333
def verboseFlagCallback(self, flag):
334+
_logger.debug('verboseFlagCallback: %s', flag)
325335
self.isVerbose = True
326336

327337
def compileOnlyCallback(self, flag):
338+
_logger.debug('compileOnlyCallback: %s', flag)
328339
self.isCompileOnly = True
329340

330341
def linkUnaryCallback(self, flag):
342+
_logger.debug('linkUnaryCallback: %s', flag)
331343
self.linkArgs.append(flag)
332344

333345
def compileUnaryCallback(self, flag):
346+
_logger.debug('compileUnaryCallback: %s', flag)
334347
self.compileArgs.append(flag)
335348

336349
def darwinWarningLinkUnaryCallback(self, flag):
350+
_logger.debug('darwinWarningLinkUnaryCallback: %s', flag)
337351
if sys.platform.startswith('darwin'):
338-
_logger.warning('The flag "{0}" cannot be used with this tool'.format(flag))
352+
_logger.warning('The flag "%s" cannot be used with this tool', flag)
339353
sys.exit(1)
340354
else:
341355
self.linkArgs.append(flag)
342356

343357
def defaultBinaryCallback(self, flag, arg):
344-
_logger.warning('Ignoring compiler arg pair: "{0} {1}"'.format(flag, arg))
358+
_logger.warning('Ignoring compiler arg pair: "%s %s"', flag, arg)
345359

346360
def dependencyBinaryCallback(self, flag, arg):
361+
_logger.debug('dependencyBinaryCallback: %s %s', flag, arg)
347362
self.isDependencyOnly = True
348363
self.compileArgs.append(flag)
349364
self.compileArgs.append(arg)
350365

351366
def compileBinaryCallback(self, flag, arg):
367+
_logger.debug('compileBinaryCallback: %s %s', flag, arg)
352368
self.compileArgs.append(flag)
353369
self.compileArgs.append(arg)
354370

355371

356372
def linkBinaryCallback(self, flag, arg):
373+
_logger.debug('linkBinaryCallback: %s %s', flag, arg)
357374
self.linkArgs.append(flag)
358375
self.linkArgs.append(arg)
359376

360377
#flags common to both linking and compiling (coverage for example)
361378
def compileLinkUnaryCallback(self, flag):
379+
_logger.debug('compileLinkUnaryCallback: %s', flag)
362380
self.compileArgs.append(flag)
363381
self.linkArgs.append(flag)
364382

@@ -367,8 +385,8 @@ def getOutputFilename(self):
367385
return self.outputFilename
368386
elif self.isCompileOnly:
369387
#iam: -c but no -o, therefore the obj should end up in the cwd.
370-
(path, base) = os.path.split(self.inputFiles[0])
371-
(root, ext) = os.path.splitext(base)
388+
(_, base) = os.path.split(self.inputFiles[0])
389+
(root, _) = os.path.splitext(base)
372390
return '{0}.o'.format(root)
373391
else:
374392
return 'a.out'
@@ -378,8 +396,8 @@ def getOutputFilename(self):
378396
# bitcodeFile is (starts with a '.'), use the logging level & DUMPING flag to get a sense
379397
# of what is being written out.
380398
def getArtifactNames(self, srcFile, hidden=False):
381-
(srcpath, srcbase) = os.path.split(srcFile)
382-
(srcroot, srcext) = os.path.splitext(srcbase)
399+
(_, srcbase) = os.path.split(srcFile)
400+
(srcroot, _) = os.path.splitext(srcbase)
383401
if hidden:
384402
objbase = '.{0}.o'.format(srcroot)
385403
else:
@@ -392,15 +410,11 @@ def getArtifactNames(self, srcFile, hidden=False):
392410

393411
#iam: for printing our partitioning of the args
394412
def dump(self):
395-
_logger.debug('compileArgs: {0}'.format(self.compileArgs))
396-
_logger.debug('inputFiles: {0}'.format(self.inputFiles))
397-
_logger.debug('linkArgs: {0}'.format(self.linkArgs))
398-
_logger.debug('objectFiles: {0}'.format(self.objectFiles))
399-
_logger.debug('outputFilename: {0}'.format(self.outputFilename))
413+
_logger.debug('compileArgs: %s\ninputFiles: %s\nlinkArgs: %s',
414+
self.compileArgs, self.inputFiles, self.linkArgs)
415+
_logger.debug('objectFiles: %s\noutputFilename: %s',
416+
self.objectFiles, self.outputFilename)
400417
for srcFile in self.inputFiles:
401-
_logger.debug('srcFile: {0}'.format(srcFile))
418+
_logger.debug('srcFile: %s', srcFile)
402419
(objFile, bcFile) = self.getArtifactNames(srcFile)
403-
_logger.debug('{0} ===> ({1}, {2})'.format(srcFile, objFile, bcFile))
404-
405-
406-
420+
_logger.debug('%s ===> (%s, %s)', srcFile, objFile, bcFile)

0 commit comments

Comments
 (0)