vcprojtool.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # @brief VCProject file generator
4 # @date $Date: 2008-02-29 04:52:14 $
5 # @author Norkai Ando <n-ando@aist.go.jp>
6 #
7 # Copyright (C) 2008
8 # Noriaki Ando
9 # Task-intelligence Research Group,
10 # Intelligent Systems Research Institute,
11 # National Institute of
12 # Advanced Industrial Science and Technology (AIST), Japan
13 # All rights reserved.
14 #
15 # $Id: vcprojtool.py 775 2008-07-28 16:14:45Z n-ando $
16 #
17 
18 #------------------------------------------------------------
19 # Generic vcproj template
20 #------------------------------------------------------------
21 vcproj_template = """<?xml version="1.0" encoding="shift_jis"?>
22 <VisualStudioProject
23  ProjectType="[ProjectType]"
24  Version="[Version]"
25  Name="[RootNamespace]"
26  ProjectGUID="{[ProjectGUID]}"
27  RootNamespace="[RootNamespace]"
28  Keyword="Win32Proj"
29  >
30  <Platforms>
31  <Platform
32  Name="Win32"
33  />
34  </Platforms>
35  <ToolFiles>
36  </ToolFiles>
37  <Configurations>
38 [for conf in Configurations]
39  <Configuration
40  Name="[conf.Name]"
41  OutputDirectory="[conf.OutputDirectory]"
42  IntermediateDirectory="[conf.IntermediateDirectory]"
43  ConfigurationType="%d"
44  CharacterSet="0"
45 [if-any conf.InheritedPropertySheets]
46  InheritedPropertySheets="[conf.InheritedPropertySheets]"
47 [endif]
48  >
49 %s
50  </Configuration>
51 [endfor]
52  </Configurations>
53  <References>
54  </References>
55  <Files>
56 [if-any Source]
57  <Filter
58  Name="[Source.Name]"
59  Filter="[Source.Filter]"
60  UniqueIdentifier="{[Source.GUID]}"
61  >
62 [if-any Source.Files][for file in Source.Files]
63  <File
64  RelativePath="[file.Path]"
65  >
66  </File>
67 [endfor][endif]
68  </Filter>
69 [endif]
70 [if-any Header]
71  <Filter
72  Name="[Header.Name]"
73  Filter="[Header.Filter]"
74  UniqueIdentifier="{[Header.GUID]}"
75  >
76 [if-any Header.Files][for file in Header.Files]
77  <File
78  RelativePath="[file.Path]"
79  >
80  </File>
81 [endfor][endif]
82  </Filter>
83 [endif]
84 [if-any Resource]
85  <Filter
86  Name="[Resource.Name]"
87  Filter="[Resource.Filter]"
88  UniqueIdentifier="{[Resource.GUID]}"
89  >
90 [if-any Resoruce.Files][for file in Resoruce.Files]
91  <File
92  RelativePath="[file.Path]"
93  >
94  </File>
95 [endfor][endif]
96  </Filter>
97 [endif]
98  </Files>
99  <Globals>
100  </Globals>
101 </VisualStudioProject>
102 """
103 
104 #------------------------------------------------------------
105 # ConfigurationType
106 #------------------------------------------------------------
107 conf_type = {"EXE": 1, "DLL": 2, "NMAKE": 3, "LIB": 4,
108  "RTCEXE": 1, "RTCDLL": 2}
109 
110 #------------------------------------------------------------
111 # Tool set for configuration
112 #------------------------------------------------------------
113 tools = {"EXE":
114  ["VCPreBuildEventTool",
115  "VCCustomBuildTool",
116  "VCXMLDataGeneratorTool",
117  "VCWebServiceProxyGeneratorTool",
118  "VCMIDLTool",
119  "VCCLCompilerTool",
120  "VCManagedResourceCompilerTool",
121  "VCResourceCompilerTool",
122  "VCPreLinkEventTool",
123  "VCLinkerTool",
124  "VCALinkTool",
125  "VCManifestTool",
126  "VCXDCMakeTool",
127  "VCBscMakeTool",
128  "VCFxCopTool",
129  "VCAppVerifierTool",
130  "VCWebDeploymentTool",
131  "VCPostBuildEventTool"],
132  "DLL":
133  ["VCPreBuildEventTool",
134  "VCCustomBuildTool",
135  "VCXMLDataGeneratorTool",
136  "VCWebServiceProxyGeneratorTool",
137  "VCMIDLTool",
138  "VCCLCompilerTool",
139  "VCManagedResourceCompilerTool",
140  "VCResourceCompilerTool",
141  "VCPreLinkEventTool",
142  "VCLinkerTool",
143  "VCALinkTool",
144  "VCManifestTool",
145  "VCXDCMakeTool",
146  "VCBscMakeTool",
147  "VCFxCopTool",
148  "VCAppVerifierTool",
149  "VCWebDeploymentTool",
150  "VCPostBuildEventTool"],
151  "LIB":
152  ["VCPreBuildEventTool",
153  "VCCustomBuildTool",
154  "VCXMLDataGeneratorTool",
155  "VCWebServiceProxyGeneratorTool",
156  "VCMIDLTool",
157  "VCCLCompilerTool",
158  "VCManagedResourceCompilerTool",
159  "VCResourceCompilerTool",
160  "VCPreLinkEventTool",
161  "VCLibrarianTool",
162  "VCALinkTool",
163  "VCXDCMakeTool",
164  "VCBscMakeTool",
165  "VCFxCopTool",
166  "VCPostBuildEventTool"]
167  }
168 tools["RTCEXE"] = tools["EXE"]
169 tools["RTCDLL"] = tools["DLL"]
170 
171 
172 #------------------------------------------------------------
173 # Tool element
174 #------------------------------------------------------------
175 tool_elem = """ <Tool
176  Name="%s"
177 [if-any conf.%s][for tool in conf.%s]
178 [if-any tool.Key]
179  [tool.Key]="[tool.Value]"
180 [endif]
181 [endfor][endif]
182  />
183 """
184 
185 
186 exeproj_yaml = """
187 ProjectType: Visual C++
188 Version: 8.00
189 Name: # Your Project Name
190 ProjectGUID: __GUID__
191 RootNamespace:
192 Keyword: Win32Proj
193 Platforms:
194  Platform:
195  Name: Win32
196 Configurations:
197  - Name: Debug
198  OutputDirectory: $(ProjectDir)$(ConfigurationName)
199  IntermediateDirectory: $(ConfigurationName)
200  InheritedPropertySheets: # Set vsprops file if you need
201 """
202 
203 
204 #------------------------------------------------------------
205 # Yaml template
206 #------------------------------------------------------------
207 exe_yaml = """ProjectType: "Visual C++"
208 Version: "8.00"
209 Name: __PROJECT_NAME__
210 ProjectGUID: __GUID__
211 RootNamespace: __PROJECT_NAME__
212 Keyword: "Win32Proj"
213 Configurations:
214 #------------------------------------------------------------
215 # Debug Configuration
216 #------------------------------------------------------------
217  - Name: "Debug|Win32"
218  OutputDirectory: $(ProjectDir)$(ConfigurationName)"
219  IntermediateDirectory: "$(ConfiguratioName)"
220  ConfigurationType: "1"
221 # InheritedPropertySheets:
222  CharacterSet: "0"
223 # VCPreBuildEventTool:
224 # VCCustomBuildTool:
225 # VCXMLDataGeneratorTool:
226 # VCWebServiceProxyGeneratorTool:
227 # VCMIDLTool:
228  VCCLCompilerTool:
229  - Key: Optimization
230  Value: 0
231  - Key: PreprocessorDefinitions
232  Value: "WIN32;_DEBUG;_CONSOLE;__WIN32__;__x86__;_WIN32_WINNT=0x0500;__NT__;__OSVERSION__=4"
233  - Key: MinimalRebuild
234  Value: "true"
235  - Key: BasicRuntimeChecks
236  Value: "3"
237  - Key: RuntimeLibrary
238  Value: "3"
239  - Key: UsePrecompiledHeader
240  Value: "0"
241  - Key: WarningLevel
242  Value: "3"
243  - Key: Detect64BitPortabilityProblems
244  Value: "false"
245  - Key: DebugInformationFormat
246  Value: "4"
247 # VCManagedResourceCompilerTool:
248 # VCResourceCompilerTool:
249 # VCPreLinkEventTool:
250  VCLinkerTool:
251  - Key: AdditionalDependencies
252  Value: ""
253  - Key: OutputFile
254  Value: "$(OutDir)\\\\__PROJECT_NAME__.exe"
255  - Key: LinkIncremental
256  Value: "2"
257  - Key: IgnoreDefaultLibraryNames
258  Value: ""
259  - Key: GenerateDebugInformation
260  Value: "true"
261  - Key: SubSystem
262  Value: "1"
263  - Key: TargetMachine
264  Value: "1"
265 # VCALinkTool:
266 # VCManifestTool:
267 # VCXDCMakeTool:
268 # VCBscMakeTool:
269 # VCFxCopTool:
270 # VCAppVerifierTool:
271 # VCWebDeploymentTool:
272  VCPostBuildEventTool:
273 #------------------------------------------------------------
274 # Release Configuration
275 #------------------------------------------------------------
276  - Name: "Release|Win32"
277  OutputDirectory: $(ProjectDir)$(ConfigurationName)"
278  IntermediateDirectory: "$(ConfiguratioName)"
279  ConfigurationType: "1"
280  InheritedPropertySheets: ""
281  CharacterSet: "0"
282  WholeProgramOptimization: "0"
283 # VCPreBuildEventTool:
284 # VCCustomBuildTool:
285 # VCXMLDataGeneratorTool:
286 # VCWebServiceProxyGeneratorTool:
287 # VCMIDLTool:
288  VCCLCompilerTool:
289  - Key: PreprocessorDefinitions
290  Value: "WIN32;NDEBUG;_CONSOLE;__WIN32__;__x86__;_WIN32_WINNT=0x0500;__NT__;__OSVERSION__=4"
291  - Key: RuntimeLibrary
292  Value: "2"
293  - Key: UsePrecompiledHeader
294  Value: "0"
295  - Key: WarningLevel
296  Value: "3"
297  - Key: Detect64BitPortabilityProblems
298  Value: "false"
299  - Key: DebugInformationFormat
300  Value: "3"
301 # VCManagedResourceCompilerTool"
302 # VCResourceCompilerTool"
303 # VCPreLinkEventTool"
304  VCLinkerTool:
305  - Key: AdditionalDependencies
306  Value: ""
307  - Key: OutputFile
308  Value: "$(OutDir)\\\\__PROJECT_NAME__.exe"
309  - Key: LinkIncremental
310  Value: "1"
311  - Key: GenerateDebugInformation
312  Value: "false"
313  - Key: SubSystem
314  Value: "1"
315  - Key: OptimizeReferences
316  Value: "2"
317  - Key: EnableCOMDATFolding
318  Value: "2"
319  - Key: LinkTimeCodeGeneration
320  Value: "0"
321  - Key: TargetMachine
322  Value: "1"
323 # VCALinkTool:
324 # VCManifestTool:
325 # VCXDCMakeTool:
326 # VCBscMakeTool:
327 # VCFxCopTool:
328 # VCAppVerifierTool:
329 # VCWebDeploymentTool:
330 # VCPostBuildEventTool:
331 """
332 
333 dll_yaml = """ProjectType: "Visual C++"
334 Version: "8.00"
335 Name: __PROJECT_NAME__
336 ProjectGUID: __GUID__
337 RootNamespace: __PROJECT_NAME__
338 Keyword: "Win32Proj"
339 Configurations:
340  - Name: "Debug|Win32"
341  OutputDirectory: "$(ProjectDir)$(ConfigurationName)"
342  IntermediateDirectory: "$(ConfigurationName)"
343  ConfigurationType: "2"
344 # InheritedPropertySheets: ""
345  CharacterSet: "0"
346 # VCPreBuildEventTool:
347 # VCCustomBuildTool:
348 # VCXMLDataGeneratorTool:
349 # VCWebServiceProxyGeneratorTool:
350 # VCMIDLTool:
351  VCCLCompilerTool:
352  - Key: Optimization
353  Value: "0"
354  - Key: PreprocessorDefinitions
355  Value: "WIN32;_DEBUG;_WINDOWS;_USRDLL;__WIN32__;__NT__;__OSVERSION__=4;__x86__;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
356  - Key: MinimalRebuild
357  Value: "true"
358  - Key: BasicRuntimeChecks
359  Value: "3"
360  - Key: RuntimeLibrary
361  Value: "3"
362  - Key: UsePrecompiledHeader
363  Value: "0"
364  - Key: WarningLevel
365  Value: "3"
366  - Key: Detect64BitPortabilityProblems
367  Value: "false"
368  - Key: DebugInformationFormat
369  Value: "4"
370 # VCManagedResourceCompilerTool:
371 # VCResourceCompilerTool:
372  VCPreLinkEventTool:
373  - Key: CommandLine
374  Value: |
375  lib -out:"$(TargetDir)RTC_static.lib" "$(TargetDir)*.obj" "$(SolutionDir)\\\\rtm\\\\idl\\\\$(ConfigurationName)\\\\*.obj"
376  set PATH=%PATH%;$(rtm_path)
377  cd $(OutDir)
378  start /wait cmd /c makedeffile.py RTC_static.lib RTC042d 0.4.1 RTC042d.def
379  move RTC042d.def ..\\\\
380  VCLinkerTool:
381  - Key: AdditionalDependencies
382  Value: ""
383  - Key: OutputFile
384  Value: "$(OutDir)\\\\__PROJECT_NAME__.dll"
385  - Key: Version
386  Value: __VERSION__
387  - Key: LinkIncremental
388  Value: "2"
389  - Key: ModuleDefinitionFile
390  Value: "$(TargetName).def"
391  - Key: GenerateDebugInformation
392  Value: "true"
393  - Key: SubSystem
394  Value: "2"
395  - Key: TargetMachine
396  Value: "1"
397 # VCALinkTool:
398 # VCManifestTool:
399 # VCXDCMakeTool:
400 # VCBscMakeTool:
401 # VCFxCopTool:
402 # VCAppVerifierTool:
403 # VCWebDeploymentTool:
404  VCPostBuildEventTool:
405  - Key: CommandLine
406  Value: |
407  copy "$(OutDir)\\\\$(TargetName).lib" "$(SolutionDir)bin\\\\"
408  copy "$(OutDir)\\\\$(TargetName).dll" "$(SolutionDir)bin\\\\"
409  - Name: "Release|Win32"
410  OutputDirectory: "$(ProjectDir)$(ConfigurationName)"
411  IntermediateDirectory: "$(ConfigurationName)"
412  ConfigurationType: "2"
413  InheritedPropertySheets: ""
414  CharacterSet: "0"
415  WholeProgramOptimization: "0"
416 # VCPreBuildEventTool:
417 # VCCustomBuildTool:
418 # VCXMLDataGeneratorTool:
419 # VCWebServiceProxyGeneratorTool:
420 # VCMIDLTool:
421  VCCLCompilerTool:
422  - Key: PreprocessorDefinitions
423  Value: "WIN32;NDEBUG;_WINDOWS;_USRDLL;__WIN32__;__NT__;__OSVERSION__=4;__x86__;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
424  - Key: RuntimeLibrary
425  Value: "2"
426  - Key: UsePrecompiledHeader
427  Value: "0"
428  - Key: WarningLevel
429  Value: "3"
430  - Key: Detect64BitPortabilityProblems
431  Value: "false"
432  - Key: DebugInformationFormat
433  Value: "3"
434 # VCManagedResourceCompilerTool:
435 # VCResourceCompilerTool:
436  VCPreLinkEventTool:
437  - Key: CommandLine
438  Value: |
439  lib -out:"$(TargetDir)RTC_static.lib" "$(TargetDir)*.obj" "$(SolutionDir)\\\\rtm\\\\idl\\\\$(ConfigurationName)\\\\*.obj"
440  set PATH=%PATH%;$(rtm_path)
441  cd "$(OutDir)"
442  start /wait cmd /c makedeffile.py RTC_static.lib RTC042 0.4.1 RTC042.def
443  move RTC042.def ..\\\\
444  VCLinkerTool:
445  - Key: AdditionalDependencies
446  Value: ""
447  - Key: OutputFile
448  Value: "$(OutDir)\\\\__PROJECT_NAME__.dll"
449  - Key: LinkIncremental
450  Value: "1"
451  - Key: ModuleDefinitionFile
452  Value: "$(TargetName).def"
453  - Key: GenerateDebugInformation
454  Value: "false"
455  - Key: SubSystem
456  Value: "2"
457  - Key: OptimizeReferences
458  Value: "2"
459  - Key: EnableCOMDATFolding
460  Value: "2"
461  - Key: TargetMachine
462  Value: "1"
463 # VCALinkTool:
464 # VCManifestTool:
465 # VCXDCMakeTool:
466 # VCBscMakeTool:
467 # VCFxCopTool:
468 # VCAppVerifierTool:
469 # VCWebDeploymentTool:
470  VCPostBuildEventTool:
471  - Key: CommandLine
472  Value: |
473  copy "$(OutDir)\\\\$(TargetName).lib" "$(SolutionDir)bin\\\\"
474  copy "$(OutDir)\\\\$(TargetName).dll" "$(SolutionDir)bin\\\\"
475 """
476 #------------------------------------------------------------
477 lib_yaml = """ProjectType: "Visual C++"
478 Version: "8.00"
479 Name: __PROJECT_NAME__
480 ProjectGUID: __GUID__
481 RootNamespace: __PROJECT_NAME__
482 Keyword: "Win32Proj"
483 Configurations:
484  - Name: "Debug|Win32"
485  OutputDirectory: "$(ProjectDir)$(ConfigurationName)"
486  IntermediateDirectory: "$(ConfigurationName)"
487  ConfigurationType: "4"
488 # InheritedPropertySheets: "..\\\\..\\\\OpenRTM-aist.vsprops"
489  CharacterSet: "0"
490  DeleteExtensionsOnClean: ""
491  PreBuildEventTool:
492  - Key: CommandLine
493  Value: |
494  set PATH=$(rtm_path);%PYTHON_ROOT%\\\\;%PATH%
495  for %%x in (*.idl) do makewrapper.py %%x
496  for %%x in (*.idl) do omniidl -bcxx -Wba -nf %%x
497 # VCCustomBuildTool:
498 # VCXMLDataGeneratorTool:
499 # VCWebServiceProxyGeneratorTool:
500 # VCMIDLTool:
501  VCCLCompilerTool:
502  - Key: Optimization
503  Value: "0"
504  - Key: PreprocessorDefinitions
505  Value: "WIN32;_DEBUG;_LIB;__WIN32__;__NT__;__OSVERSION__=4;__x86__;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
506  - Key: MinimalRebuild
507  Value: "true"
508  - Key: BasicRuntimeChecks
509  Value: "3"
510  - Key: RuntimeLibrary
511  Value: "3"
512  - Key: UsePrecompiledHeader
513  Value: "0"
514  - Key: WarningLevel
515  Value: "3"
516  - Key: Detect64BitPortabilityProblems
517  Value: "false"
518  - Key: DebugInformationFormat
519  Value: "4"
520 # VCManagedResourceCompilerTool:
521 # VCResourceCompilerTool:
522 # VCPreLinkEventTool:
523  VCLibrarianTool:
524  - Key: OutputFile
525  Value: "$(OutDir)\\\\__PROJECT_NAME__.lib"
526 # VCALinkTool:
527 # VCXDCMakeTool:
528 # VCBscMakeTool:
529 # VCFxCopTool:
530  VCPostBuildEventTool:
531  - Key: Description
532  Value: "make .def file"
533  - Key: CommandLine
534  Value: |
535  copy "$(OutDir)\\\\libRTCSkeld.lib" "$(SolutionDir)\\\\bin"
536  - Name: "Release|Win32"
537  OutputDirectory: "$(ProjectDir)$(ConfigurationName)"
538  IntermediateDirectory: "$(ConfigurationName)"
539  ConfigurationType: "4"
540 # InheritedPropertySheets: "..\\\\..\\\\OpenRTM-aist.vsprops"
541  CharacterSet: "0"
542  WholeProgramOptimization: "0"
543  VCPreBuildEventTool:
544  - Key: CommandLine
545  Value: |
546  set PATH=$(rtm_path);%PYTHON_ROOT%\\\\;%PATH%
547  for %%x in (*.idl) do makewrapper.py %%x
548  for %%x in (*.idl) do omniidl -bcxx -Wba -nf %%x
549 # VCCustomBuildTool:
550 # VCXMLDataGeneratorTool:
551 # VCWebServiceProxyGeneratorTool:
552 # VCMIDLTool:
553  VCCLCompilerTool:
554  - Key: PreprocessorDefinitions
555  Value: "WIN32;NDEBUG;_LIB;__WIN32__;__NT__;__OSVERSION__=4;__x86__;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
556  - Key: RuntimeLibrary
557  Value: "2"
558  - Key: UsePrecompiledHeader
559  Value: "0"
560  - Key: WarningLevel
561  Value: "3"
562  - Key: Detect64BitPortabilityProblems
563  Value: "false"
564  - Key: DebugInformationFormat
565  Value: "3"
566 # VCManagedResourceCompilerTool:
567 # VCResourceCompilerTool:
568 # VCPreLinkEventTool:
569  VCLibrarianTool:
570  - Key: OutputFile
571  Value: "$(OutDir)\\\\__PROJECT_NAME__.lib"
572 # VCALinkTool:
573 # VCXDCMakeTool:
574 # VCBscMakeTool:
575 # VCFxCopTool:
576  VCPostBuildEventTool:
577  - Key: CommandLine
578  Value: |
579  copy "$(OutDir)\\\\libRTCSkel.lib" "$(SolutionDir)\\\\bin"
580 """
581 
582 
583 rtcexe_yaml="""ProjectType: "Visual C++"
584 Version: "__VCVERSION__"
585 Name: __PROJECT_NAME__
586 ProjectGUID: __GUID__
587 RootNamespace: __PROJECT_NAME__
588 Keyword: "Win32Proj"
589 Configurations:
590 #------------------------------------------------------------
591 # Debug Configuration
592 #------------------------------------------------------------
593  - Name: "Debug|Win32"
594  OutputDirectory: "$(ProjectDir)__PROJECT_NAME__\\\\$(ConfigurationName)"
595  IntermediateDirectory: "__PROJECT_NAME__\\\\$(ConfigurationName)"
596  ConfigurationType: "1"
597  InheritedPropertySheets: "$(SolutionDir)rtm_config.vsprops;$(SolutionDir)user_config.vsprops"
598  CharacterSet: "0"
599  VCPreBuildEventTool:
600  - Key: CommandLine
601  Value: |
602  set PATH=$(rtm_path);%PYTHON_ROOT%\\\\;%PATH%
603  for %%x in (*.idl) do rtm-skelwrapper.py --include-dir="" --skel-suffix=Skel --stub-suffix=Stub --idl-file=%%x
604  for %%x in (*.idl) do $(rtm_idlc) $(rtm_idlflags) %%x
605  VCCLCompilerTool:
606  - Key: Optimization
607  Value: 0
608  - Key: PreprocessorDefinitions
609  Value: "USE_stub_in_nt_dll;WIN32;_DEBUG;_CONSOLE;__WIN32__;__x86__;_WIN32_WINNT=0x0500;__NT__;__OSVERSION__=4;_CRT_SECURE_NO_DEPRECATE"
610  - Key: MinimalRebuild
611  Value: "true"
612  - Key: BasicRuntimeChecks
613  Value: "3"
614  - Key: RuntimeLibrary
615  Value: "3"
616  - Key: UsePrecompiledHeader
617  Value: "0"
618  - Key: WarningLevel
619  Value: "3"
620  - Key: Detect64BitPortabilityProblems
621  Value: "true"
622  - Key: DebugInformationFormat
623  Value: "4"
624  VCLinkerTool:
625  - Key: AdditionalDependencies
626  Value: "$(rtm_libd)"
627  - Key: OutputFile
628  Value: "$(OutDir)\\\\__PROJECT_NAME__.exe"
629  - Key: LinkIncremental
630  Value: "2"
631  - Key: GenerateDebugInformation
632  Value: "true"
633  - Key: SubSystem
634  Value: "1"
635  - Key: TargetMachine
636  Value: "1"
637 #------------------------------------------------------------
638 # Release Configuration
639 #------------------------------------------------------------
640  - Name: "Release|Win32"
641  OutputDirectory: "$(ProjectDir)__PROJECT_NAME__\\\\$(ConfigurationName)"
642  IntermediateDirectory: "__PROJECT_NAME__\\\\$(ConfigurationName)"
643  ConfigurationType: "1"
644  InheritedPropertySheets: "$(SolutionDir)rtm_config.vsprops;$(SolutionDir)user_config.vsprops"
645  CharacterSet: "0"
646  WholeProgramOptimization: "0"
647  VCPreBuildEventTool:
648  - Key: CommandLine
649  Value: |
650  set PATH=$(rtm_path);%PYTHON_ROOT%\\\\;%PATH%
651  for %%x in (*.idl) do rtm-skelwrapper.py --include-dir="" --skel-suffix=Skel --stub-suffix=Stub --idl-file=%%x
652  for %%x in (*.idl) do $(rtm_idlc) $(rtm_idlflags) %%x
653  VCPostBuildEventTool:
654  - Key: CommandLine
655  Value: |
656  if NOT EXIST "$(SolutionDir)\\\\components" mkdir "$(SolutionDir)\\\\components"
657  copy "$(OutDir)\\\\__PROJECT_NAME__.exe" "$(SolutionDir)\\\\components"
658  VCCLCompilerTool:
659  - Key: PreprocessorDefinitions
660  Value: "USE_stub_in_nt_dll;WIN32;NDEBUG;_CONSOLE;__WIN32__;__x86__;_WIN32_WINNT=0x0500;__NT__;__OSVERSION__=4;_CRT_SECURE_NO_DEPRECATE"
661  - Key: RuntimeLibrary
662  Value: "2"
663  - Key: UsePrecompiledHeader
664  Value: "0"
665  - Key: WarningLevel
666  Value: "3"
667  - Key: Detect64BitPortabilityProblems
668  Value: "true"
669  - Key: DebugInformationFormat
670  Value: "3"
671  VCLinkerTool:
672  - Key: AdditionalDependencies
673  Value: "$(rtm_lib)"
674  - Key: OutputFile
675  Value: "$(OutDir)\\\\__PROJECT_NAME__.exe"
676  - Key: LinkIncremental
677  Value: "1"
678  - Key: GenerateDebugInformation
679  Value: "false"
680  - Key: SubSystem
681  Value: "1"
682  - Key: OptimizeReferences
683  Value: "2"
684  - Key: EnableCOMDATFolding
685  Value: "2"
686  - Key: LinkTimeCodeGeneration
687  Value: "0"
688  - Key: TargetMachine
689  Value: "1"
690 """
691 
692 rtcdll_yaml="""ProjectType: "Visual C++"
693 Version: "__VCVERSION__"
694 Name: __PROJECT_NAME__
695 ProjectGUID: __GUID__
696 RootNamespace: __PROJECT_NAME__
697 Keyword: "Win32Proj"
698 Configurations:
699 #------------------------------------------------------------
700 # Debug Configuration
701 #------------------------------------------------------------
702  - Name: "Debug|Win32"
703  OutputDirectory: "$(ProjectDir)__PROJECT_NAME__\\\\$(ConfigurationName)"
704  IntermediateDirectory: "__PROJECT_NAME__\\\\$(ConfigurationName)"
705  ConfigurationType: "2"
706  InheritedPropertySheets: "$(SolutionDir)rtm_config.vsprops;$(SolutionDir)user_config.vsprops"
707  CharacterSet: "0"
708  VCPreBuildEventTool:
709  - Key: CommandLine
710  Value: |
711  set PATH=$(rtm_path);%PYTHON_ROOT%\\\\;%PATH%
712  for %%x in (*.idl) do rtm-skelwrapper.py --include-dir="" --skel-suffix=Skel --stub-suffix=Stub --idl-file=%%x
713  for %%x in (*.idl) do $(rtm_idlc) $(rtm_idlflags) %%x
714  VCCLCompilerTool:
715  - Key: Optimization
716  Value: "0"
717  - Key: PreprocessorDefinitions
718  Value: "USE_stub_in_nt_dll;WIN32;_DEBUG;_WINDOWS;_USRDLL;__WIN32__;__NT__;__OSVERSION__=4;__x86__;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
719  - Key: MinimalRebuild
720  Value: "true"
721  - Key: BasicRuntimeChecks
722  Value: "3"
723  - Key: RuntimeLibrary
724  Value: "3"
725  - Key: UsePrecompiledHeader
726  Value: "0"
727  - Key: WarningLevel
728  Value: "3"
729  - Key: Detect64BitPortabilityProblems
730  Value: "true"
731  - Key: DebugInformationFormat
732  Value: "4"
733  VCLinkerTool:
734  - Key: AdditionalDependencies
735  Value: "$(rtm_libd)"
736 # - Key: OutputFile
737 # Value: "$(OutDir)\\\\__PROJECT_NAME__.dll"
738 # - Key: Version
739 # Value: __VERSION__
740  - Key: LinkIncremental
741  Value: "2"
742 # - Key: ModuleDefinitionFile
743 # Value: "$(TargetName).def"
744  - Key: GenerateDebugInformation
745  Value: "true"
746  - Key: SubSystem
747  Value: "2"
748  - Key: TargetMachine
749  Value: "1"
750 #------------------------------------------------------------
751 # Release Configuration
752 #------------------------------------------------------------
753  - Name: "Release|Win32"
754  OutputDirectory: "$(ProjectDir)__PROJECT_NAME__\\\\$(ConfigurationName)"
755  IntermediateDirectory: "__PROJECT_NAME__\\\\$(ConfigurationName)"
756  ConfigurationType: "2"
757  InheritedPropertySheets: "$(SolutionDir)rtm_config.vsprops;$(SolutionDir)user_config.vsprops"
758  CharacterSet: "0"
759  WholeProgramOptimization: "0"
760  VCPreBuildEventTool:
761  - Key: CommandLine
762  Value: |
763  set PATH=$(rtm_path);%PYTHON_ROOT%\\\\;%PATH%
764  for %%x in (*.idl) do rtm-skelwrapper.py --include-dir="" --skel-suffix=Skel --stub-suffix=Stub --idl-file=%%x
765  for %%x in (*.idl) do $(rtm_idlc) $(rtm_idlflags) %%x
766  VCPostBuildEventTool:
767  - Key: CommandLine
768  Value: |
769  if NOT EXIST "$(SolutionDir)\\\\components" mkdir "$(SolutionDir)\\\\components"
770  copy "$(OutDir)\\\\__PROJECT_NAME__.dll" "$(SolutionDir)\\\\components"
771  VCCLCompilerTool:
772  - Key: PreprocessorDefinitions
773  Value: "USE_stub_in_nt_dll;WIN32;NDEBUG;_WINDOWS;_USRDLL;__WIN32__;__NT__;__OSVERSION__=4;__x86__;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
774  - Key: RuntimeLibrary
775  Value: "2"
776  - Key: UsePrecompiledHeader
777  Value: "0"
778  - Key: WarningLevel
779  Value: "3"
780  - Key: Detect64BitPortabilityProblems
781  Value: "true"
782  - Key: DebugInformationFormat
783  Value: "3"
784  VCLinkerTool:
785  - Key: AdditionalDependencies
786  Value: "$(rtm_lib)"
787 # - Key: OutputFile
788 # Value: "$(OutDir)\\\\__PROJECT_NAME__.dll"
789  - Key: LinkIncremental
790  Value: "1"
791 # - Key: ModuleDefinitionFile
792 # Value: "$(TargetName).def"
793  - Key: GenerateDebugInformation
794  Value: "false"
795  - Key: SubSystem
796  Value: "2"
797  - Key: OptimizeReferences
798  Value: "2"
799  - Key: EnableCOMDATFolding
800  Value: "2"
801  - Key: TargetMachine
802  Value: "1"
803 """
804 
805 
806 
807 def usage():
808  print """Usage:
809  vcprojtool.py cmd options
810 commands:
811  vcproj: Generate vcproj
812  yaml : Generate example yaml file
813  flist : Generate file list as yaml
814 examples:
815  vcprojtool.py vcproj --type [exe|dll|nmake|lib]
816  --output out_fname
817  --yaml *.yaml
818  --source *.cpp
819  --header *.h
820  --resource *.txt
821  vcprojtool.py yaml --type [exe|dll|nmake|lib] --output
822  vcprojtool.py flist --out --source|--header|--resource *
823 """
824 
825 import sys
826 
827 #------------------------------------------------------------
828 # Exceptions
829 #------------------------------------------------------------
831  pass
832 
833 class InvalidOption(VCProjException):
834  def __init__(self, msg):
835  self.msg = "Error: InvalidOption:\n "
836  self.msg += msg
837 
839  def __init__(self, msg):
840  self.msg = "Error: InvalidCommand:\n "
841  self.msg += msg
842 
843 #------------------------------------------------------------
844 # VCProject generator class
845 #------------------------------------------------------------
846 class VCProject:
847  def __init__(self, type, yaml_text):
848  import yaml
849  self.type = type
850  self.dict = yaml.load(yaml_text)
851  self.escape_cmdline(self.dict)
852 
853  def generate(self):
854  import yat
856  return self.template.generate(self.dict).replace("\r\n", "\n").replace("\n", "\r\n")
857 
858  def tool_element(self, type):
859  text = ""
860  for tool in tools[type]:
861  t = tool_elem % (tool, tool, tool)
862  text += t
863  return text
864 
865  def get_template(self, type):
866  return vcproj_template % (conf_type[type], self.tool_element(type))
867 
868  def escape_cmdline(self, dict):
869  if not dict.has_key("Configurations"): return
870 
871  def escape_cmd(text):
872  text = text.replace("\"", "&quot;")
873  text = text.replace("\r\n", "\n")
874  text = text.replace("\n", "&#x0D;&#x0A;")
875  return text
876  from types import DictType, ListType
877  for conf in dict["Configurations"]:
878  for tool in conf.keys(): # Tool
879  if isinstance(conf[tool], ListType):
880  for keyval in conf[tool]:
881  if isinstance(keyval, DictType) \
882  and keyval.has_key("Key") \
883  and keyval.has_key("Value") \
884  and keyval["Key"] == "CommandLine":
885  keyval["Value"] = escape_cmd(keyval["Value"])
886 
887 #------------------------------------------------------------
888 # YAML configuration file generator
889 #------------------------------------------------------------
891  def __init__(self, type, vcversion, projectname, version, flist):
892  self.type = type
893  self.vcversion = vcversion
894  self.projectname = projectname
895  self.version = version
896  self.flist = flist
897 
898  self.yaml_template = {"EXE": exe_yaml, "DLL": dll_yaml, "LIB": lib_yaml,
899  "RTCEXE": rtcexe_yaml, "RTCDLL": rtcdll_yaml}
900 
901  def load_yamls(self, yfiles):
902  text = ""
903  for f in yfiles:
904  fd = open(f, "r")
905  text += fd.read()
906  fd.close()
907  return text
908 
909  def replace_uuid(self, text):
910  import uuid
911  token0 = text.split("__GUID__")
912  text0 = token0[0]
913  for i in range(1, len(token0)):
914  u = str(uuid.uuid1()).upper()
915  text0 += u + token0[i]
916 
917  token1 = text0.split("__UUID")
918  text1 = token1[0]
919  for i in range(1, len(token1)):
920  u = "_" + str(uuid.uuid1()).replace("-", "")
921  text1 += u + token1[i]
922  return text1
923 
924  def generate(self):
925  text = ""
926  loaded = ""
927  if self.flist.has_key("yaml") and len(self.flist["yaml"]) > 0:
928  loaded = self.load_yamls(self.flist["yaml"])
929 
930  if loaded.find("ProjectType:") < 0: # No toplevel config
931  if self.yaml_template.has_key(self.type):
932  text = self.yaml_template[self.type]
933  text += loaded
934  else:
935  print "type should be specified."
936  usage()
937  else:
938  text = loaded
939 
940  text += FileList(self.flist).generate()
941 
942  text = self.replace_uuid(text)
943  if self.projectname:
944  text = text.replace("__PROJECT_NAME__", self.projectname)
945  if self.version:
946  text = text.replace("__VERSION__", self.version)
947  if self.vcversion:
948  text = text.replace("__VCVERSION__", self.vcversion)
949  return text
950 
951 #------------------------------------------------------------
952 # File list yaml file generator
953 #------------------------------------------------------------
954 class FileList:
955  def __init__(self, flist):
956  self.flist = flist
957  self.filter = {"source":
958  {"Id": "Source",
959  "name": "Source Files",
960  "filter": "cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx",
961  },
962  "header":
963  {"Id": "Header",
964  "name": "Header Files",
965  "filter": "h;hpp;hxx;hm;inl;inc;xsd",
966  },
967  "resource":
968  {"Id": "Resoruce",
969  "name": "Resource Files",
970  "filter": "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav",
971  }
972  }
973  self.temp = """%s:
974  Name: %s
975  Filter: %s
976  GUID: __GUID__
977  Files:
978 """
979  return
980 
981  def generate(self):
982  text = ""
983  for f in ["source", "header", "resource"]:
984  if len(self.flist[f]) > 0:
985  text += self.temp % \
986  (self.filter[f]["Id"], self.filter[f]["name"],
987  self.filter[f]["filter"])
988  for file in self.flist[f]:
989  # vcproj's path delimiter should be "\"
990  file = file.replace("/","\\")
991  text += " - Path: " + file + "\n"
992  return text
993 
994 
995 
996 
997 
998 #def generate_vcproj(type, projectname, version, flist):
999 # yaml_text = ""
1000 # for f in flist["yaml"]:
1001 # fd = open(f, "r")
1002 # yaml_text += fd.read()
1003 # fd.close()
1004 # yaml_text += generate_flist(flist)
1005 # yaml_text = replace_uuid(yaml_text)
1006 # if projectname:
1007 # yaml_text = yaml_text.replace("__PROJECT_NAME__", projectname)
1008 # if version:
1009 # yaml_text = yaml_text.replace("__VERSION__", version)
1010 # vcproj = VCProject(type, yaml_text)
1011 # return vcproj.generate()
1012 #
1013 #
1014 #
1015 #
1016 #def generate_yaml(type, projectname, version, flist):
1017 # yaml_template = {"EXE": exe_yaml, "DLL": dll_yaml, "LIB": lib_yaml}
1018 # text = yaml_template[type]
1019 # text += generate_flist(flist)
1020 # if projectname:
1021 # text = text.replace("__PROJECT_NAME__", projectname)
1022 # if version:
1023 # text = text.replace("__VERSION__", version)
1024 # return text
1025 
1026 #------------------------------------------------------------
1027 # command option
1028 #------------------------------------------------------------
1029 def parse_args(argv):
1030  cmd = argv[0]
1031  if not (cmd == "vcproj" or cmd == "flist" or cmd == "yaml"):
1032  raise InvalidCommand("no such command: " + cmd)
1033 
1034  outfname = None
1035  type = None
1036  vcversion = None
1037  projectname = None
1038  version = None
1039  flist = {"yaml": [], "source": [], "header": [], "resource": []}
1040  i = 1
1041  argc = len(argv)
1042 
1043  while i < argc:
1044  opt = argv[i]
1045  if opt == "--projectname":
1046  i += 1
1047  if i < argc: projectname = argv[i]
1048  else: raise InvalidOption(opt + " needs value")
1049  elif opt == "--version":
1050  i += 1
1051  if i < argc: version = argv[i]
1052  else: raise InvalidOption(opt + " needs value")
1053  elif opt == "--vcversion":
1054  i += 1
1055  if i < argc: vcversion = argv[i]
1056  else: raise InvalidOption(opt + " needs value")
1057  elif opt == "--output" or opt == "--out" or opt == "-o":
1058  i += 1
1059  if i < argc: outfname = argv[i]
1060  else: raise InvalidOption(opt + " needs value")
1061  elif opt == "--type" or opt == "-t":
1062  i += 1
1063  if i < argc: type = argv[i]
1064  else: raise InvalidOption(opt + " needs value")
1065  type = type.upper()
1066  if not conf_type.has_key(type):
1067  raise InvalidOption("unknown type: "
1068  + type + "\n" +
1069  " --type should be [exe|dll|nmake|lib]")
1070  elif opt[:2] == "--" and flist.has_key(opt[2:]):
1071  lname = opt[2:]
1072  i += 1
1073  if not i < argc: raise InvalidOption(opt + " need value")
1074  while i < argc and argv[i][:2] != "--":
1075  flist[lname].append(argv[i])
1076  i += 1
1077  if len(flist[lname]) == 0:
1078  raise InvalidOption(opt + " needs value")
1079  i -= 1
1080  else:
1081  raise InvalidOption("unknown option: " + opt)
1082  i += 1
1083  return (cmd, vcversion, projectname, version, outfname, type, flist)
1084 
1085 #------------------------------------------------------------
1086 # main function
1087 #------------------------------------------------------------
1088 def main(argv):
1089  if len(argv) == 0:
1090  usage()
1091  sys.exit(-1)
1092 
1093  try:
1094  res = parse_args(argv)
1095  except VCProjException, e:
1096  print "\n" + e.msg + "\n"
1097  usage()
1098  sys.exit(-1)
1099 
1100  cmd = res[0]
1101  vcversion = res[1]
1102  projectname = res[2]
1103  version = res[3]
1104  outfile = res[4]
1105  type = res[5]
1106  flist = res[6]
1107 
1108  if cmd == "vcproj":
1109  t = VCProject(type,
1110  YamlConfig(type, vcversion,
1111  projectname, version, flist).generate()
1112  ).generate()
1113  elif cmd == "flist":
1114  t = FileList(flist).generate()
1115  elif cmd == "yaml":
1116  t = YamlConfig(type, vcversion, projectname, version, flist).generate()
1117 
1118  if outfile == None:
1119  fd = sys.stdout
1120  else:
1121  fd = open(outfile, "wb")
1122 
1123  fd.write(t)
1124 
1125 #------------------------------------------------------------
1126 # tests
1127 #------------------------------------------------------------
1129  print FileList({"source": ["hoge.cpp", "hage.cpp", "fuga.cpp"],
1130  "header": ["hoge.h", "hage.h", "fuga.h"],
1131  "resource": []}).generate()
1132 
1134  print YamlConfig("EXE", "8.00", "Test", "0.9.1",
1135  {"source":
1136  ["hoge.cpp",
1137  "hage.cpp",
1138  "fuga.cpp"],
1139  "header":
1140  ["hoge.h", "hage.h", "fuga.h"],
1141  "resource":
1142  []}).generate()
1143 
1145  print VCProject("EXE", YamlConfig("EXE", "8.00", "Test", "1.0.0",
1146  {"source":
1147  ["hoge.cpp",
1148  "hage.cpp",
1149  "fuga.cpp"],
1150  "header":
1151  ["hoge.h", "hage.h", "fuga.h"],
1152  "resource":
1153  [],
1154  "yaml":
1155  []}).generate()).generate()
1156 
1157 #------------------------------------------------------------
1158 # entry point
1159 #------------------------------------------------------------
1160 if __name__ == "__main__":
1161 # test_filelist()
1162 # test_yamlconfig()
1163 # test_vcproj()
1164  main(sys.argv[1:])
1165 
def usage()
Definition: vcprojtool.py:807
def parse_args(argv)
Definition: vcprojtool.py:1029
def test_filelist()
Definition: vcprojtool.py:1128
def uuid1(node=None, clock_seq=None)
def get_template(self, type)
Definition: vcprojtool.py:865
def test_yamlconfig()
Definition: vcprojtool.py:1133
def __init__(self, msg)
Definition: vcprojtool.py:834
def escape_cmdline(self, dict)
Definition: vcprojtool.py:868
def __init__(self, msg)
Definition: vcprojtool.py:839
def __init__(self, type, vcversion, projectname, version, flist)
Definition: vcprojtool.py:891
def test_vcproj()
Definition: vcprojtool.py:1144
def replace_uuid(self, text)
Definition: vcprojtool.py:909
def __init__(self, type, yaml_text)
Definition: vcprojtool.py:847
def load_yamls(self, yfiles)
Definition: vcprojtool.py:901
void append(SDOPackage::NVList &dest, const SDOPackage::NVList &src)
Append an element to NVList.
Definition: NVUtil.cpp:354
def tool_element(self, type)
Definition: vcprojtool.py:858
def __init__(self, flist)
Definition: vcprojtool.py:955
def main(argv)
Definition: vcprojtool.py:1088
def generate(self)
Definition: vcprojtool.py:981
def generate(idl_file, preproc_args, impl_suffix, skel_suffix="Skel", fd_h=None, fd_cpp=None)


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:45