Main function of this vcproj prettifier.
(argv)
| 282 | |
| 283 | |
| 284 | def main(argv): |
| 285 | """Main function of this vcproj prettifier.""" |
| 286 | global ARGUMENTS |
| 287 | ARGUMENTS = argv |
| 288 | |
| 289 | # check if we have exactly 1 parameter. |
| 290 | if len(argv) < 2: |
| 291 | print( |
| 292 | 'Usage: %s "c:\\path\\to\\vcproj.vcproj" [key1=value1] ' |
| 293 | "[key2=value2]" % argv[0] |
| 294 | ) |
| 295 | return 1 |
| 296 | |
| 297 | # Parse the keys |
| 298 | for i in range(2, len(argv)): |
| 299 | (key, value) = argv[i].split("=") |
| 300 | REPLACEMENTS[key] = value |
| 301 | |
| 302 | # Open the vcproj and parse the xml. |
| 303 | dom = parse(argv[1]) |
| 304 | |
| 305 | # First thing we need to do is find the Configuration Node and merge them |
| 306 | # with the vsprops they include. |
| 307 | for configuration_node in GetConfigurationNodes(dom.documentElement): |
| 308 | # Get the property sheets associated with this configuration. |
| 309 | vsprops = configuration_node.getAttribute("InheritedPropertySheets") |
| 310 | |
| 311 | # Fix the filenames to be absolute. |
| 312 | vsprops_list = FixFilenames( |
| 313 | vsprops.strip().split(";"), os.path.dirname(argv[1]) |
| 314 | ) |
| 315 | |
| 316 | # Extend the list of vsprops with all vsprops contained in the current |
| 317 | # vsprops. |
| 318 | for current_vsprops in vsprops_list: |
| 319 | vsprops_list.extend(GetChildrenVsprops(current_vsprops)) |
| 320 | |
| 321 | # Now that we have all the vsprops, we need to merge them. |
| 322 | for current_vsprops in vsprops_list: |
| 323 | MergeProperties(configuration_node, parse(current_vsprops).documentElement) |
| 324 | |
| 325 | # Now that everything is merged, we need to cleanup the xml. |
| 326 | CleanupVcproj(dom.documentElement) |
| 327 | |
| 328 | # Finally, we use the prett xml function to print the vcproj back to the |
| 329 | # user. |
| 330 | # print dom.toprettyxml(newl="\n") |
| 331 | PrettyPrintNode(dom.documentElement) |
| 332 | return 0 |
| 333 | |
| 334 | |
| 335 | if __name__ == "__main__": |
no test coverage detected