1 // Copyright (c) Microsoft Corporation. All rights reserved.
 2 
 3 function OnFinish(selProj, selObj)
 4 {
 5   try
 6   {
 7     var strProjectPath = wizard.FindSymbol("PROJECT_PATH");
 8     var strProjectName = wizard.FindSymbol("PROJECT_NAME");
 9 
10     var bEmptyProject = wizard.FindSymbol("EMPTY_PROJECT");
11 
12     wizard.AddSymbol("RC_FILE_NAME",CreateSafeRCFileName(strProjectName) + ".rc");
13 
14     selProj = CreateProject(strProjectName, strProjectPath);
15     selProj.Object.Keyword = "Win32Proj";
16 
17     AddCommonConfig(selProj, strProjectName);
18     var strAppType = GetAppType();
19     AddSpecificConfig(selProj, strProjectName, bEmptyProject, strAppType);
20 
21     SetupFilters(selProj);
22 
23     if (!bEmptyProject)
24     {
25       SetResDlgFont();
26       
27       var Pch = wizard.FindSymbol("PRE_COMPILED_HEADER");
28 
29       if ((strAppType == "LIB" || ((strAppType == "CONSOLE") && 
30                     !wizard.FindSymbol("SUPPORT_MFC") && !wizard.FindSymbol("SUPPORT_ATL"))) && !Pch) 
31       {
32         AddFilesToProjectWithInfFile(selProj, strProjectName);
33         SetNoPchSettings(selProj);
34       }
35       else
36       {
37         AddFilesToProjectWithInfFile(selProj, strProjectName);
38         SetCommonPchSettings(selProj);  
39       }
40     }
41     selProj.Object.Save();
42   }
43   catch(e)
44   {
45     if (e.description.length != 0)
46       SetErrorInfo(e);
47     return e.number
48   }
49 }
50 
51 function SetFileProperties(projfile, strName)
52 {
53   if (strName == "dllmain.cpp") {
54     var Configs = projfile.Object.FileConfigurations;
55     for(var i=1;i<=Configs.Count;++i) {
56       var Config = Configs(i);
57       var CLTool = Config.Tool;
58       CLTool.CompileAsManaged = 0; // Force no /CLR
59       CLTool.UsePrecompiledHeader  = 0; // No pre-compiled headers      
60     }
61   }
62 }
63 
64 function GetTargetName(strName, strProjectName, strResPath, strHelpPath)
65 {
66   try
67   {
68     var strTarget = strName;
69 
70     if (strName == "readme.txt") {
71       strTarget = "ReadMe.txt";
72     } else if (strName == "resource.h") {
73       strTarget = "Resource.h";
74     } else if (strName == "small.ico") {
75       strTarget = "small.ico";
76     } else if (strName == "root.rc") {
77       strTarget = wizard.FindSymbol("RC_FILE_NAME");
78     } else if (strName.substr(0, 4) == "root") {
79       strTarget = strProjectName + strName.substr(4);
80     }
81     return strTarget; 
82   }
83   catch(e)
84   {
85     throw e;
86   }
87 }
88 
89 function GetAppType()
90 {
91   try
92   {
93     var strAppType = "";
94     if (wizard.FindSymbol("CONSOLE_APP"))
95       strAppType = "CONSOLE";
96     else
97     {
98       if (wizard.FindSymbol("WIN_APP"))
99         strAppType = "WIN";
100       else
101       {
102         if (wizard.FindSymbol("DLL_APP"))
103           strAppType = "DLL";
104         else
105         {
106           if (wizard.FindSymbol("LIB_APP"))
107             strAppType = "LIB";
108         }
109       }
110     }
111     return strAppType;
112   }
113   catch(e)
114   {
115     throw e;
116   }
117 }
118 
119 function AddSpecificConfig(proj, strProjectName, bEmptyProject, strAppType)
120 {
121   try
122   {
123     var bMFC = wizard.FindSymbol("SUPPORT_MFC");
124     var bATL = wizard.FindSymbol("SUPPORT_ATL");
125         
126     var config = proj.Object.Configurations("Debug");
127     config.CharacterSet = charSetUNICODE;
        config.CharacterSet = charSetNotSet;    // [***] changed from charSetUnicode
128 
129     if (strAppType == "LIB")
130       config.ConfigurationType = typeStaticLibrary;
131     else if (strAppType == "DLL")
132       config.ConfigurationType = typeDynamicLibrary;
133 
134     var CLTool = config.Tools("VCCLCompilerTool");
135   //  CLTool.PrecompiledHeaderFile = "$(OutDir)/" + strProjectName + ".pch";
136 
137     CLTool.RuntimeLibrary = rtMultiThreadedDebugDLL;
        CLTool.CompileAs = compileAsC;  // [***] added
138 
139     var strDefines = CLTool.PreprocessorDefinitions;
140     if (strDefines != "") strDefines += ";";
141     strDefines += GetPlatformDefine(config);
142     strDefines += "_DEBUG";
143 
144     switch(strAppType)
145     {
146       case "CONSOLE":
147         strDefines += ";_CONSOLE";
148         if (bMFC)
149           config.UseOfMFC = useMfcDynamic;
150         if (bATL)
151           config.UseOfATL = useATLStatic;
152         break;
153       case "LIB":
154         strDefines += ";_LIB";
155         if (bMFC)
156           config.UseOfMFC = useMfcDynamic;
157         break;
158       case "DLL":
159         strDefines += ";_WINDOWS;_USRDLL;";
160         var strExports = wizard.FindSymbol("UPPER_CASE_SAFE_PROJECT_IDENTIFIER_NAME") + "_EXPORTS";
161         strDefines += strExports;
162         if (bMFC)
163           config.UseOfMFC = useMfcDynamic;
164         if (bATL)
165           config.UseOfATL = useATLStatic;
166         break;
167       case "WIN":
168         strDefines += ";_WINDOWS";
169         if (bMFC)
170           config.UseOfMFC = useMfcDynamic;
171         if (bATL)
172           config.UseOfATL = useATLStatic;
173         break;
174       default:
175         break;
176     }
177 
        strDefines += ";_CRT_SECURE_NO_DEPRECATE";  // [***] added
178     CLTool.PreprocessorDefinitions = strDefines;
179     if (bEmptyProject)
180       CLTool.UsePrecompiledHeader = pchNone;
181 
182     CLTool.DebugInformationFormat = debugEditAndContinue;
183 
184     if (strAppType != "LIB")
185     {
186       var LinkTool = config.Tools("VCLinkerTool");
187       LinkTool.GenerateDebugInformation = true;
188       LinkTool.LinkIncremental = linkIncrementalYes;
189 
190       if (strAppType == "DLL" || strAppType == "WIN")
191         LinkTool.SubSystem = subSystemWindows;
192       else
193         LinkTool.SubSystem = subSystemConsole;
194     }
195 
196     config = proj.Object.Configurations.Item("Release");
197     config.CharacterSet = charSetUNICODE;
        config.CharacterSet = charSetNotSet;    // [***] changed from charSetUnicode
198 
199     if (strAppType == "LIB")
200       config.ConfigurationType = typeStaticLibrary;
201     else if (strAppType == "DLL")
202       config.ConfigurationType = typeDynamicLibrary;
203 
204     var CLTool = config.Tools("VCCLCompilerTool");
205 
206     CLTool.RuntimeLibrary = rtMultiThreadedDLL;
        CLTool.CompileAs = compileAsC;  // [***] added
207 
208     var strDefines = CLTool.PreprocessorDefinitions;
209     if (strDefines != "") strDefines += ";";
210     strDefines += GetPlatformDefine(config);
211     strDefines += "NDEBUG";
212     if (bEmptyProject)
213       CLTool.UsePrecompiledHeader = pchNone;
214 
215     CLTool.DebugInformationFormat = debugEnabled;
216 
217     switch(strAppType)
218     {
219       case "CONSOLE":
220         strDefines += ";_CONSOLE";
221         if (bMFC)
222           config.UseOfMFC = useMfcDynamic;
223         if (bATL)
224           config.UseOfATL = useATLStatic;
225         break;
226       case "LIB":
227         strDefines += ";_LIB";
228         if (bMFC)
229           config.UseOfMFC = useMfcDynamic;
230         break;
231       case "DLL":
232         strDefines += ";_WINDOWS;_USRDLL;";
233         var strExports = wizard.FindSymbol("UPPER_CASE_SAFE_PROJECT_IDENTIFIER_NAME") + "_EXPORTS";
234         strDefines += strExports;
235         break;
236       case "WIN":
237         strDefines += ";_WINDOWS";
238         if (bMFC)
239           config.UseOfMFC = useMfcDynamic;
240         if (bATL)
241           config.UseOfATL = useATLStatic;
242         break;
243       default:
244         break;
245     }
246 
        strDefines += ";_CRT_SECURE_NO_DEPRECATE";  // [***] added
247     CLTool.PreprocessorDefinitions = strDefines;
248 
249     if (strAppType != "LIB")
250     {
251       var LinkTool = config.Tools("VCLinkerTool");
252       LinkTool.GenerateDebugInformation = true;
253       LinkTool.LinkIncremental = linkIncrementalNo;
254 
255       if (strAppType == "DLL" || strAppType == "WIN")
256         LinkTool.SubSystem = subSystemWindows;
257       else
258         LinkTool.SubSystem = subSystemConsole;
259     }
260   }
261   catch(e)
262   {
263     throw e;
264   }
265 }