From: Jarkko Pöyry Date: Sat, 21 Feb 2015 02:38:38 +0000 (-0800) Subject: Clean up scripts/. X-Git-Tag: upstream/0.1.0~1935^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd7c885b7a467f7acf7a88395407443687b00b2b;p=platform%2Fupstream%2FVK-GL-CTS.git Clean up scripts/. - Remove obsolete check_redundant_include_guards.py. Redundant include guards do not need checking since they are forbidden. - Remove obsolete git-check.py script. - Move delibs/scripts to scripts/. Change-Id: Iecf339af0ed7a35149bdfc39930f84f81797fb4b --- diff --git a/framework/delibs/scripts/git-check.py b/framework/delibs/scripts/git-check.py deleted file mode 100644 index 86ddccc..0000000 --- a/framework/delibs/scripts/git-check.py +++ /dev/null @@ -1,70 +0,0 @@ -# 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) diff --git a/scripts/check_redundant_include_guards.py b/scripts/check_redundant_include_guards.py deleted file mode 100644 index fb29487..0000000 --- a/scripts/check_redundant_include_guards.py +++ /dev/null @@ -1,108 +0,0 @@ -# -*- 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." diff --git a/scripts/check_include_guards.py b/scripts/src_util/check_include_guards.py similarity index 100% rename from scripts/check_include_guards.py rename to scripts/src_util/check_include_guards.py diff --git a/framework/delibs/scripts/pre_commit.py b/scripts/src_util/pre_commit.py similarity index 100% rename from framework/delibs/scripts/pre_commit.py rename to scripts/src_util/pre_commit.py diff --git a/framework/delibs/scripts/update-copyright-year.py b/scripts/update-copyright-year.py similarity index 100% rename from framework/delibs/scripts/update-copyright-year.py rename to scripts/update-copyright-year.py