MCPcopy Create free account
hub / github.com/nodejs/node / Write

Method Write

tools/gyp/pylib/gyp/MSVSNew.py:230–365  ·  view source on GitHub ↗

Writes the solution file to disk. Raises: IndexError: An entry appears multiple times.

(self, writer=gyp.common.WriteOnDiff)

Source from the content-addressed store, hash-verified

228 self.Write()
229
230 def Write(self, writer=gyp.common.WriteOnDiff):
231 """Writes the solution file to disk.
232
233 Raises:
234 IndexError: An entry appears multiple times.
235 """
236 # Walk the entry tree and collect all the folders and projects.
237 all_entries = set()
238 entries_to_check = self.entries[:]
239 while entries_to_check:
240 e = entries_to_check.pop(0)
241
242 # If this entry has been visited, nothing to do.
243 if e in all_entries:
244 continue
245
246 all_entries.add(e)
247
248 # If this is a folder, check its entries too.
249 if isinstance(e, MSVSFolder):
250 entries_to_check += e.entries
251
252 all_entries = sorted(all_entries, key=attrgetter("path"))
253
254 # Open file and print header
255 f = writer(self.path)
256 f.write(
257 "Microsoft Visual Studio Solution File, "
258 "Format Version %s\r\n" % self.version.SolutionVersion()
259 )
260 f.write("# %s\r\n" % self.version.Description())
261
262 # Project entries
263 sln_root = os.path.split(self.path)[0]
264 for e in all_entries:
265 relative_path = gyp.common.RelativePath(e.path, sln_root)
266 # msbuild does not accept an empty folder_name.
267 # use '.' in case relative_path is empty.
268 folder_name = relative_path.replace("/", "\\") or "."
269 f.write(
270 'Project("%s") = "%s", "%s", "%s"\r\n'
271 % (
272 e.entry_type_guid, # Entry type GUID
273 e.name, # Folder name
274 folder_name, # Folder name (again)
275 e.get_guid(), # Entry GUID
276 )
277 )
278
279 # TODO(rspangler): Need a way to configure this stuff
280 if self.websiteProperties:
281 f.write(
282 "\tProjectSection(WebsiteProperties) = preProject\r\n"
283 '\t\tDebug.AspNetCompiler.Debug = "True"\r\n'
284 '\t\tRelease.AspNetCompiler.Debug = "False"\r\n'
285 "\tEndProjectSection\r\n"
286 )
287

Callers 2

__init__Method · 0.95
GenerateOutputFunction · 0.95

Calls 15

sortedFunction · 0.85
popMethod · 0.80
SolutionVersionMethod · 0.80
DescriptionMethod · 0.80
sortMethod · 0.80
addMethod · 0.65
getMethod · 0.65
closeMethod · 0.65
setFunction · 0.50
attrgetterFunction · 0.50
writerFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected