AutoDetectResult CompilerOW::AutoDetectInstallationDir() { /* Following code is Not necessary as OpenWatcom does not write to Registry anymore */ /*wxRegKey key; // defaults to HKCR key.SetName(wxT("HKEY_LOCAL_MACHINE\\Software\\Open Watcom\\c_1.0")); if (key.Open()) // found; read it key.QueryValue(wxT("Install Location"), m_MasterPath);*/ if (m_MasterPath.IsEmpty()) // just a guess; the default installation dir m_MasterPath = wxT("C:\\watcom"); if (!m_MasterPath.IsEmpty()) { AddIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h")); AddIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h") + wxFILE_SEP_PATH + wxT("nt")); AddLibDir(m_MasterPath + wxFILE_SEP_PATH + wxT("lib386")); AddLibDir(m_MasterPath + wxFILE_SEP_PATH + wxT("lib386") + wxFILE_SEP_PATH + wxT("nt")); AddResourceIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h")); AddResourceIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h") + wxFILE_SEP_PATH + wxT("nt")); m_ExtraPaths.Add(m_MasterPath + wxFILE_SEP_PATH + wxT("binnt")); m_ExtraPaths.Add(m_MasterPath + wxFILE_SEP_PATH + wxT("binw")); } wxSetEnv(wxT("WATCOM"), m_MasterPath); return wxFileExists(m_MasterPath + wxFILE_SEP_PATH + wxT("binnt") + wxFILE_SEP_PATH + m_Programs.C) ? adrDetected : adrGuessed; }
AutoDetectResult CompilerMSVC::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); // Read the VCToolkitInstallDir environment variable wxGetEnv(_T("VCToolkitInstallDir"), &m_MasterPath); if (m_MasterPath.IsEmpty()) { // just a guess; the default installation dir wxString Programs = _T("C:\\Program Files"); // what's the "Program Files" location // TO DO : support 64 bit -> 32 bit apps are in "ProgramFiles(x86)" // 64 bit apps are in "ProgramFiles" wxGetEnv(_T("ProgramFiles"), &Programs); m_MasterPath = Programs + _T("\\Microsoft Visual C++ Toolkit 2003"); } if (!m_MasterPath.IsEmpty()) { AddIncludeDir(m_MasterPath + sep + _T("include")); AddLibDir(m_MasterPath + sep + _T("lib")); #ifdef __WXMSW__ // add include dirs for MS Platform SDK too wxRegKey key; // defaults to HKCR key.SetName(_T("HKEY_CURRENT_USER\\Software\\Microsoft\\Win32SDK\\Directories")); if (key.Exists() && key.Open(wxRegKey::Read)) { wxString dir; key.QueryValue(_T("Install Dir"), dir); if (!dir.IsEmpty()) { if (dir.GetChar(dir.Length() - 1) != '\\') dir += sep; AddIncludeDir(dir + _T("include")); AddLibDir(dir + _T("lib")); m_ExtraPaths.Add(dir + _T("bin")); } } // add extra paths for "Debugging tools" too key.SetName(_T("HKEY_CURRENT_USER\\Software\\Microsoft\\DebuggingTools")); if (key.Exists() && key.Open(wxRegKey::Read)) { wxString dir; key.QueryValue(_T("WinDbg"), dir); if (!dir.IsEmpty()) { if (dir.GetChar(dir.Length() - 1) == '\\') dir.Remove(dir.Length() - 1, 1); m_ExtraPaths.Add(dir); } } #endif // __WXMSW__ } return wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; }
AutoDetectResult CompilerGNUTRICORE::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); #ifdef __WXMSW__ m_MasterPath = _T("C:\\HighTec\\TriCore"); // just a guess // wxLogNull ln; wxRegKey key; // defaults to HKCR key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\HighTec EDV-Systeme\\TriCore\\")); if (key.Exists() && key.Open(wxRegKey::Read)) { // found; read it if (key.HasValue(_T("InstallPath"))) { key.QueryValue(_T("InstallPath"), m_MasterPath); } } #else m_MasterPath = _T("/usr/local/tricore"); #endif // __WXMSW__ AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrDetected) { AddIncludeDir(m_MasterPath + sep + _T("tricore") + sep + _T("include")); } return ret; }
AutoDetectResult CompilerGDC::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); if (platform::windows) { // look first if MinGW was installed with Code::Blocks (new in beta6) m_MasterPath = ConfigManager::GetExecutableFolder(); if (!wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C)) { // no... search for MinGW installation dir wxString windir = wxGetOSDirectory(); wxFileConfig ini(_T(""), _T(""), windir + _T("/MinGW.ini"), _T(""), wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_NO_ESCAPE_CHARACTERS); m_MasterPath = ini.Read(_T("/InstallSettings/InstallPath"), _T("C:\\MinGW")); if (!wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C)) { #ifdef __WXMSW__ // for wxRegKey // not found... // look for dev-cpp installation wxRegKey key; // defaults to HKCR key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Dev-C++")); if (key.Exists() && key.Open(wxRegKey::Read)) { // found; read it key.QueryValue(_T("Install_Dir"), m_MasterPath); } else { // installed by inno-setup // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Minimalist GNU for Windows 4.1_is1 wxString name; long index; key.SetName(_T("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall")); //key.SetName("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion"); bool ok = key.GetFirstKey(name, index); while (ok && !name.StartsWith(_T("Minimalist GNU for Windows"))) { ok = key.GetNextKey(name, index); } if (ok) { name = key.GetName() + _T("\\") + name; key.SetName(name); Manager::Get()->GetLogManager()->DebugLog(F(_T("name: %s"), name.wx_str())); if (key.Exists()) key.QueryValue(_T("InstallLocation"), m_MasterPath); } } #endif } } else m_Programs.MAKE = _T("make.exe"); // we distribute "make" not "mingw32-make" } else m_MasterPath = _T("/usr"); AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrDetected) { AddIncludeDir(m_MasterPath + sep + _T("include") + sep + _T("d")); AddLibDir(m_MasterPath + sep + _T("lib")); } return ret; }
int main(int argc, char** argv) { #ifndef RX_PREFIX #warning "No RX_PREFIX defined. Relying on RX_PREFIX @ runtime" char* RX_PREFIX = getenv("RX_PREFIX"); if(RX_PREFIX == NULL) { printf("Error: RX_PREFIX not defined, neither on compile nor on run time. Please export RX_PREFIX as the directory of the compiler executable!\n"); exit(EXIT_FAILURE); } #endif /** Check if STDLIB_R3X is given **/ char* StandardLibraryLocation = getenv("STDLIB_R3X"); if(StandardLibraryLocation!=NULL) { AddIncludeDir(StandardLibraryLocation); } ParseArguments(argc, argv); if(CompileDynamic == true) { DynamicSuffix = " -d"; } char* asmfile = ConcatenateStrings(OutputFile, ".asm"); char* ASMOutputFile = ConcatenateStrings(RX_PREFIX, ConcatenateStrings("/", asmfile)); char* TBCOutputFile = ConcatenateStrings(RX_PREFIX, "/_temp.bas"); char* GCCOptions = ConcatenateStrings("gcc -E -P -o ", ConcatenateStrings(TBCOutputFile, ConcatenateStrings(" - < ", InputFile))); char* CgenOptions = ConcatenateStrings(RX_PREFIX, ConcatenateStrings("/cgen", ConcatenateStrings(" -exe ", ConcatenateStrings("./", OutputFile)))); for(unsigned int i = 0; i < NumberOfIncludeDirs; i++) { if(IncludeDirs[i]!=NULL) { GCCOptions = ConcatenateStrings(GCCOptions, ConcatenateStrings(" -I", IncludeDirs[i])); } } char* TBCOptions = ConcatenateStrings(RX_PREFIX, ConcatenateStrings("/tbc > ", ConcatenateStrings(ASMOutputFile, ConcatenateStrings(" ", ConcatenateStrings(TBCOutputFile, DynamicSuffix))))); char* FASMOptions = ConcatenateStrings(RX_PREFIX, ConcatenateStrings("/fasm ", ConcatenateStrings(ASMOutputFile, ConcatenateStrings(" ./", OutputFile)))); /*printf("ASMOutputFile: %s\nTBCOutputFile: %s\nGCCOptions: %s\nTBCOptions: %s\nFASMOptions: %s\n", ASMOutputFile, TBCOutputFile, GCCOptions, TBCOptions, FASMOptions);*/ system(GCCOptions); system(TBCOptions); if(AsmFlag == false) { system(FASMOptions); system(CgenOptions); } else { FILE* fd = fopen(ASMOutputFile, "r+b"); fseek(fd, 0L, SEEK_END); unsigned int sz = ftell(fd); fseek(fd, 0L, SEEK_SET); char* space = calloc(sz+1, 1); fread(space, 1, sz, fd); space[sz] = 0; FILE* fp = fopen(OutputFile, "w+b"); fprintf(fp, "%s", space); fclose(fp); fclose(fd); } /**! Remove temp files **/ remove(ASMOutputFile); remove(TBCOutputFile); return 0; }
void ParseArguments(int argc, char* argv[]) { for(unsigned int i = 0; i < argc; i++) { if(!strcmp(argv[i], "-s")) { if(i >= argc) { fprintf(stderr, "Error: -s, source file expected\n"); exit(EXIT_FAILURE); } else { InputFile = argv[i+1]; } } else if (!strcmp(argv[i], "-o")) { if(i >= argc) { fprintf(stderr, "Error: -o, output file expected\n"); exit(EXIT_FAILURE); } else { OutputFile = argv[i+1]; } } else if(!strcmp(argv[i], "-h")) { printf("t++ - T++ frontend for R3X\n"); printf("Options:\n"); printf("-s: Source file\n"); printf("-o: Output file\n"); printf("-i: Specify include directories [Multiple Include Directories supported]"); printf("If no output file is given, a.exe is assumed\n"); } else if(!strcmp(argv[i], "-i")) { if(i >= argc) { fprintf(stderr, "Error: -i, header directory not specified\n"); exit(EXIT_FAILURE); } AddIncludeDir(argv[i+1]); } else if(!strcmp(argv[i], "-asm")) { AsmFlag = true; if(i >= argc) { fprintf(stderr, "Error: -asm, no output source given"); } AsmFile = argv[i+1]; } else if(!strcmp(argv[i], "-d")) { CompileDynamic = true; } } if (OutputFile == NULL) { OutputFile = strdup("a.exe"); } if (InputFile == NULL) { fprintf(stderr, "Error: Input file not specified. Pass -h for help\n"); exit(EXIT_FAILURE); } }
AutoDetectResult CompilerICC::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); wxString extraDir = _T(""); if (platform::windows) { if (wxDirExists(_T("C:\\Program Files\\Intel\\Compiler"))) { wxDir icc_dir(_T("C:\\Program Files\\Intel\\Compiler\\C++")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; m_MasterPath.Append(_T("\\IA32")); // Now check for the installation of MSVC const wxString msvcIds[4] = { _T("msvc6"), _T("msvctk"), _T("msvc8"), _T("msvc10") }; bool msvcFound = false; for (unsigned int which_msvc = 0; which_msvc < array_size(msvcIds); ++which_msvc) { Compiler* vcComp = CompilerFactory::GetCompiler(msvcIds[which_msvc]); if (vcComp) { if (vcComp->AutoDetectInstallationDir() == adrDetected) { const wxString& vcMasterPath = vcComp->GetMasterPath(); if (m_ExtraPaths.Index(vcMasterPath) == wxNOT_FOUND && wxDirExists(vcMasterPath)) { m_ExtraPaths.Add(vcMasterPath); } AddIncludeDir(vcMasterPath + _T("\\Include")); AddLibDir(vcMasterPath + _T("\\Lib")); AddResourceIncludeDir(vcMasterPath + _T("\\Include")); const wxArrayString& vcExtraPaths = vcComp->GetExtraPaths(); for (size_t i = 0; i < vcExtraPaths.GetCount(); ++i) { if (m_ExtraPaths.Index(vcExtraPaths[i]) == wxNOT_FOUND && wxDirExists(vcExtraPaths[i])) { m_ExtraPaths.Add(vcExtraPaths[i]); } } const wxArrayString& vcIncludeDirs = vcComp->GetIncludeDirs(); for (size_t i = 0; i < vcIncludeDirs.GetCount(); ++i) { if (wxDirExists(vcIncludeDirs[i])) { if (m_IncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) { AddIncludeDir(vcIncludeDirs[i]); } if (m_ResIncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) { AddResourceIncludeDir(vcIncludeDirs[i]); } } } const wxArrayString& vcLibDirs = vcComp->GetLibDirs(); for (size_t i = 0; i < vcLibDirs.GetCount(); ++i) { if (m_LibDirs.Index(vcLibDirs[i]) == wxNOT_FOUND && wxDirExists(vcLibDirs[i])) { AddLibDir(vcLibDirs[i]); } } msvcFound = true; break; } } } if (!msvcFound) { cbMessageBox(_T("It seems your computer doesn't have a working MSVC compiler.\n\n" "This compiler requires MS compiler for proper functioning and\n" "it may not work without it."), _T("Error"), wxOK | wxICON_ERROR); } } } } // Read the ICPP_COMPILER90 environment variable wxGetEnv(_T("ICPP_COMPILER90"), &m_MasterPath); extraDir = sep + _T("IA32");// Intel also provides compiler for Itanium processors if (m_MasterPath.IsEmpty()) { // just a guess the default installation dir wxString Programs = _T("C:\\Program Files"); // what's the "Program Files" location // TO DO : support 64 bit -> 32 bit apps are in "ProgramFiles(x86)" // 64 bit apps are in "ProgramFiles" wxGetEnv(_T("ProgramFiles"), &Programs); m_MasterPath = Programs + _T("\\Intel\\Compiler\\C++\\9.0"); } } else { m_MasterPath = _T("/opt/intel/cc/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_dir(_T("/opt/intel/cc")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; } } } } AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrDetected) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("Include"), 0); m_LibDirs.Insert(m_MasterPath + sep + _T("Lib"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("Include"), 0); } // Try to detect the debugger. If not detected successfully the debugger plugin will // complain, so only the autodetection of compiler is considered in return value wxString path; wxString dbg; if (platform::windows) { dbg = _T("idb.exe"); wxGetEnv(_T("IDB_PATH"), &path); path += _T("IDB\\9.0\\IA32"); } else { dbg = _T("idb"); path= _T("/opt/intel/idb/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_debug_dir(_T("/opt/intel/idb")); if (icc_debug_dir.IsOpened()) { wxArrayString debug_dirs; wxIccDirTraverser IccDebugDirTraverser(debug_dirs); icc_debug_dir.Traverse(IccDebugDirTraverser); if (!debug_dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path debug_dirs.Sort(true); path = debug_dirs[0]; } } } } if (wxFileExists(path + sep + _T("bin") + sep + dbg)) m_ExtraPaths.Add(path); return ret; }
AutoDetectResult CompilerICC::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); if (platform::windows) { if ( wxDirExists(_T("C:\\Program Files\\Intel\\Compiler")) ) { wxDir icc_dir(_T("C:\\Program Files\\Intel\\Compiler\\C++")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; m_MasterPath.Append(_T("\\IA32")); } } } int version = 0; while ( m_MasterPath.IsEmpty() || !wxDirExists(m_MasterPath) ) { wxString iccEnvVar; if (version==0) { // Try default w/o version number iccEnvVar = _T("ICPP_COMPILER"); version = 8; } else if (version>15) break; // exit while-loop else { // Try ICPP_COMPILER80 ... ICPP_COMPILER12 iccEnvVar.Printf(wxT("ICPP_COMPILER%d0"), version); version++; } // Read the ICPP_COMPILER[XX] environment variable if ( !wxGetEnv(iccEnvVar, &m_MasterPath) ) m_MasterPath.Clear(); } // Now check for the installation of MSVC const wxString msvcIds[4] = { _T("msvc6"), _T("msvctk"), _T("msvc8"), _T("msvc10") }; bool msvcFound = false; for (unsigned int which_msvc = 0; which_msvc < array_size(msvcIds); ++which_msvc) { Compiler* vcComp = CompilerFactory::GetCompiler(msvcIds[which_msvc]); if (!vcComp) continue; // compiler not registered? try next one wxString vcMasterNoMacros = vcComp->GetMasterPath(); Manager::Get()->GetMacrosManager()->ReplaceMacros(vcMasterNoMacros); if ( !wxFileExists(vcMasterNoMacros + sep + wxT("bin") + sep + vcComp->GetPrograms().C) && !wxFileExists(vcMasterNoMacros + sep + vcComp->GetPrograms().C) ) continue; // this MSVC is not installed; try next one const wxString& vcMasterPath = vcComp->GetMasterPath(); if (m_ExtraPaths.Index(vcMasterPath) == wxNOT_FOUND) m_ExtraPaths.Add(vcMasterPath); if ( !vcMasterPath.EndsWith(wxT("bin")) && m_ExtraPaths.Index(vcMasterPath + sep + wxT("bin")) == wxNOT_FOUND ) { m_ExtraPaths.Add(vcMasterPath + sep + wxT("bin")); } AddIncludeDir(vcMasterPath + _T("\\Include")); AddLibDir(vcMasterPath + _T("\\Lib")); AddResourceIncludeDir(vcMasterPath + _T("\\Include")); const wxArrayString& vcExtraPaths = vcComp->GetExtraPaths(); for (size_t i = 0; i < vcExtraPaths.GetCount(); ++i) { if ( m_ExtraPaths.Index(vcExtraPaths[i]) == wxNOT_FOUND && wxDirExists(vcExtraPaths[i]) ) { m_ExtraPaths.Add(vcExtraPaths[i]); } } const wxArrayString& vcIncludeDirs = vcComp->GetIncludeDirs(); for (size_t i = 0; i < vcIncludeDirs.GetCount(); ++i) { if (wxDirExists(vcIncludeDirs[i])) { if (m_IncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) AddIncludeDir(vcIncludeDirs[i]); if (m_ResIncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) AddResourceIncludeDir(vcIncludeDirs[i]); } } const wxArrayString& vcLibDirs = vcComp->GetLibDirs(); for (size_t i = 0; i < vcLibDirs.GetCount(); ++i) { if ( m_LibDirs.Index(vcLibDirs[i]) == wxNOT_FOUND && wxDirExists(vcLibDirs[i]) ) { AddLibDir(vcLibDirs[i]); } } msvcFound = true; break; } if ( m_MasterPath.IsEmpty() || !wxDirExists(m_MasterPath) ) { // Just a final guess for the default installation dir wxString Programs = _T("C:\\Program Files"); // what's the "Program Files" location // TO DO : support 64 bit -> 32 bit apps are in "ProgramFiles(x86)" // 64 bit apps are in "ProgramFiles" wxGetEnv(_T("ProgramFiles"), &Programs); m_MasterPath = Programs + _T("\\Intel\\Compiler\\C++\\9.0"); } else if (!msvcFound) { cbMessageBox(_T("It seems your computer doesn't have a MSVC compiler installed.\n\n" "The ICC compiler requires MSVC for proper functioning and\n" "it may not work without it."), _T("Error"), wxOK | wxICON_ERROR); } } else { m_MasterPath = _T("/opt/intel/cc/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_dir(_T("/opt/intel/cc")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; } } } } AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrGuessed) ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("ia32") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrGuessed) ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("intel64") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrDetected) { if ( wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("ia32") + sep + m_Programs.C) ) m_ExtraPaths.Add(m_MasterPath + sep + _T("bin") + sep + _T("ia32")); if ( wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("intel64") + sep + m_Programs.C) ) m_ExtraPaths.Add(m_MasterPath + sep + _T("bin") + sep + _T("intel64")); if ( wxDirExists(m_MasterPath + sep + _T("include")) ) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("include"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("include"), 0); } if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("include")) ) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("include"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("include"), 0); } if ( wxDirExists(m_MasterPath + sep + _T("lib")) ) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("lib"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("lib"), 0); } if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib")) ) m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib"), 0); if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("ia32")) ) m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("ia32"), 0); if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("intel64")) ) m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("intel64"), 0); } // Try to detect the debugger. If not detected successfully the debugger plugin will // complain, so only the autodetection of compiler is considered in return value wxString path; wxString dbg; if (platform::windows) { dbg = _T("idb.exe"); wxGetEnv(_T("IDB_PATH"), &path); if ( !path.IsEmpty() && wxDirExists(path) ) { int version = 9; while ( true ) { wxString idbPath = path + sep + _T("IDB") + sep + wxString::Format(_T("%d.0"), version) + sep + _T("IA32"); if ( wxDirExists(idbPath) ) { path = idbPath; // found break; // exit while-loop } else if (version>15) break; // exit while-loop else version++; } } } else { dbg = _T("idb"); path = _T("/opt/intel/idb/9.0"); if ( wxDirExists(_T("/opt/intel")) ) { wxDir icc_debug_dir(_T("/opt/intel/idb")); if (icc_debug_dir.IsOpened()) { wxArrayString debug_dirs; wxIccDirTraverser IccDebugDirTraverser(debug_dirs); icc_debug_dir.Traverse(IccDebugDirTraverser); if (!debug_dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path debug_dirs.Sort(true); path = debug_dirs[0]; } } } } if ( wxFileExists(path + sep + _T("bin") + sep + dbg) ) m_ExtraPaths.Add(path); return ret; }
AutoDetectResult CompilerLCC::AutoDetectInstallationDir() { wxString compiler; compiler << wxFILE_SEP_PATH << _T("bin") << wxFILE_SEP_PATH << m_Programs.C; #ifdef __WXMSW__ wxRegKey key; // defaults to HKCR wxString mpHKLM = wxEmptyString; wxString mpHKCU = wxEmptyString; wxString mpLccRoot = wxEmptyString; wxString mpLccLnk = wxEmptyString; wxString mpCompiler = wxEmptyString; // Query uninstall information if installed with admin rights: key.SetName(_T("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\lcc-win32 (base system)_is1")); if (key.Exists() && key.Open(wxRegKey::Read)) key.QueryValue(_T("Inno Setup: App Path"), mpHKLM); // Query uninstall information if installed *without* admin rights: key.SetName(_T("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\lcc-win32 (base system)_is1")); if (key.Exists() && key.Open(wxRegKey::Read)) key.QueryValue(_T("Inno Setup: App Path"), mpHKCU); // Check the LCC lccroot path key.SetName(_T("HKEY_CURRENT_USER\\Software\\lcc")); if (key.Exists() && key.Open(wxRegKey::Read)) key.QueryValue(_T("lccroot"), mpLccRoot); if (mpLccRoot.IsEmpty()) { // Check the LCC lccroot path key.SetName(_T("HKEY_CURRENT_USER\\Software\\lcc\\lccroot")); if (key.Exists() && key.Open(wxRegKey::Read)) key.QueryValue(_T("path"), mpLccRoot); } // Check the LCC lcclnk path key.SetName(_T("HKEY_CURRENT_USER\\Software\\lcc\\lcclnk")); if (key.Exists() && key.Open(wxRegKey::Read)) { key.QueryValue(_T("libpath"), mpLccLnk); wxString lib_path = _T("\\lib"); if ( !mpLccLnk.IsEmpty() && (mpLccLnk.Length()>lib_path.Length()) && (mpLccLnk.Lower().EndsWith(lib_path)) ) { // Remove the lib path to point to the LCC root folder mpLccLnk.Remove( (mpLccLnk.Length()-lib_path.Length()), lib_path.Length() ); } } // Check the LCC compiler path key.SetName(_T("HKEY_CURRENT_USER\\Software\\lcc\\compiler")); if (key.Exists() && key.Open(wxRegKey::Read)) { key.QueryValue(_T("includepath"), mpCompiler); wxString inc_path = _T("\\include"); if ( !mpCompiler.IsEmpty() && (mpCompiler.Length()>inc_path.Length()) && (mpCompiler.Lower().EndsWith(inc_path)) ) { // Remove the include path to point to the LCC root folder mpCompiler.Remove( (mpCompiler.Length()-inc_path.Length()), inc_path.Length() ); } } // Verify all path's obtained if (wxFileExists(mpHKLM + compiler)) m_MasterPath = mpHKLM; else if (wxFileExists(mpHKCU + compiler)) m_MasterPath = mpHKCU; else if (wxFileExists(mpLccRoot + compiler)) m_MasterPath = mpLccRoot; else if (wxFileExists(mpLccLnk + compiler)) m_MasterPath = mpLccLnk; else if (wxFileExists(mpCompiler + compiler)) m_MasterPath = mpCompiler; else #endif // __WXMSW__ m_MasterPath = _T("C:\\lcc"); // just a guess; the default installation dir if (!m_MasterPath.IsEmpty()) { AddIncludeDir (m_MasterPath + wxFILE_SEP_PATH + _T("include")); AddLibDir (m_MasterPath + wxFILE_SEP_PATH + _T("lib")); m_ExtraPaths.Add(m_MasterPath + wxFILE_SEP_PATH + _T("bin")); } m_RegistryUpdated = false; // Check the registry another time on IsValid() return wxFileExists(m_MasterPath+compiler) ? adrDetected : adrGuessed; }
AutoDetectResult CompilerIAR::AutoDetectInstallationDir() { if (platform::windows) { m_MasterPath.Clear(); #ifdef __WXMSW__ // for wxRegKey wxRegKey key; // defaults to HKCR key.SetName(wxT("HKEY_LOCAL_MACHINE\\Software\\IAR Systems\\Installed Products")); if (key.Exists() && key.Open(wxRegKey::Read)) { wxString subkeyname; long idx; if (key.GetFirstKey(subkeyname, idx)) { do { wxRegKey keys; keys.SetName(key.GetName() + wxFILE_SEP_PATH + subkeyname); if (!keys.Exists() || !keys.Open(wxRegKey::Read)) continue; keys.QueryValue(wxT("TargetDir"), m_MasterPath); if (!m_MasterPath.IsEmpty()) { if (wxFileExists(m_MasterPath + wxFILE_SEP_PATH + wxT("bin") + wxFILE_SEP_PATH + m_Programs.C)) break; m_MasterPath.Clear(); } } while (key.GetNextKey(subkeyname, idx)); } } #endif // __WXMSW__ wxString env_path = wxGetenv(_T("ProgramFiles(x86)")); if (m_MasterPath.IsEmpty()) { wxDir dir(env_path + wxT("\\IAR Systems")); if (wxDirExists(dir.GetName()) && dir.IsOpened()) { wxString filename; bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS); while (cont) { if ( filename.StartsWith(wxT("Embedded Workbench")) ) { wxFileName fn(dir.GetName() + wxFILE_SEP_PATH + filename + wxFILE_SEP_PATH + m_Arch + wxFILE_SEP_PATH + wxT("bin") + wxFILE_SEP_PATH + m_Programs.C); if ( wxFileName::IsFileExecutable(fn.GetFullPath()) && (m_MasterPath.IsEmpty() || fn.GetPath() > m_MasterPath) ) { m_MasterPath = dir.GetName() + wxFILE_SEP_PATH + filename + wxFILE_SEP_PATH + m_Arch; } } cont = dir.GetNext(&filename); } } } if (m_MasterPath.IsEmpty()) { // just a guess; the default installation dir m_MasterPath = env_path + wxT("\\IAR Systems\\Embedded Workbench\\" + m_Arch); } if ( wxDirExists(m_MasterPath) ) { AddIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("include")); AddLibDir(m_MasterPath + wxFILE_SEP_PATH + wxT("lib") + wxFILE_SEP_PATH + wxT("clib")); m_ExtraPaths.Add(m_MasterPath + wxFILE_SEP_PATH + wxT("bin")); } } else { m_MasterPath=_T("/usr/local"); // default } if (m_Arch == wxT("8051")) { AddLinkerOption(wxT("-f \"") + m_MasterPath + wxFILE_SEP_PATH + wxT("config") + wxFILE_SEP_PATH + wxT("devices") + wxFILE_SEP_PATH + wxT("_generic") + wxFILE_SEP_PATH + wxT("lnk51ew_plain.xcl\"")); } else // IAR { AddCompilerOption(wxT("--no_wrap_diagnostics")); } return wxFileExists(m_MasterPath + wxFILE_SEP_PATH + wxT("bin") + wxFILE_SEP_PATH + m_Programs.C) ? adrDetected : adrGuessed; }