4 //static Color unfocusedSelectorColor { 70, 96, 166 };
6 // how to detect express vs pro?
7 static const char * compilerSignatureEnvVars[CompilerType] = { "", "", "", "VS80COMNTOOLS", "VS90COMNTOOLS", "VS100COMNTOOLS" };
9 class CompilersDetectionDialog : Window
11 background = formColor;
12 minClientSize = { 320, 180 };
13 maxClientSize = { 640, 360 };
14 borderStyle = sizable;
17 showInTaskBar = false;
18 text = $"Compilers Detection";
20 CompilerType selectedCompilerType;
22 //property Array<NamedString> compilerEnvVars
23 property CompilerConfig compilerConfig
27 //Array<NamedString> result { };
28 CompilerConfig result = null;
29 if(selectedCompilerType)
31 char compilerPath[MAX_LOCATION];
32 compilerPath[0] = '\0';
33 GetEnvironment(compilerSignatureEnvVars[selectedCompilerType], compilerPath, sizeof(compilerPath));
34 if(compilerPath && compilerPath[0] && FileExists(compilerPath).isDirectory)
36 PathCat(compilerPath, "vsvars32.bat"); // is this file name constant and this file always present?
37 if(FileExists(compilerPath).isFile)
39 File f = FileOpen(compilerPath, read);
43 result = MakeDefaultCompiler(selectedCompilerType, false);
44 result.type = selectedCompilerType;
45 if(selectedCompilerType.isVC)
47 //result.cppCommand = "";
48 //result.ccCommand = "";
49 result.makeCommand = "vcbuild";
51 while(f.GetLine(line, 65536))
53 char * var = SearchString(line, 0, "@SET ", false, false);
58 equal = strstr(var, "=");
61 char * val = equal + 1;
62 Array<String> dirs = null;
64 TrimLSpaces(var, var);
65 TrimRSpaces(var, var);
66 if(!strcmpi(var, "VSINSTALLDIR") || !strcmpi(var, "VCINSTALLDIR") ||
67 !strcmpi(var, "FrameworkDir") || !strcmpi(var, "FrameworkVersion") || !strcmpi(var, "FrameworkSDKDir") ||
68 !strcmpi(var, "DevEnvDir") || !strcmpi(var, "LIBPATH"))
70 result.environmentVars.Add(NamedString { name = CopyString(var), string = CopyString(val) });
72 else if(!strcmpi(var, "PATH"))
73 dirs = result.executableDirs;
74 else if(!strcmpi(var, "LIB"))
75 dirs = result.libraryDirs;
76 else if(!strcmpi(var, "INCLUDE"))
77 dirs = result.includeDirs;
82 char * refId = new char[strlen(var)+3];
83 sprintf(refId, "%%%s%%", var);
84 numTokens = TokenizeWith(val, sizeof(tokens) / sizeof(byte *), tokens, ";", false);
85 for(c = 0; c < numTokens; c++)
87 if(strcmpi(tokens[c], refId))
88 dirs.Add(CopyString(tokens[c]));
93 else if(!strcmp(line, "@goto end"))
105 Label labelCompilersList { this, position = { 8, 8 }, labeledWindow = compilersList };
106 ListBox compilersList
108 this, borderStyle = deep, hasVertScroll = true, hasHorzScroll = true;
109 // multiSelect = true, selectionColor = unfocusedSelectorColor;
110 fullRowSelect = true;
111 alwaysHighLight = true;
114 anchor = Anchor { left = 8, top = 24, right = 8, bottom = 36 };
117 bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
121 selectedCompilerType = (CompilerType)row.tag;
122 ok.disabled = !selectedCompilerType;
130 this, isDefault = true, disabled = true, text = $"OK";
131 size = { 60 }, anchor = { right = 76, bottom = 8 };
132 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
142 this, hotKey = escape, text = $"Cancel";
143 size = { 60 }, anchor = { right = 8, bottom = 8 };
144 NotifyClicked = ButtonCloseDialog;
149 CompilerType compilerType;
150 char compilerPath[MAX_LOCATION];
151 for(compilerType = firstCompilerType; compilerType <= lastCompilerType; compilerType++)
153 const char * varName = compilerSignatureEnvVars[compilerType];
154 if(varName && *varName)
156 compilerPath[0] = '\0';
157 GetEnvironment(varName, compilerPath, sizeof(compilerPath));
158 if(compilerPath && compilerPath[0] && FileExists(compilerPath).isDirectory)
160 PathCat(compilerPath, "vsvars32.bat"); // is this file name constant and this file always present?
161 if(FileExists(compilerPath).isFile)
163 DataRow row = compilersList.AddString(compilerType.longName);
164 row.tag = (int64)compilerType;
165 // maybe try to read this line in vsvars32.bat instead of hard coded compiler names or not
166 // @echo Setting environment for using Microsoft Visual Studio 2005 x86 tools.
171 if(compilersList.rowCount)
172 compilersList.SelectRow(compilersList.firstRow);