From 6555fb80fdd8f6a5d201efadec3189d1244830a0 Mon Sep 17 00:00:00 2001 From: Nevena Bojovic Date: Tue, 1 Mar 2022 22:05:25 +0100 Subject: Izbrisala bin, obj i node-modules. --- .../Front/node_modules/node-gyp/gyp/tools/README | 15 - .../node_modules/node-gyp/gyp/tools/Xcode/README | 5 - .../gyp/tools/Xcode/Specifications/gyp.pbfilespec | 27 - .../gyp/tools/Xcode/Specifications/gyp.xclangspec | 226 ---- .../node_modules/node-gyp/gyp/tools/emacs/README | 12 - .../node-gyp/gyp/tools/emacs/gyp-tests.el | 63 -- .../node_modules/node-gyp/gyp/tools/emacs/gyp.el | 275 ----- .../node-gyp/gyp/tools/emacs/run-unit-tests.sh | 7 - .../node-gyp/gyp/tools/emacs/testdata/media.gyp | 1105 ------------------- .../gyp/tools/emacs/testdata/media.gyp.fontified | 1107 -------------------- .../node_modules/node-gyp/gyp/tools/graphviz.py | 102 -- .../node_modules/node-gyp/gyp/tools/pretty_gyp.py | 156 --- .../node_modules/node-gyp/gyp/tools/pretty_sln.py | 181 ---- .../node-gyp/gyp/tools/pretty_vcproj.py | 339 ------ 14 files changed, 3620 deletions(-) delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/README delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/README delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/Specifications/gyp.pbfilespec delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/Specifications/gyp.xclangspec delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/emacs/README delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/emacs/gyp-tests.el delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/emacs/gyp.el delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/emacs/run-unit-tests.sh delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/emacs/testdata/media.gyp delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/emacs/testdata/media.gyp.fontified delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/graphviz.py delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_gyp.py delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_sln.py delete mode 100644 sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_vcproj.py (limited to 'sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools') diff --git a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/README b/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/README deleted file mode 100644 index 84a73d15..00000000 --- a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/README +++ /dev/null @@ -1,15 +0,0 @@ -pretty_vcproj: - Usage: pretty_vcproj.py "c:\path\to\vcproj.vcproj" [key1=value1] [key2=value2] - - They key/value pair are used to resolve vsprops name. - - For example, if I want to diff the base.vcproj project: - - pretty_vcproj.py z:\dev\src-chrome\src\base\build\base.vcproj "$(SolutionDir)=z:\dev\src-chrome\src\chrome\\" "$(CHROMIUM_BUILD)=" "$(CHROME_BUILD_TYPE)=" > original.txt - pretty_vcproj.py z:\dev\src-chrome\src\base\base_gyp.vcproj "$(SolutionDir)=z:\dev\src-chrome\src\chrome\\" "$(CHROMIUM_BUILD)=" "$(CHROME_BUILD_TYPE)=" > gyp.txt - - And you can use your favorite diff tool to see the changes. - - Note: In the case of base.vcproj, the original vcproj is one level up the generated one. - I suggest you do a search and replace for '"..\' and replace it with '"' in original.txt - before you perform the diff. \ No newline at end of file diff --git a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/README b/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/README deleted file mode 100644 index 2492a2c2..00000000 --- a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/README +++ /dev/null @@ -1,5 +0,0 @@ -Specifications contains syntax formatters for Xcode 3. These do not appear to be supported yet on Xcode 4. To use these with Xcode 3 please install both the gyp.pbfilespec and gyp.xclangspec files in - -~/Library/Application Support/Developer/Shared/Xcode/Specifications/ - -and restart Xcode. \ No newline at end of file diff --git a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/Specifications/gyp.pbfilespec b/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/Specifications/gyp.pbfilespec deleted file mode 100644 index 85e2e268..00000000 --- a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/Specifications/gyp.pbfilespec +++ /dev/null @@ -1,27 +0,0 @@ -/* - gyp.pbfilespec - GYP source file spec for Xcode 3 - - There is not much documentation available regarding the format - of .pbfilespec files. As a starting point, see for instance the - outdated documentation at: - http://maxao.free.fr/xcode-plugin-interface/specifications.html - and the files in: - /Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources/ - - Place this file in directory: - ~/Library/Application Support/Developer/Shared/Xcode/Specifications/ -*/ - -( - { - Identifier = sourcecode.gyp; - BasedOn = sourcecode; - Name = "GYP Files"; - Extensions = ("gyp", "gypi"); - MIMETypes = ("text/gyp"); - Language = "xcode.lang.gyp"; - IsTextFile = YES; - IsSourceFile = YES; - } -) diff --git a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/Specifications/gyp.xclangspec b/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/Specifications/gyp.xclangspec deleted file mode 100644 index 3b3506d3..00000000 --- a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/Xcode/Specifications/gyp.xclangspec +++ /dev/null @@ -1,226 +0,0 @@ -/* - Copyright (c) 2011 Google Inc. All rights reserved. - Use of this source code is governed by a BSD-style license that can be - found in the LICENSE file. - - gyp.xclangspec - GYP language specification for Xcode 3 - - There is not much documentation available regarding the format - of .xclangspec files. As a starting point, see for instance the - outdated documentation at: - http://maxao.free.fr/xcode-plugin-interface/specifications.html - and the files in: - /Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources/ - - Place this file in directory: - ~/Library/Application Support/Developer/Shared/Xcode/Specifications/ -*/ - -( - - { - Identifier = "xcode.lang.gyp.keyword"; - Syntax = { - Words = ( - "and", - "or", - " (caar gyp-parse-history) target-point) - (setq gyp-parse-history (cdr gyp-parse-history)))) - -(defun gyp-parse-point () - "The point of the last parse state added by gyp-parse-to." - (caar gyp-parse-history)) - -(defun gyp-parse-sections () - "A list of section symbols holding at the last parse state point." - (cdar gyp-parse-history)) - -(defun gyp-inside-dictionary-p () - "Predicate returning true if the parser is inside a dictionary." - (not (eq (cadar gyp-parse-history) 'list))) - -(defun gyp-add-parse-history (point sections) - "Add parse state SECTIONS to the parse history at POINT so that parsing can be - resumed instantly." - (while (>= (caar gyp-parse-history) point) - (setq gyp-parse-history (cdr gyp-parse-history))) - (setq gyp-parse-history (cons (cons point sections) gyp-parse-history))) - -(defun gyp-parse-to (target-point) - "Parses from (point) to TARGET-POINT adding the parse state information to - gyp-parse-state-history. Parsing stops if TARGET-POINT is reached or if a - string literal has been parsed. Returns nil if no further parsing can be - done, otherwise returns the position of the start of a parsed string, leaving - the point at the end of the string." - (let ((parsing t) - string-start) - (while parsing - (setq string-start nil) - ;; Parse up to a character that starts a sexp, or if the nesting - ;; level decreases. - (let ((state (parse-partial-sexp (gyp-parse-point) - target-point - -1 - t)) - (sections (gyp-parse-sections))) - (if (= (nth 0 state) -1) - (setq sections (cdr sections)) ; pop out a level - (cond ((looking-at-p "['\"]") ; a string - (setq string-start (point)) - (goto-char (scan-sexps (point) 1)) - (if (gyp-inside-dictionary-p) - ;; Look for sections inside a dictionary - (let ((section (gyp-section-name - (buffer-substring-no-properties - (+ 1 string-start) - (- (point) 1))))) - (setq sections (cons section (cdr sections))))) - ;; Stop after the string so it can be fontified. - (setq target-point (point))) - ((looking-at-p "{") - ;; Inside a dictionary. Increase nesting. - (forward-char 1) - (setq sections (cons 'unknown sections))) - ((looking-at-p "\\[") - ;; Inside a list. Increase nesting - (forward-char 1) - (setq sections (cons 'list sections))) - ((not (eobp)) - ;; other - (forward-char 1)))) - (gyp-add-parse-history (point) sections) - (setq parsing (< (point) target-point)))) - string-start)) - -(defun gyp-section-at-point () - "Transform the last parse state, which is a list of nested sections and return - the section symbol that should be used to determine font-lock information for - the string. Can return nil indicating the string should not have any attached - section." - (let ((sections (gyp-parse-sections))) - (cond - ((eq (car sections) 'conditions) - ;; conditions can occur in a variables section, but we still want to - ;; highlight it as a keyword. - nil) - ((and (eq (car sections) 'list) - (eq (cadr sections) 'list)) - ;; conditions and sources can have items in [[ ]] - (caddr sections)) - (t (cadr sections))))) - -(defun gyp-section-match (limit) - "Parse from (point) to LIMIT returning by means of match data what was - matched. The group of the match indicates what style font-lock should apply. - See also `gyp-add-font-lock-keywords'." - (gyp-invalidate-parse-states-after (point)) - (let ((group nil) - (string-start t)) - (while (and (< (point) limit) - (not group) - string-start) - (setq string-start (gyp-parse-to limit)) - (if string-start - (setq group (cl-case (gyp-section-at-point) - ('dependencies 1) - ('variables 2) - ('conditions 2) - ('sources 3) - ('defines 4) - (nil nil))))) - (if group - (progn - ;; Set the match data to indicate to the font-lock mechanism the - ;; highlighting to be performed. - (set-match-data (append (list string-start (point)) - (make-list (* (1- group) 2) nil) - (list (1+ string-start) (1- (point))))) - t)))) - -;;; Please see http://code.google.com/p/gyp/wiki/GypLanguageSpecification for -;;; canonical list of keywords. -(defun gyp-add-font-lock-keywords () - "Add gyp-mode keywords to font-lock mechanism." - ;; TODO(jknotten): Move all the keyword highlighting into gyp-section-match - ;; so that we can do the font-locking in a single font-lock pass. - (font-lock-add-keywords - nil - (list - ;; Top-level keywords - (list (concat "['\"]\\(" - (regexp-opt (list "action" "action_name" "actions" "cflags" - "cflags_cc" "conditions" "configurations" - "copies" "defines" "dependencies" "destination" - "direct_dependent_settings" - "export_dependent_settings" "extension" "files" - "include_dirs" "includes" "inputs" "ldflags" "libraries" - "link_settings" "mac_bundle" "message" - "msvs_external_rule" "outputs" "product_name" - "process_outputs_as_sources" "rules" "rule_name" - "sources" "suppress_wildcard" - "target_conditions" "target_defaults" - "target_defines" "target_name" "toolsets" - "targets" "type" "variables" "xcode_settings")) - "[!/+=]?\\)") 1 'font-lock-keyword-face t) - ;; Type of target - (list (concat "['\"]\\(" - (regexp-opt (list "loadable_module" "static_library" - "shared_library" "executable" "none")) - "\\)") 1 'font-lock-type-face t) - (list "\\(?:target\\|action\\)_name['\"]\\s-*:\\s-*['\"]\\([^ '\"]*\\)" 1 - 'font-lock-function-name-face t) - (list 'gyp-section-match - (list 1 'font-lock-function-name-face t t) ; dependencies - (list 2 'font-lock-variable-name-face t t) ; variables, conditions - (list 3 'font-lock-constant-face t t) ; sources - (list 4 'font-lock-preprocessor-face t t)) ; preprocessor - ;; Variable expansion - (list "<@?(\\([^\n )]+\\))" 1 'font-lock-variable-name-face t) - ;; Command expansion - (list " "{dst}"') - - print("}") - - -def main(): - if len(sys.argv) < 2: - print(__doc__, file=sys.stderr) - print(file=sys.stderr) - print("usage: %s target1 target2..." % (sys.argv[0]), file=sys.stderr) - return 1 - - edges = LoadEdges("dump.json", sys.argv[1:]) - - WriteGraph(edges) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_gyp.py b/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_gyp.py deleted file mode 100644 index 4ffa4445..00000000 --- a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_gyp.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (c) 2012 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Pretty-prints the contents of a GYP file.""" - - -import sys -import re - - -# Regex to remove comments when we're counting braces. -COMMENT_RE = re.compile(r"\s*#.*") - -# Regex to remove quoted strings when we're counting braces. -# It takes into account quoted quotes, and makes sure that the quotes match. -# NOTE: It does not handle quotes that span more than one line, or -# cases where an escaped quote is preceded by an escaped backslash. -QUOTE_RE_STR = r'(?P[\'"])(.*?)(? 0: - after = True - - # This catches the special case of a closing brace having something - # other than just whitespace ahead of it -- we don't want to - # unindent that until after this line is printed so it stays with - # the previous indentation level. - if cnt < 0 and closing_prefix_re.match(stripline): - after = True - return (cnt, after) - - -def prettyprint_input(lines): - """Does the main work of indenting the input based on the brace counts.""" - indent = 0 - basic_offset = 2 - for line in lines: - if COMMENT_RE.match(line): - print(line) - else: - line = line.strip("\r\n\t ") # Otherwise doesn't strip \r on Unix. - if len(line) > 0: - (brace_diff, after) = count_braces(line) - if brace_diff != 0: - if after: - print(" " * (basic_offset * indent) + line) - indent += brace_diff - else: - indent += brace_diff - print(" " * (basic_offset * indent) + line) - else: - print(" " * (basic_offset * indent) + line) - else: - print("") - - -def main(): - if len(sys.argv) > 1: - data = open(sys.argv[1]).read().splitlines() - else: - data = sys.stdin.read().splitlines() - # Split up the double braces. - lines = split_double_braces(data) - - # Indent and print the output. - prettyprint_input(lines) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_sln.py b/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_sln.py deleted file mode 100644 index 6ca0cd12..00000000 --- a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_sln.py +++ /dev/null @@ -1,181 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (c) 2012 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Prints the information in a sln file in a diffable way. - - It first outputs each projects in alphabetical order with their - dependencies. - - Then it outputs a possible build order. -""" - - -import os -import re -import sys -import pretty_vcproj - -__author__ = "nsylvain (Nicolas Sylvain)" - - -def BuildProject(project, built, projects, deps): - # if all dependencies are done, we can build it, otherwise we try to build the - # dependency. - # This is not infinite-recursion proof. - for dep in deps[project]: - if dep not in built: - BuildProject(dep, built, projects, deps) - print(project) - built.append(project) - - -def ParseSolution(solution_file): - # All projects, their clsid and paths. - projects = dict() - - # A list of dependencies associated with a project. - dependencies = dict() - - # Regular expressions that matches the SLN format. - # The first line of a project definition. - begin_project = re.compile( - r'^Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942' - r'}"\) = "(.*)", "(.*)", "(.*)"$' - ) - # The last line of a project definition. - end_project = re.compile("^EndProject$") - # The first line of a dependency list. - begin_dep = re.compile(r"ProjectSection\(ProjectDependencies\) = postProject$") - # The last line of a dependency list. - end_dep = re.compile("EndProjectSection$") - # A line describing a dependency. - dep_line = re.compile(" *({.*}) = ({.*})$") - - in_deps = False - solution = open(solution_file) - for line in solution: - results = begin_project.search(line) - if results: - # Hack to remove icu because the diff is too different. - if results.group(1).find("icu") != -1: - continue - # We remove "_gyp" from the names because it helps to diff them. - current_project = results.group(1).replace("_gyp", "") - projects[current_project] = [ - results.group(2).replace("_gyp", ""), - results.group(3), - results.group(2), - ] - dependencies[current_project] = [] - continue - - results = end_project.search(line) - if results: - current_project = None - continue - - results = begin_dep.search(line) - if results: - in_deps = True - continue - - results = end_dep.search(line) - if results: - in_deps = False - continue - - results = dep_line.search(line) - if results and in_deps and current_project: - dependencies[current_project].append(results.group(1)) - continue - - # Change all dependencies clsid to name instead. - for project in dependencies: - # For each dependencies in this project - new_dep_array = [] - for dep in dependencies[project]: - # Look for the project name matching this cldis - for project_info in projects: - if projects[project_info][1] == dep: - new_dep_array.append(project_info) - dependencies[project] = sorted(new_dep_array) - - return (projects, dependencies) - - -def PrintDependencies(projects, deps): - print("---------------------------------------") - print("Dependencies for all projects") - print("---------------------------------------") - print("-- --") - - for (project, dep_list) in sorted(deps.items()): - print("Project : %s" % project) - print("Path : %s" % projects[project][0]) - if dep_list: - for dep in dep_list: - print(" - %s" % dep) - print("") - - print("-- --") - - -def PrintBuildOrder(projects, deps): - print("---------------------------------------") - print("Build order ") - print("---------------------------------------") - print("-- --") - - built = [] - for (project, _) in sorted(deps.items()): - if project not in built: - BuildProject(project, built, projects, deps) - - print("-- --") - - -def PrintVCProj(projects): - - for project in projects: - print("-------------------------------------") - print("-------------------------------------") - print(project) - print(project) - print(project) - print("-------------------------------------") - print("-------------------------------------") - - project_path = os.path.abspath( - os.path.join(os.path.dirname(sys.argv[1]), projects[project][2]) - ) - - pretty = pretty_vcproj - argv = [ - "", - project_path, - "$(SolutionDir)=%s\\" % os.path.dirname(sys.argv[1]), - ] - argv.extend(sys.argv[3:]) - pretty.main(argv) - - -def main(): - # check if we have exactly 1 parameter. - if len(sys.argv) < 2: - print('Usage: %s "c:\\path\\to\\project.sln"' % sys.argv[0]) - return 1 - - (projects, deps) = ParseSolution(sys.argv[1]) - PrintDependencies(projects, deps) - PrintBuildOrder(projects, deps) - - if "--recursive" in sys.argv: - PrintVCProj(projects) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_vcproj.py b/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_vcproj.py deleted file mode 100644 index 00d32deb..00000000 --- a/sandbox/testAppNevena/Front/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +++ /dev/null @@ -1,339 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (c) 2012 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Make the format of a vcproj really pretty. - - This script normalize and sort an xml. It also fetches all the properties - inside linked vsprops and include them explicitly in the vcproj. - - It outputs the resulting xml to stdout. -""" - - -import os -import sys - -from xml.dom.minidom import parse -from xml.dom.minidom import Node - -__author__ = "nsylvain (Nicolas Sylvain)" -ARGUMENTS = None -REPLACEMENTS = dict() - - -def cmp(x, y): - return (x > y) - (x < y) - - -class CmpTuple: - """Compare function between 2 tuple.""" - - def __call__(self, x, y): - return cmp(x[0], y[0]) - - -class CmpNode: - """Compare function between 2 xml nodes.""" - - def __call__(self, x, y): - def get_string(node): - node_string = "node" - node_string += node.nodeName - if node.nodeValue: - node_string += node.nodeValue - - if node.attributes: - # We first sort by name, if present. - node_string += node.getAttribute("Name") - - all_nodes = [] - for (name, value) in node.attributes.items(): - all_nodes.append((name, value)) - - all_nodes.sort(CmpTuple()) - for (name, value) in all_nodes: - node_string += name - node_string += value - - return node_string - - return cmp(get_string(x), get_string(y)) - - -def PrettyPrintNode(node, indent=0): - if node.nodeType == Node.TEXT_NODE: - if node.data.strip(): - print("{}{}".format(" " * indent, node.data.strip())) - return - - if node.childNodes: - node.normalize() - # Get the number of attributes - attr_count = 0 - if node.attributes: - attr_count = node.attributes.length - - # Print the main tag - if attr_count == 0: - print("{}<{}>".format(" " * indent, node.nodeName)) - else: - print("{}<{}".format(" " * indent, node.nodeName)) - - all_attributes = [] - for (name, value) in node.attributes.items(): - all_attributes.append((name, value)) - all_attributes.sort(CmpTuple()) - for (name, value) in all_attributes: - print('{} {}="{}"'.format(" " * indent, name, value)) - print("%s>" % (" " * indent)) - if node.nodeValue: - print("{} {}".format(" " * indent, node.nodeValue)) - - for sub_node in node.childNodes: - PrettyPrintNode(sub_node, indent=indent + 2) - print("{}".format(" " * indent, node.nodeName)) - - -def FlattenFilter(node): - """Returns a list of all the node and sub nodes.""" - node_list = [] - - if node.attributes and node.getAttribute("Name") == "_excluded_files": - # We don't add the "_excluded_files" filter. - return [] - - for current in node.childNodes: - if current.nodeName == "Filter": - node_list.extend(FlattenFilter(current)) - else: - node_list.append(current) - - return node_list - - -def FixFilenames(filenames, current_directory): - new_list = [] - for filename in filenames: - if filename: - for key in REPLACEMENTS: - filename = filename.replace(key, REPLACEMENTS[key]) - os.chdir(current_directory) - filename = filename.strip("\"' ") - if filename.startswith("$"): - new_list.append(filename) - else: - new_list.append(os.path.abspath(filename)) - return new_list - - -def AbsoluteNode(node): - """Makes all the properties we know about in this node absolute.""" - if node.attributes: - for (name, value) in node.attributes.items(): - if name in [ - "InheritedPropertySheets", - "RelativePath", - "AdditionalIncludeDirectories", - "IntermediateDirectory", - "OutputDirectory", - "AdditionalLibraryDirectories", - ]: - # We want to fix up these paths - path_list = value.split(";") - new_list = FixFilenames(path_list, os.path.dirname(ARGUMENTS[1])) - node.setAttribute(name, ";".join(new_list)) - if not value: - node.removeAttribute(name) - - -def CleanupVcproj(node): - """For each sub node, we call recursively this function.""" - for sub_node in node.childNodes: - AbsoluteNode(sub_node) - CleanupVcproj(sub_node) - - # Normalize the node, and remove all extraneous whitespaces. - for sub_node in node.childNodes: - if sub_node.nodeType == Node.TEXT_NODE: - sub_node.data = sub_node.data.replace("\r", "") - sub_node.data = sub_node.data.replace("\n", "") - sub_node.data = sub_node.data.rstrip() - - # Fix all the semicolon separated attributes to be sorted, and we also - # remove the dups. - if node.attributes: - for (name, value) in node.attributes.items(): - sorted_list = sorted(value.split(";")) - unique_list = [] - for i in sorted_list: - if not unique_list.count(i): - unique_list.append(i) - node.setAttribute(name, ";".join(unique_list)) - if not value: - node.removeAttribute(name) - - if node.childNodes: - node.normalize() - - # For each node, take a copy, and remove it from the list. - node_array = [] - while node.childNodes and node.childNodes[0]: - # Take a copy of the node and remove it from the list. - current = node.childNodes[0] - node.removeChild(current) - - # If the child is a filter, we want to append all its children - # to this same list. - if current.nodeName == "Filter": - node_array.extend(FlattenFilter(current)) - else: - node_array.append(current) - - # Sort the list. - node_array.sort(CmpNode()) - - # Insert the nodes in the correct order. - for new_node in node_array: - # But don't append empty tool node. - if new_node.nodeName == "Tool": - if new_node.attributes and new_node.attributes.length == 1: - # This one was empty. - continue - if new_node.nodeName == "UserMacro": - continue - node.appendChild(new_node) - - -def GetConfiguationNodes(vcproj): - # TODO(nsylvain): Find a better way to navigate the xml. - nodes = [] - for node in vcproj.childNodes: - if node.nodeName == "Configurations": - for sub_node in node.childNodes: - if sub_node.nodeName == "Configuration": - nodes.append(sub_node) - - return nodes - - -def GetChildrenVsprops(filename): - dom = parse(filename) - if dom.documentElement.attributes: - vsprops = dom.documentElement.getAttribute("InheritedPropertySheets") - return FixFilenames(vsprops.split(";"), os.path.dirname(filename)) - return [] - - -def SeekToNode(node1, child2): - # A text node does not have properties. - if child2.nodeType == Node.TEXT_NODE: - return None - - # Get the name of the current node. - current_name = child2.getAttribute("Name") - if not current_name: - # There is no name. We don't know how to merge. - return None - - # Look through all the nodes to find a match. - for sub_node in node1.childNodes: - if sub_node.nodeName == child2.nodeName: - name = sub_node.getAttribute("Name") - if name == current_name: - return sub_node - - # No match. We give up. - return None - - -def MergeAttributes(node1, node2): - # No attributes to merge? - if not node2.attributes: - return - - for (name, value2) in node2.attributes.items(): - # Don't merge the 'Name' attribute. - if name == "Name": - continue - value1 = node1.getAttribute(name) - if value1: - # The attribute exist in the main node. If it's equal, we leave it - # untouched, otherwise we concatenate it. - if value1 != value2: - node1.setAttribute(name, ";".join([value1, value2])) - else: - # The attribute does not exist in the main node. We append this one. - node1.setAttribute(name, value2) - - # If the attribute was a property sheet attributes, we remove it, since - # they are useless. - if name == "InheritedPropertySheets": - node1.removeAttribute(name) - - -def MergeProperties(node1, node2): - MergeAttributes(node1, node2) - for child2 in node2.childNodes: - child1 = SeekToNode(node1, child2) - if child1: - MergeProperties(child1, child2) - else: - node1.appendChild(child2.cloneNode(True)) - - -def main(argv): - """Main function of this vcproj prettifier.""" - global ARGUMENTS - ARGUMENTS = argv - - # check if we have exactly 1 parameter. - if len(argv) < 2: - print( - 'Usage: %s "c:\\path\\to\\vcproj.vcproj" [key1=value1] ' - "[key2=value2]" % argv[0] - ) - return 1 - - # Parse the keys - for i in range(2, len(argv)): - (key, value) = argv[i].split("=") - REPLACEMENTS[key] = value - - # Open the vcproj and parse the xml. - dom = parse(argv[1]) - - # First thing we need to do is find the Configuration Node and merge them - # with the vsprops they include. - for configuration_node in GetConfiguationNodes(dom.documentElement): - # Get the property sheets associated with this configuration. - vsprops = configuration_node.getAttribute("InheritedPropertySheets") - - # Fix the filenames to be absolute. - vsprops_list = FixFilenames( - vsprops.strip().split(";"), os.path.dirname(argv[1]) - ) - - # Extend the list of vsprops with all vsprops contained in the current - # vsprops. - for current_vsprops in vsprops_list: - vsprops_list.extend(GetChildrenVsprops(current_vsprops)) - - # Now that we have all the vsprops, we need to merge them. - for current_vsprops in vsprops_list: - MergeProperties(configuration_node, parse(current_vsprops).documentElement) - - # Now that everything is merged, we need to cleanup the xml. - CleanupVcproj(dom.documentElement) - - # Finally, we use the prett xml function to print the vcproj back to the - # user. - # print dom.toprettyxml(newl="\n") - PrettyPrintNode(dom.documentElement) - return 0 - - -if __name__ == "__main__": - sys.exit(main(sys.argv)) -- cgit v1.2.3