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