summaryrefslogtreecommitdiff
path: root/util/style.py
AgeCommit message (Collapse)Author
2017-02-10misc: Update #!env calls for python to explicit versionJason Lowe-Power
In some newer Linux distributions, env python default to Python 3.0. This patch explicitly uses "python2" instead of just "python" for all scripts that use #! Reported-by: Sanchayan Maity <maitysanchayan@gmail.com> Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
2016-11-25style: Add options to select checkers and apply fixesAndreas Sandberg
Add an option, --checker/-c, to style.py that selects individual style checkers to apply. When this option isn't specified, the script defaults to all available style checkers. The option may be specified multiple times to run multiple style checkers. The option, --fix/-f, can be specified to automatically fix style violations. Change-Id: Id7597fba6b65cecfa17a88b1c87c8a4c8315af59 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Andreas Hansson <andreas.hansson@arm.com>
2016-03-30style: Add a style checker that doesn't depend on MercurialAndreas Sandberg
The current style checker script, hgstyle.py, assumes that it is being run from Mercurial. This means that it depends on the Mercurial Python libraries, which aren't necessarily present if using git. This changeset adds a new style checker script, style.py, that has been designed to be run from the command line. The script has support for detecting which revision control system is used and is able to query both git and Mercurial for changes. This enables the script to operate on modified regions and/or all of the modified files in the repository. Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Curtis Dunham <curtis.dunham@arm.com> Reviewed-by: Steve Reinhardt <steve.reinhardt@amd.com> --HG-- extra : rebase_source : 2b420aff79d190f32557bc8822518cbc5d93e999
2016-03-30scons, style: Rename style.py to hgstyle.pyAndreas Sandberg
The Mercurial style checker extensions are currently stored in style.py. This is not ideal since they won't work with other version control systems. This changeset renames style.py to hgstyle.py and adds upgrade code to scons that automatically updates the hooks in hgrc. Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Curtis Dunham <curtis.dunham@arm.com> Reviewed-by: Nathanael Premillieu <nathananel.premillieu@arm.com> Reviewed-by: Steve Reinhardt <steve.reinhardt@amd.com> --HG-- rename : util/style.py => util/hgstyle.py extra : rebase_source : ee8107ef245901371b368b7c2046ecdd89e3ff4c
2016-03-30style: Remove unsupported style.py commandsAndreas Sandberg
Remove the unsupported style.py subcommands (fixwhite, chkwhite), which leaves the chkformat command as the only remaining command. Since the script now only supports one command, remove the sub-command support altogether. Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Curtis Dunham <curtis.dunham@arm.com> Reviewed-by: Nathanael Premillieu <nathananel.premillieu@arm.com> --HG-- extra : rebase_source : 548081a5f5358064bffd941b51dd895cff1e2df8
2016-03-24style: Strip newline when checking linesAndreas Sandberg
The style checker incorrectly includes newlines when checking lines of code, which effectively decreases the column limit by 1. This changeset strips the newline character from before calling line checkers. Change-Id: I0a8c7707ece57d782d11cc86db4b8064db291ce0 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
2016-02-06util: added line length and boolean comparison style checkersSteve Reinhardt
Added checkers for line length and boolean comparisons (== true/== false) to the style script.
2016-02-06util: clean up and extend style checkerSteve Reinhardt
Added a new Verifier object to check for and fix spacing between if/while/for and following paren. Restructured Verifier class to make it easier to add new subclasses, particularly by using a global list of verifiers to auto-generate command line options and simplify the invocation loop.
2015-02-11style: Fix broken m5format commandAndreas Sandberg
The m5format command didn't actually work due to parameter handling issues and missing language detection. This changeset fixes those issues and cleans up some of the code to shared between the style checker and the format checker.
2015-02-11style: Fix incorrect style checker option nameAndreas Sandberg
The style used to support the option -w to automatically fix white space issues. However, this option was actually wired up to fix all styles issues the checker encountered. This changeset cleans up the code that handles automatic fixing and adds an option to fix all issues, and separate options for white spaces and include ordering.
2015-02-03style: Update the style checker to handle new include orderAndreas Sandberg
As of August 2014, the gem5 style guide mandates that a source file's primary header is included first in that source file. This helps to ensure that the header file does not depend on include file ordering and avoids surprises down the road when someone tries to reuse code. In the new order, include files are grouped into the following blocks: * Primary header file (e.g., foo.hh for foo.cc) * Python headers * C system/stdlib includes * C++ stdlib includes * Include files in the gem5 source tree Just like before, include files within a block are required to be sorted in alphabetical order. This changeset updates the style checker to enforce the new order.
2014-08-26style: Add support for a style ignore list and ignore ext/Andreas Sandberg
There are some directories within the repository where we don't want to enforce our coding style. Specifically, we don't want the style hooks to warn whenever we update external code in the ext/ directory.
2014-08-26style: Fixup strange semantics in hg m5styleAndreas Sandberg
The 'hg m5style' command had some rather strange semantics. When called without arguments, it applied the style checker to all added files and modified regions of modified files. However, when providing a list of files, it used that list as an ignore list instead of specifically checking those files. This patch makes the m5style command behave more like other Mercurial commands where the arguments are used to specify which files to work on instead of which files to ignore.
2014-06-09Util: Do not style check symlinksJoel Hestness
The style checker used to traverse symlinks if they pointed to files, which can result in style checker failure if the pointed-to file doesn't exist. This style check is actually unnecessary, since symlinks either point to other files that are already style checked, or files outside gem5, which shouldn't be checked. Skip symlinks.
2012-07-27util: Fix issues with style checker.Nathanael Premillieu
2012-06-29Style: Make style.py's invalid warning print which file caused the infraction.Matt Evans
2011-09-24style.py: don't die on empty filesSteve Reinhardt
2011-05-24style: Make the style hook work in directories other than the root.Nathan Binkert
2011-04-17style: fix all_regions code and remove bogus region typeNathan Binkert
2011-04-17style: remove extra debugging printNathan Binkert
2011-04-15style: add sort_includes to the style hookNathan Binkert
2011-04-15style: move style verifiers into classesNathan Binkert
2011-04-15style: add a user interface wrapper classNathan Binkert
makes things work both with mercurial and stand alone with stdio
2011-01-13Style checker: Fix a couple bugs in style.py.Gabe Black
2011-01-10style: prevent the style hook from aborting uncleanly because of an exceptionNathan Binkert
2011-01-10style: clean up style hook code a bitNathan Binkert
I've renamed the check_whitespace operation to check_style. You're going to need to change your .hg/hgrc file. While you're at it, add a pre-qrefresh hook please.
2010-12-30style: make style hook work with pre-qrefresh and update to use new codeNathan Binkert
clean up the code a little bit while we're at it. I recommend that everyone adds the pre-qrefresh hook below since it will make qref run the style hook and not just commit/qpush [extensions] style = <m5 path>/util/style.py [hooks] pretxncommit.style = python:style.check_whitespace pre-qrefresh.style = python:style.check_whitespace
2010-01-23style_hook: Fix the style hookNathan Binkert
Re-enable it and update it for more modern versions of mercurial.
2009-09-17Functionality migrated to sequencer.Polina Dudnik
2009-08-21[mq]: first_patchPolina Dudnik
2009-04-08style: fix style hook for some newer versions of mercurial.Nathan Binkert
2009-01-13Fix style hook for Mercurial >= 1.1Ali Saidi
2008-11-15Remove the pointless, repository destroying assertion and just have the ↵Clint Smullen
script check every line in the file if it cannot get context information.
2008-06-14Add hg commands for style check so you can check at times other than commitNathan Binkert
2007-12-11Fix minor bug in util/style.pySteve Reinhardt
--HG-- extra : convert_revision : d37accc884c2967d87dd267debab5afeb8b6ed85
2007-08-21style: fix style hook when run from a repo subdir.Nathan Binkert
Before this fix, the style hook would blow up when you did a qrefresh to add a new file, but executed the qrefresh from a repository sub directory. --HG-- extra : convert_revision : 851b0421dfa5c5b23d0f49441c4ba2e0ac579c5d
2007-08-14style: Don't try to fix files that should be ignored.Nathan Binkert
The style hook was ignoring new files, but processing all modified files. --HG-- extra : convert_revision : 97400c24a12103d7ac3d4f69b026853816c39d72
2007-07-29Merge with head. style.py was also missing an argument in one call to ↵Gabe Black
modified_lines. --HG-- extra : convert_revision : 0f4e23007399f9d0e2be5310062bd61f5415550d
2007-07-28Work around a mercurial bug in bdiff.blocksNathan Binkert
--HG-- extra : convert_revision : 597503431883a24f68744bf0dce77356a32d7ff7
2007-07-28style: fix stupid bugsNathan Binkert
--HG-- extra : convert_revision : ef3dcc3a160eb19a6c4fcdcd411d392aa42e4efe
2007-07-28style: Check/Fix whitespace on SCons filesNathan Binkert
--HG-- extra : convert_revision : 46e6b2dd8e1984cbab0ea24c94760794734c0f95
2007-07-23Allow the fixwhite stuff to work when committing from a subdirNathan Binkert
--HG-- extra : convert_revision : 10e6ecc60bb8ee4e4a6f06f8c56550299c262c91
2007-07-22do proper style checks for merged filesNathan Binkert
--HG-- extra : convert_revision : f9d4c61ded4b13655dbe86f0bb6a0b3beaf45151
2007-07-22fix the style fixing thingNathan Binkert
--HG-- extra : convert_revision : 65ffc14e7b78b49df9a67ef0d3521551dd44d1cd
2007-07-21Add code to turn the style stuff into a mercurial hook.Nathan Binkert
Nag the user during compile if they have an hg cloned copy of M5, have mercurial installed, but don't have the style hook enabled. --HG-- extra : convert_revision : 6bcbb67f1a3fcd36db7d3ef16a9ff19680f126f2