<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><span>Hi !</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 15.555556297302246px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span><br></span></div><div style="background-color: transparent;"><span>Joćo Matos <ripzonetriton@gmail.com> has made some patch to autoprobe for Visual studio system include and library pathes -<br></span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;"><span>commit - </span></div><div style="background-color:
transparent;"><span>http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120903/063802.html<br></span></div><div style="background-color: transparent;"><span>http://llvm.org/viewvc/llvm-project?view=rev&revision=163076<br></span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;"><span><br></span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;"><span>But I guess this commit was reverted - since I cannot find this function in rev 163370.</span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;"><span><br></span></div><div style="background-color:
transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;">What do you think if I'll bring it back into clang once again.</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;"><br></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;">There is several issues - one - developer should be able to specify manually which VS environment he wants to use</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;">(vs2008, vs2010, vs2012...) - VS environment can be autoprobed, but it's only for hello world
style apps.</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;">Now I have prototyped by using special env variable VSENV = 8/9/10 - 2005 - 8, 2008 - 9, 2010 - 10.</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;"><br></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;">Attaching console code snipet:</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;"><br></div><div style="background-color: transparent;"><div style="background-color:
transparent;">#include "stdafx.h"</div><div style="background-color: transparent;">#ifndef _WIN32</div><div style="background-color: transparent;">#error "failed"</div><div style="background-color: transparent;">#endif</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">#ifdef _WIN32</div><div style="background-color: transparent;">#include <string></div><div style="background-color: transparent;">#include <vector></div><div style="background-color: transparent;">#include <stdio.h></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">static std::string exec(const char* cmd)</div><div style="background-color: transparent;">{</div><div style="background-color: transparent;"> FILE* pipe = _popen(cmd, "r");</div><div style="background-color: transparent;"> if
(!pipe) return "ERROR";</div><div style="background-color: transparent;"> char buffer[1024];</div><div style="background-color: transparent;"> std::string result = "";</div><div style="background-color: transparent;"> while(!feof(pipe)) {</div><div style="background-color: transparent;"> <span class="Apple-tab-span" style="white-space:pre"> </span>if(fgets(buffer, sizeof(buffer), pipe) != NULL)</div><div style="background-color: transparent;"> <span class="Apple-tab-span" style="white-space:pre"> </span>result += buffer;</div><div style="background-color: transparent;"> }</div><div style="background-color: transparent;"> _pclose(pipe);</div><div style="background-color: transparent;"> return result;</div><div style="background-color: transparent;">}</div><div style="background-color: transparent;"><br></div><div style="background-color:
transparent;">#pragma comment(lib, "shlwapi.lib") //_popen, _pclose</div><div style="background-color: transparent;">#include <shlwapi.h></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">//</div><div style="background-color: transparent;">// Returns true if got settings, false if not.</div><div style="background-color: transparent;">//</div><div style="background-color: transparent;">bool GetVisualStudioEnv(</div><div style="background-color: transparent;"> const char* envVar, // [in] "INCLUDE" / "LIBPATH"</div><div style="background-color: transparent;"> std::vector<std::string>& vecPathes,</div><div style="background-color: transparent;"> int iProbeFrom = 0, int iProbeTo = 0 // 2005 - 8, 2008 - 9, 2010 -
10</div><div style="background-color: transparent;">)</div><div style="background-color: transparent;">{</div><div style="background-color: transparent;"> std::string s;</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> if( iProbeFrom == 0 && iProbeTo == 0 )</div><div style="background-color: transparent;"> {</div><div style="background-color: transparent;"> // Environment variable specifies which VS to use.</div><div style="background-color: transparent;"> if( getenv("VSENV") != NULL )</div><div style="background-color: transparent;"> {</div><div style="background-color: transparent;"> int iVer = atoi( getenv("VSENV") );</div><div style="background-color: transparent;">
</div><div style="background-color: transparent;"> if( iVer == 0 )</div><div style="background-color: transparent;"> return false;</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> return GetVisualStudioEnv(envVar, vecPathes, iVer, iVer );</div><div style="background-color: transparent;"> }</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> iProbe>From = 20;</div><div style="background-color: transparent;"> iProbeTo = 8;</div><div style="background-color: transparent;"> } //if</div><div style="background-color: transparent;">
</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;"> for( int iProbeVer = iProbeFrom; iProbeVer >= iProbeTo; iProbeVer-- )</div><div style="background-color: transparent;"> {</div><div style="background-color: transparent;"> char envvar[64];</div><div style="background-color: transparent;"> sprintf(envvar, "VS%d0COMNTOOLS", iProbeVer);</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> // Not defined</div><div style="background-color: transparent;"> if( getenv(envvar) == NULL ) </div><div style="background-color: transparent;"> continue;</div><div style="background-color: transparent;"><br></div><div style="background-color:
transparent;"> std::string cmd = getenv(envvar);</div><div style="background-color: transparent;"> cmd += "\\..\\..\\vc\\vcvarsall.bat";</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> if( !PathFileExistsA( cmd.c_str() ) )</div><div style="background-color: transparent;"> continue;</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> //printf("Located: %s", envvar);</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> cmd = "cmd /C \"" + cmd + "\" ^>nul ^& set";</div><div style="background-color: transparent;">
s = exec(cmd.c_str());</div><div style="background-color: transparent;"> break;</div><div style="background-color: transparent;"> }</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> if( s.length() == 0 ) </div><div style="background-color: transparent;"> return false;</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;"> char* envline;</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> vecPathes.clear();</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;"> for (envline = strtok( &s[0], "\n" ); envline; envline = strtok( NULL, "\n" ))</div><div
style="background-color: transparent;"> {</div><div style="background-color: transparent;"> char* varend = strchr( envline, '=');</div><div style="background-color: transparent;"> if( !varend )</div><div style="background-color: transparent;"> continue;</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> *varend = 0;</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> if( strcmp(envline,envVar) == 0 )</div><div style="background-color: transparent;"> {</div><div style="background-color: transparent;"> char* val;</div><div style="background-color: transparent;">
for (val = strtok( varend + 1, ";" ); val; val = strtok( NULL, ";" ))</div><div style="background-color: transparent;"> {</div><div style="background-color: transparent;"> vecPathes.push_back(val);</div><div style="background-color: transparent;"> }</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> return true;</div><div style="background-color: transparent;"> }</div><div style="background-color: transparent;"> *varend = '=';</div><div style="background-color: transparent;"> } //for</div><div style="background-color: transparent;"><br></div><div style="background-color:
transparent;"> return false;</div><div style="background-color: transparent;">} //GetVisualStudioEnv</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">#endif //_WIN32</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">int _tmain(int argc, _TCHAR* argv[])</div><div style="background-color: transparent;">{</div><div style="background-color: transparent;"> std::vector<std::string> vecPathes;</div><div style="background-color: transparent;"> </div><div style="background-color: transparent;"> if(GetVisualStudioEnv("INCLUDE",vecPathes) )</div><div style="background-color: transparent;"> {</div><div style="background-color: transparent;"> for(
unsigned int i = 0; i < vecPathes.size(); i++ )</div><div style="background-color: transparent;"> {</div><div style="background-color: transparent;"> printf("'%s'\n", vecPathes[i].c_str());</div><div style="background-color: transparent;"> }</div><div style="background-color: transparent;"> }</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;"> //printf("env: '%s'\n",exec("set INCLUDE").c_str());</div><div style="background-color: transparent;"><span class="Apple-tab-span" style="white-space:pre"> </span>return 0;</div><div style="background-color: transparent;">}</div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 15.555556297302246px; font-style: normal; background-color: transparent;"><br></div><div style="color:
rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 15.555556297302246px; font-style: normal; background-color: transparent;"><br></div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 15.555556297302246px; font-style: normal; background-color: transparent;">So this is my initial proposal for API / include / folder pathes obtaining.</div></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> </div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;">--<br> Have a nice day!<br> Tarmo.</div></div></body></html>