Yaml fix
[ACE_TAO.git] / TAO / bin / ADDIDL.DSM
blobb53ea3eb63655443bdcc6444e38e4514c0c5ac6f
2 '**********************************************************************
3 ' $Header$
4 ' $NoKeywords: $
6 ' @doc AddIDL 
8 ' Macros for Microsoft Visual Studio.
10 ' @comm To install this file go to Tools->Customize->Macro Files->Browse...
12 '**********************************************************************
16 '@bsub Add an IDL file into all build projects in the current workspace.
17 '@comm This routine also sets up the custom build options require for the TAO
18 'CORBA implementation. The use can select to create a new file or just add a reference
19 'to the project (e.g. if a file already exists).If a new file is created, then a
20 'basic outline for an OMG module or interface declaration is inserted. Note that the inline
21 'file extension is defined by INLINE_EXTENSION.
23 Sub AddIDLFile()
24 'DESCRIPTION: Add new IDL File with TAO custom build entries to all build projects in the workspace. 
26         On Error Resume Next
28         'Define the extension used for inline files here
29         INLINE_EXTENSION = "inl"
31         WkSpaceDir = Application.CurrentDirectory
32         ModuleName = InputBox("module (namespace or extensionless IDL filename):")
33         FileName = ModuleName
34         WkSpaceDir=InputBox("Directory for IDL file: ","Output Directory",WkSpaceDir)
35         
36         if WkSpaceDir="" then
37                 Exit Sub
38         end if
40         if Right(WkSpaceDir,1) <> "\" then
41                 WkSpaceDir=WkSpaceDir+"\"
42         end if
44         IDLFile = WkSpaceDir+FileName +".idl"
46         'Try to a file with this path/name
47         Documents.Open IDLFile
49         'If such a file already exists then it should now be the active doc
50         if ActiveDocument.Fullname = IDLFile then
52                 if msgbox("Overwrite the existing file ?",vbYesNo) = vbNo then 
53                         NewFile = 0
54                 else
55                         'Close the file before we modify it
56                         ActiveDocument.Close
57                         NewFile = 1
58                 end if
59         else
60                 NewFile =1
61         end if
63         'If NewFile is set to 1 then create the outline for a OMG IDL module
64         if NewFile = 1 then
65                 InterfaceName = InputBox("interface:")
67                 if msgbox("Include a module ("+ ModuleName+") declaration",vbYesNo) = vbYes then 
68                         Descr = vbLF + vbLF + "#if !defined (_" + UCase(ModuleName) + "_IDL)" + vbLF + _
69                         "#define _" + UCase(ModuleName) + "_IDL" + vbLF +vbLF + _
70                         "//"+vbLF+"//" +vbLF + "module " + ModuleName + " {" +vbLF + _
71                         "       //" + vbLF + _
72                         "       interface " + InterfaceName + "{"+vbLF + _
73                         "               //Definitions"+ vbLF + vbLF+ vbLF + _
74                         "               //Operations"+ vbLF + vbLF+ vbLF + _
75                         "               //Properties"+ vbLF+ vbLF + _
76                         "       };"+vbLF + "};"+vbLF +vbLF + _
77                         "#endif /* _"+ UCase(ModuleName) +"_IDL */"+vbLF
78                 else
79                         Descr = vbLF + vbLF + "#if !defined (_" + UCase(ModuleName) + "_IDL)" + vbLF + _
80                         "#define _" + UCase(ModuleName) + "_IDL" + vbLF +vbLF + _
81                         "       //" + vbLF + _
82                         "       //" + vbLF + _
83                         "       interface " + InterfaceName + "{"+vbLF + _
84                         "               //Definitions"+ vbLF + vbLF+ vbLF + _
85                         "               //Operations"+ vbLF + vbLF+ vbLF + _
86                         "               //Properties"+ vbLF+ vbLF + _
87                         "       };"+vbLF +vbLF + _
88                         "#endif /* _"+ UCase(ModuleName) +"_IDL */"+vbLF
89                 end if
91                 CreateCppFile IDLFile, Descr
92         end if
94                 Dim proj
95                 ' Add the files to each project
96                 'Note that the inline files do not need to be added
97                 for each proj in Projects
98                         if msgbox("Add "+ IDLFile +" and the IDL compiler output files to "+ proj +" ?",vbYesNo) = vbYes then
99                                 ProjectPath= Left(proj.FullName,InStrRev(proj.FullName,"\")-1)
101                                 proj.AddFile IDLFile
102                                 proj.AddFile WkSpaceDir+ModuleName + "C.cpp"
103                                 proj.AddFile WkSpaceDir+ModuleName + "C.h"
104                                 proj.AddFile WkSpaceDir+ModuleName + "S.cpp"
105                                 proj.AddFile WkSpaceDir+ModuleName + "S.h"
106                                 proj.AddFile WkSpaceDir+ModuleName + "S_T.cpp"
107                                 proj.AddFile WkSpaceDir+ModuleName + "S_T.h"
109                                 Dim cfg
110                                 ' Add the custom build for each configuration in each project
111                                 If proj.Type = "Build" Then
112                                         Commands="%ACE_ROOT%\bin\tao_idl.exe -ci C."+ INLINE_EXTENSION +" -si S.inl -st S_T."+ INLINE_EXTENSION +" " + IDLFile
113                                         Output =        "$(InputName)C.cpp"             + vbLF + _
114                                                                 "$(InputName)C.h"               + vbLF + _
115                                                                 "$(InputName)C."+ INLINE_EXTENSION +""          + vbLF + _
116                                                                 "$(InputName)S.cpp"             + vbLF + _
117                                                                 "$(InputName)S.h"               + vbLF + _
118                                                                 "$(InputName)S."+ INLINE_EXTENSION +""          + vbLF + _
119                                                                 "$(InputName)S_T.cpp"   + vbLF + _
120                                                                 "$(InputName)S_T.h"             + vbLF + _
121                                                                 "$(InputName)S_T."+ INLINE_EXTENSION +""
123                                         for each cfg in proj.Configurations
124                                                 cfg.AddCustomBuildStepToFile IDLFile, Commands, Output, "Running the TAO IDL Compiler on $(InputPath)..."
125                                         next
126                                 End If
127                         end if
128                 next
129 End Sub
135 '@bsub Creates a C/C++ file.
136 '@comm This routine will create a C or C++ source file f, with content c. 
137 'The new file will become the active doc.
139 Function CreateCppFile(byval f, byval c)
140 'DESCRIPTION: Creates a .cpp file. 
142         On Error Resume Next
143     Documents.Add "Text"
144     ActiveDocument.Language = "C/C++"
145     ActiveDocument.Selection = c
146     ActiveDocument.Selection.NewLine
147     ActiveDocument.Save f
149 End Function