source: trip-planner-front/node_modules/node-gyp/gyp/tools/pretty_sln.py@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.4 KB
Line 
1#!/usr/bin/env python
2
3# Copyright (c) 2012 Google Inc. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Prints the information in a sln file in a diffable way.
8
9 It first outputs each projects in alphabetical order with their
10 dependencies.
11
12 Then it outputs a possible build order.
13"""
14
15from __future__ import print_function
16
17import os
18import re
19import sys
20import pretty_vcproj
21
22__author__ = "nsylvain (Nicolas Sylvain)"
23
24
25def BuildProject(project, built, projects, deps):
26 # if all dependencies are done, we can build it, otherwise we try to build the
27 # dependency.
28 # This is not infinite-recursion proof.
29 for dep in deps[project]:
30 if dep not in built:
31 BuildProject(dep, built, projects, deps)
32 print(project)
33 built.append(project)
34
35
36def ParseSolution(solution_file):
37 # All projects, their clsid and paths.
38 projects = dict()
39
40 # A list of dependencies associated with a project.
41 dependencies = dict()
42
43 # Regular expressions that matches the SLN format.
44 # The first line of a project definition.
45 begin_project = re.compile(
46 r'^Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942'
47 r'}"\) = "(.*)", "(.*)", "(.*)"$'
48 )
49 # The last line of a project definition.
50 end_project = re.compile("^EndProject$")
51 # The first line of a dependency list.
52 begin_dep = re.compile(r"ProjectSection\(ProjectDependencies\) = postProject$")
53 # The last line of a dependency list.
54 end_dep = re.compile("EndProjectSection$")
55 # A line describing a dependency.
56 dep_line = re.compile(" *({.*}) = ({.*})$")
57
58 in_deps = False
59 solution = open(solution_file)
60 for line in solution:
61 results = begin_project.search(line)
62 if results:
63 # Hack to remove icu because the diff is too different.
64 if results.group(1).find("icu") != -1:
65 continue
66 # We remove "_gyp" from the names because it helps to diff them.
67 current_project = results.group(1).replace("_gyp", "")
68 projects[current_project] = [
69 results.group(2).replace("_gyp", ""),
70 results.group(3),
71 results.group(2),
72 ]
73 dependencies[current_project] = []
74 continue
75
76 results = end_project.search(line)
77 if results:
78 current_project = None
79 continue
80
81 results = begin_dep.search(line)
82 if results:
83 in_deps = True
84 continue
85
86 results = end_dep.search(line)
87 if results:
88 in_deps = False
89 continue
90
91 results = dep_line.search(line)
92 if results and in_deps and current_project:
93 dependencies[current_project].append(results.group(1))
94 continue
95
96 # Change all dependencies clsid to name instead.
97 for project in dependencies:
98 # For each dependencies in this project
99 new_dep_array = []
100 for dep in dependencies[project]:
101 # Look for the project name matching this cldis
102 for project_info in projects:
103 if projects[project_info][1] == dep:
104 new_dep_array.append(project_info)
105 dependencies[project] = sorted(new_dep_array)
106
107 return (projects, dependencies)
108
109
110def PrintDependencies(projects, deps):
111 print("---------------------------------------")
112 print("Dependencies for all projects")
113 print("---------------------------------------")
114 print("-- --")
115
116 for (project, dep_list) in sorted(deps.items()):
117 print("Project : %s" % project)
118 print("Path : %s" % projects[project][0])
119 if dep_list:
120 for dep in dep_list:
121 print(" - %s" % dep)
122 print("")
123
124 print("-- --")
125
126
127def PrintBuildOrder(projects, deps):
128 print("---------------------------------------")
129 print("Build order ")
130 print("---------------------------------------")
131 print("-- --")
132
133 built = []
134 for (project, _) in sorted(deps.items()):
135 if project not in built:
136 BuildProject(project, built, projects, deps)
137
138 print("-- --")
139
140
141def PrintVCProj(projects):
142
143 for project in projects:
144 print("-------------------------------------")
145 print("-------------------------------------")
146 print(project)
147 print(project)
148 print(project)
149 print("-------------------------------------")
150 print("-------------------------------------")
151
152 project_path = os.path.abspath(
153 os.path.join(os.path.dirname(sys.argv[1]), projects[project][2])
154 )
155
156 pretty = pretty_vcproj
157 argv = [
158 "",
159 project_path,
160 "$(SolutionDir)=%s\\" % os.path.dirname(sys.argv[1]),
161 ]
162 argv.extend(sys.argv[3:])
163 pretty.main(argv)
164
165
166def main():
167 # check if we have exactly 1 parameter.
168 if len(sys.argv) < 2:
169 print('Usage: %s "c:\\path\\to\\project.sln"' % sys.argv[0])
170 return 1
171
172 (projects, deps) = ParseSolution(sys.argv[1])
173 PrintDependencies(projects, deps)
174 PrintBuildOrder(projects, deps)
175
176 if "--recursive" in sys.argv:
177 PrintVCProj(projects)
178 return 0
179
180
181if __name__ == "__main__":
182 sys.exit(main())
Note: See TracBrowser for help on using the repository browser.