+++ /dev/null
-# Script for checking which projects have unsubmitted modifications in them.
-#
-# Usage:
-# - recommended to add a alias/bat/sh for a shorter command
-# - running without parameters will check any existing known dE projects.
-# - can give projects names on command line, if only wish to check a sub-set
-# e.g., git-check.py delibs deqp
-
-import os
-import sys
-
-COMMANDS = ["pull", "push", "check"]
-ALL_REPOS = ["delibs", "deqp", "movies", "domeni", "demisc"]
-
-# Defaults.
-command = "check"
-repos = ALL_REPOS
-
-# Parse command line.
-numArgs = len(sys.argv)
-if (numArgs == 1):
- pass
-else:
- if (sys.argv[1] in COMMANDS):
- command = sys.argv[1]
- if (numArgs > 2):
- repos = sys.argv[2:]
- else:
- repos = sys.argv[1:]
-
-def findRepo(x):
- for repo in ALL_REPOS:
- if repo.startswith(x):
- return repo
- print "%s not a valid repository directory" % x
- sys.exit(1)
-
-repoDirs = [findRepo(x) for x in repos]
-
-# Find git base repo directory.
-oldDir = os.getcwd()
-baseDir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../.."))
-foundAny = False
-
-# Execute the command.
-print "## Executing '%s' on repos: %s" % (command.upper(), ", ".join(repoDirs))
-print ""
-
-for gitDir in repoDirs:
- subDir = os.path.join(baseDir, gitDir)
- if os.path.exists(subDir):
- foundAny = True
- print "***** Check directory '%s' *****" % subDir
- os.chdir(subDir)
- if command == "check":
- os.system("git status")
- os.system("git push --dry-run")
- elif command == "push":
- os.system("git push")
- elif command == "pull":
- os.system("git pull")
- else:
- assert False
- print ""
-
-if not foundAny:
- print "No subdirs found -- tried %s" % repoDirs
- print "Searching in '%s'" % baseDir
-
-os.chdir(oldDir)
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-#-------------------------------------------------------------------------
-# drawElements Quality Program utilities
-# --------------------------------------
-#
-# Copyright 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#-------------------------------------------------------------------------
-
-import os
-import sys
-from fnmatch import fnmatch
-from optparse import OptionParser
-
-HEADER_PATTERNS = ["*.hpp", "*.h"]
-INDENTED_INCLUDE_PREFIX = "#\tinclude "
-IFNDEF_PREFIX = "#ifndef "
-
-def getIncludeGuardName (headerFile):
- return '_' + os.path.basename(headerFile).upper().replace('.', '_')
-
-def getRedundantIncludeGuardErrors (fileName):
- f = open(fileName, 'rb')
- errors = []
-
- lineNumber = 1
- prevLine = None
- for line in f:
- if line.startswith(INDENTED_INCLUDE_PREFIX):
- if prevLine is not None and prevLine.startswith(IFNDEF_PREFIX):
- ifndefName = prevLine[len(IFNDEF_PREFIX):-1] # \note -1 to take out the newline.
- includeName = line[len(INDENTED_INCLUDE_PREFIX)+1:-2] # \note +1 to take out the beginning quote, -2 to take out the newline and the ending quote.
- if getIncludeGuardName(includeName) != ifndefName:
- errors.append("Invalid redundant include guard around line %d:" % lineNumber)
- errors.append("guard is %s but included file is %s" % (ifndefName, includeName))
-
- prevLine = line
- lineNumber += 1
-
- f.close()
- return errors
-
-def isHeader (filename):
- for pattern in HEADER_PATTERNS:
- if fnmatch(filename, pattern):
- return True
- return False
-
-def getFileList (path):
- allFiles = []
- if os.path.isfile(path):
- if isHeader(path):
- allFiles.append(path)
- else:
- for root, dirs, files in os.walk(path):
- for file in files:
- if isHeader(file):
- allFiles.append(os.path.join(root, file))
- return allFiles
-
-if __name__ == "__main__":
- parser = OptionParser()
- parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, help="only print files with errors")
-
- (options, args) = parser.parse_args()
- quiet = options.quiet
- files = []
- invalidFiles = []
-
- for dir in args:
- files += getFileList(os.path.normpath(dir))
-
- print "Checking..."
- for file in files:
- if not quiet:
- print " %s" % file
-
- errors = getRedundantIncludeGuardErrors(file)
- if errors:
- if quiet:
- print " %s" % file
- for err in errors:
- print " %s" % err
- invalidFiles.append(file)
-
- print ""
- if len(invalidFiles) > 0:
- print "Found %d files with invalid redundant include guards:" % len(invalidFiles)
-
- for file in invalidFiles:
- print " %s" % file
-
- sys.exit(-1)
- else:
- print "All files have valid redundant include guards."