46 #include "compiledata.h"
47 #include "RConfigure.h"
59 const char *gProgName;
60 const char *gProgPath;
63 TFileHandler *gXDisplay = 0;
65 static Int_t *gLibraryVersion = 0;
66 static Int_t gLibraryVersionIdx = 0;
67 static Int_t gLibraryVersionMax = 256;
70 ProcInfo_t::~ProcInfo_t() {}
71 ClassImp(TProcessEventTimer);
76 TProcessEventTimer::TProcessEventTimer(Long_t delay) : TTimer(delay, kFALSE)
78 gROOT->SetInterrupt(kFALSE);
87 Bool_t TProcessEventTimer::ProcessEvents()
90 if (gSystem->ProcessEvents()) {
105 TVirtualMutex* gSystemMutex = 0;
110 TSystem::TSystem(
const char *name,
const char *title) : TNamed(name, title), fAclicProperties(0)
112 if (gSystem && name[0] !=
'-' && strcmp(name,
"Generic"))
113 Error(
"TSystem",
"only one instance of TSystem allowed");
118 fStdExceptionHandler = 0;
122 fInsideNotify = kFALSE;
131 fAclicMode = kDefault;
139 if (!gLibraryVersion) {
140 gLibraryVersion =
new Int_t [gLibraryVersionMax];
141 memset(gLibraryVersion, 0, gLibraryVersionMax*
sizeof(Int_t));
151 fOnExitList->Delete();
152 SafeDelete(fOnExitList);
155 if (fSignalHandler) {
156 fSignalHandler->Delete();
157 SafeDelete(fSignalHandler);
161 fFileHandler->Delete();
162 SafeDelete(fFileHandler);
165 if (fStdExceptionHandler) {
166 fStdExceptionHandler->Delete();
167 SafeDelete(fStdExceptionHandler);
177 SafeDelete(fCompiled);
182 SafeDelete(fHelpers);
192 Bool_t TSystem::Init()
201 fSignalHandler =
new TOrdCollection;
202 fFileHandler =
new TOrdCollection;
203 fStdExceptionHandler =
new TOrdCollection;
204 fTimers =
new TOrdCollection;
206 fBuildArch = BUILD_ARCH;
207 fBuildCompiler = COMPILER;
208 fBuildCompilerVersion = COMPILERVERS;
209 fBuildNode = BUILD_NODE;
210 fFlagsDebug = CXXDEBUG;
212 fIncludePath = INCLUDEPATH;
213 fLinkedLibs = LINKEDLIBS;
216 fAclicMode = kDefault;
217 fMakeSharedLib = MAKESHAREDLIB;
219 fCompiled =
new TOrdCollection;
221 if (gEnv && fBeepDuration == 0 && fBeepFreq == 0) {
222 fBeepDuration = gEnv->GetValue(
"Root.System.BeepDuration", 100);
223 fBeepFreq = gEnv->GetValue(
"Root.System.BeepFreq", 440);
225 if (!fName.CompareTo(
"Generic"))
return kTRUE;
233 void TSystem::SetProgname(
const char *name)
235 gProgName = StrDup(name);
241 void TSystem::SetDisplay()
251 void TSystem::SetErrorStr(
const char *errstr)
254 GetLastErrorString() = errstr;
260 const char *TSystem::GetError()
262 if (GetErrno() == 0 && !GetLastErrorString().IsNull())
263 return GetLastErrorString().Data();
264 return Form(
"errno: %d", GetErrno());
270 Int_t TSystem::GetErrno()
275 #ifdef R__SOLARIS_CC50
286 void TSystem::ResetErrno()
291 #ifdef R__SOLARIS_CC50
302 void TSystem::RemoveOnExit(TObject *obj)
304 if (fOnExitList == 0)
305 fOnExitList =
new TOrdCollection;
306 if (fOnExitList->FindObject(obj) == 0)
307 fOnExitList->Add(obj);
313 const char *TSystem::HostName()
321 void TSystem::NotifyApplicationCreated()
334 void TSystem::Beep(Int_t freq , Int_t duration ,
339 fBeepDuration = duration;
342 if (fBeepDuration < 0 || fBeepFreq < 0)
return;
343 if (freq < 0) freq = fBeepFreq;
344 if (duration < 0) duration = fBeepDuration;
345 DoBeep(freq, duration);
362 gApplication->StartIdleing();
364 gApplication->StopIdleing();
368 catch (std::exception& exc) {
369 TIter next(fStdExceptionHandler);
370 TStdExceptionHandler* eh = 0;
371 while ((eh = (TStdExceptionHandler*) next())) {
372 switch (eh->Handle(exc))
374 case TStdExceptionHandler::kSEProceed:
376 case TStdExceptionHandler::kSEHandled:
379 case TStdExceptionHandler::kSEAbort:
380 Warning(
"Run",
"instructed to abort");
387 catch (
const char *str) {
392 Warning(
"Run",
"handle uncaugth exception, terminating");
402 void TSystem::ExitLoop()
410 void TSystem::InnerLoop()
426 Bool_t TSystem::ProcessEvents()
428 gROOT->SetInterrupt(kFALSE);
430 if (!gROOT->TestBit(TObject::kInvalidObject))
431 DispatchOneEvent(kTRUE);
433 return gROOT->IsInterrupted();
439 void TSystem::DispatchOneEvent(Bool_t)
441 AbstractMethod(
"DispatchOneEvent");
447 void TSystem::Sleep(UInt_t)
449 AbstractMethod(
"Sleep");
455 Int_t TSystem::Select(TList *, Long_t)
457 AbstractMethod(
"Select");
463 Int_t TSystem::Select(TFileHandler *, Long_t)
465 AbstractMethod(
"Select");
481 void TSystem::AddTimer(TTimer *ti)
483 if (ti && fTimers && (fTimers->FindObject(ti) == 0))
491 TTimer *TSystem::RemoveTimer(TTimer *ti)
494 TTimer *tr = (TTimer*) fTimers->Remove(ti);
504 Long_t TSystem::NextTimeOut(Bool_t mode)
506 if (!fTimers)
return -1;
508 TOrdCollectionIter it((TOrdCollection*)fTimers);
510 Long64_t tt, tnow = Now();
513 while ((t = (TTimer *) it.Next())) {
514 if (t->IsSync() == mode) {
515 tt = (Long64_t)t->GetAbsTime() - tnow;
518 timeout = (Long_t)tt;
522 timeout = (Long_t)tt;
528 if (to && to->IsAsync() && timeout > 0) {
529 if (to->IsInterruptingSyscalls())
530 SigAlarmInterruptsSyscalls(kTRUE);
532 SigAlarmInterruptsSyscalls(kFALSE);
542 void TSystem::AddSignalHandler(TSignalHandler *h)
544 if (h && fSignalHandler && (fSignalHandler->FindObject(h) == 0))
545 fSignalHandler->Add(h);
552 TSignalHandler *TSystem::RemoveSignalHandler(TSignalHandler *h)
555 return (TSignalHandler *)fSignalHandler->Remove(h);
564 void TSystem::AddFileHandler(TFileHandler *h)
566 if (h && fFileHandler && (fFileHandler->FindObject(h) == 0))
567 fFileHandler->Add(h);
574 TFileHandler *TSystem::RemoveFileHandler(TFileHandler *h)
577 return (TFileHandler *)fFileHandler->Remove(h);
586 void TSystem::ResetSignal(ESignals , Bool_t )
588 AbstractMethod(
"ResetSignal");
594 void TSystem::ResetSignals()
596 AbstractMethod(
"ResetSignals");
603 void TSystem::IgnoreSignal(ESignals , Bool_t )
605 AbstractMethod(
"IgnoreSignal");
612 void TSystem::IgnoreInterrupt(Bool_t ignore)
614 IgnoreSignal(kSigInterrupt, ignore);
621 void TSystem::AddStdExceptionHandler(TStdExceptionHandler *eh)
623 if (eh && fStdExceptionHandler && (fStdExceptionHandler->FindObject(eh) == 0))
624 fStdExceptionHandler->Add(eh);
631 TStdExceptionHandler *TSystem::RemoveStdExceptionHandler(TStdExceptionHandler *eh)
633 if (fStdExceptionHandler)
634 return (TStdExceptionHandler *)fStdExceptionHandler->Remove(eh);
642 Int_t TSystem::GetFPEMask()
644 AbstractMethod(
"GetFPEMask");
652 Int_t TSystem::SetFPEMask(Int_t)
654 AbstractMethod(
"SetFPEMask");
663 int TSystem::Exec(
const char*)
665 AbstractMethod(
"Exec");
672 FILE *TSystem::OpenPipe(
const char*,
const char*)
674 AbstractMethod(
"OpenPipe");
681 int TSystem::ClosePipe(FILE*)
683 AbstractMethod(
"ClosePipe");
690 TString TSystem::GetFromPipe(
const char *command)
694 FILE *pipe = OpenPipe(command,
"r");
696 SysError(
"GetFromPipe",
"cannot run command \"%s\"", command);
701 while (line.Gets(pipe)) {
707 Int_t r = ClosePipe(pipe);
709 Error(
"GetFromPipe",
"command \"%s\" returned %d", command, r);
717 int TSystem::GetPid()
719 AbstractMethod(
"GetPid");
726 void TSystem::Exit(
int, Bool_t)
728 AbstractMethod(
"Exit");
734 void TSystem::Abort(
int)
736 AbstractMethod(
"Abort");
742 void TSystem::StackTrace()
744 AbstractMethod(
"StackTrace");
754 TSystem *TSystem::FindHelper(
const char *path,
void *dirptr)
756 TSystem *helper =
nullptr;
758 R__READ_LOCKGUARD(ROOT::gCoreMutex);
761 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
762 fHelpers =
new TOrdCollection;
767 TUrl url(path, kTRUE);
768 if (!strcmp(url.GetProtocol(),
"file"))
774 TIter next(fHelpers);
775 while ((helper = (TSystem*) next()))
776 if (helper->ConsistentWith(path, dirptr))
784 TRegexp re(
"^root.*:");
785 TString pname = path;
787 if (pname.BeginsWith(
"xroot:") || pname.Index(re) != kNPOS) {
789 if ((h = gROOT->GetPluginManager()->FindHandler(
"TSystem", path))) {
790 if (h->LoadPlugin() == -1)
792 helper = (TSystem*) h->ExecPlugin(2, path, kFALSE);
794 }
else if ((h = gROOT->GetPluginManager()->FindHandler(
"TSystem", path))) {
795 if (h->LoadPlugin() == -1)
797 helper = (TSystem*) h->ExecPlugin(0);
801 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
802 fHelpers->Add(helper);
812 Bool_t TSystem::ConsistentWith(
const char *path,
void *dirptr)
814 Bool_t checkproto = kFALSE;
817 TUrl url(path, kTRUE);
818 if (!strncmp(url.GetProtocol(), GetName(), strlen(GetName())))
823 Bool_t checkdir = kFALSE;
824 if (GetDirPtr() && GetDirPtr() == dirptr)
827 return (checkproto || checkdir);
835 int TSystem::MakeDirectory(
const char*)
837 AbstractMethod(
"MakeDirectory");
844 void *TSystem::OpenDirectory(
const char*)
846 AbstractMethod(
"OpenDirectory");
853 void TSystem::FreeDirectory(
void*)
855 AbstractMethod(
"FreeDirectory");
861 const char *TSystem::GetDirEntry(
void*)
863 AbstractMethod(
"GetDirEntry");
870 Bool_t TSystem::ChangeDirectory(
const char*)
872 AbstractMethod(
"ChangeDirectory");
879 const char *TSystem::WorkingDirectory()
887 std::string TSystem::GetWorkingDirectory()
const
889 return std::string();
895 const char *TSystem::HomeDirectory(
const char*)
903 std::string TSystem::GetHomeDirectory(
const char*)
const
905 return std::string();
914 int TSystem::mkdir(
const char *name, Bool_t recursive)
917 TString safeName = name;
919 TString dirname = DirName(safeName);
920 if (!dirname.Length()) {
925 if (AccessPathName(dirname, kFileExists)) {
926 int res = mkdir(dirname, kTRUE);
929 if (!AccessPathName(safeName, kFileExists)) {
934 return MakeDirectory(name);
942 const char *TSystem::BaseName(
const char *name)
945 if (name[0] ==
'/' && name[1] ==
'\0')
948 if ((cp = (
char*)strrchr(name,
'/')))
952 Error(
"BaseName",
"name = 0");
959 Bool_t TSystem::IsAbsoluteFileName(
const char *dir)
962 return dir[0] ==
'/';
974 Bool_t TSystem::IsFileInIncludePath(
const char *name,
char **fullpath)
976 if (!name || !name[0])
return kFALSE;
981 TString realname = SplitAclicMode(name, aclicMode, arguments, io);
983 TString fileLocation = DirName(realname);
985 TString incPath = gSystem->GetIncludePath();
986 incPath.Append(
":").Prepend(
" ");
987 incPath.ReplaceAll(
" -I",
":");
988 while ( incPath.Index(
" :") != -1 ) {
989 incPath.ReplaceAll(
" :",
":");
992 incPath.ReplaceAll(
"\":",
":");
993 incPath.ReplaceAll(
":\"",
":");
995 incPath.Prepend(fileLocation+
":.:");
997 char *actual = Which(incPath,realname);
1014 const char *TSystem::DirName(
const char *pathname)
1016 if (pathname && strchr(pathname,
'/')) {
1017 R__LOCKGUARD2(gSystemMutex);
1020 static char *buf = 0;
1021 int pathlen = strlen(pathname);
1022 if (pathlen > len) {
1025 buf =
new char [len+1];
1027 strcpy(buf, pathname);
1029 char *r = buf+pathlen-1;
1031 while ( r>buf && *(r)==
'/') { --r; }
1033 while ( r>buf && *(r)!=
'/') { --r; }
1036 while ( r>buf && *(r)==
'/') { --r; }
1039 if (r==buf && *(r)!=
'/') {
1054 const char *TSystem::UnixPathName(
const char *name)
1062 char *TSystem::ConcatFileName(
const char *dir,
const char *name)
1064 TString nameString(name);
1065 PrependPathName(dir, nameString);
1066 return StrDup(nameString.Data());
1072 const char *TSystem::PrependPathName(
const char *, TString&)
1074 AbstractMethod(
"PrependPathName");
1089 const char *TSystem::ExpandFileName(
const char *fname)
1091 const int kBufSize = kMAXPATHLEN;
1092 TTHREAD_TLS_ARRAY(
char, kBufSize, xname);
1094 Bool_t res = ExpandFileName(fname, xname, kBufSize);
1107 Bool_t TSystem::ExpandFileName(TString &fname)
1109 const int kBufSize = kMAXPATHLEN;
1110 char xname[kBufSize];
1112 Bool_t res = ExpandFileName(fname.Data(), xname, kBufSize);
1123 Bool_t TSystem::ExpandFileName(
const char *fname,
char *xname,
const int kBufSize)
1125 int n, ier, iter, lx, ncopy;
1126 char *inp, *out, *x, *t, *buff;
1127 const char *b, *c, *e;
1129 buff =
new char[kBufSize * 4];
1131 iter = 0; xname[0] = 0; inp = buff + kBufSize; out = inp + kBufSize;
1132 inp[-1] =
' '; inp[0] = 0; out[-1] =
' ';
1133 c = fname + strspn(fname,
" \t\f\r");
1136 strlcat(inp, c, kBufSize);
1139 iter++; c = inp; ier = 0;
1143 if (c[0] ==
'~' && c[1] ==
'/') {
1144 std::string hd = GetHomeDirectory();
1148 strlcpy(x, p, kBufSize);
1155 }
else if (c[0] ==
'~' && c[1] !=
'/') {
1156 n = strcspn(c+1,
"/ ");
1157 assert((n+1) < kBufSize &&
"This should have been prevented by the truncation 'strlcat(inp, c, kBufSize)'");
1159 (void)strlcpy(buff, c+1, n+1);
1160 std::string hd = GetHomeDirectory(buff);
1164 strlcpy(x, p, kBufSize);
1174 for ( ; c[0]; c++) {
1178 if (c[0] ==
'.' && c[1] ==
'/' && c[-1] ==
' ') {
1179 std::string wd = GetWorkingDirectory();
1180 strlcpy(buff, wd.c_str(), kBufSize);
1185 strlcpy(x, p, kBufSize); x += strlen(p); c = e-1;
continue;
1192 if (c[1] ==
'(') b++;
1193 if (c[1] ==
'{') b++;
1197 for (e = b; isalnum(e[0]) || e[0] ==
'_'; e++) ;
1198 buff[0] = 0; strncat(buff, b, e-b);
1201 for (t = buff; (t[0] = toupper(t[0])); t++) ;
1205 for (t = buff; (t[0] = tolower(t[0])); t++) ;
1208 if (!p && !strcmp(buff,
"cwd")) {
1209 std::string wd = GetWorkingDirectory();
1210 strlcpy(buff, wd.c_str(), kBufSize);
1213 if (!p && !strcmp(buff,
"$")) {
1214 snprintf(buff,kBufSize*4,
"%d", GetPid());
1222 if (c[1] && c[1]!=
'\\' && c[1]!=
';' && c[1]!=
'/')
1230 if (lp >= kBufSize) {
1232 strlcpy(x, p, kBufSize);
1238 c = (b==c+1) ? e-1 : e;
1243 x[0] = 0; lx = x - out;
1244 if (ier && iter < 3) { strlcpy(inp, out, kBufSize);
goto again; }
1245 ncopy = (lx >= kBufSize) ? kBufSize-1 : lx;
1246 xname[0] = 0; strncat(xname, out, ncopy);
1250 if (ier || ncopy != lx) {
1251 ::Error(
"TSystem::ExpandFileName",
"input: %s, output: %s", fname, xname);
1265 Bool_t TSystem::ExpandPathName(TString&)
1276 char *TSystem::ExpandPathName(
const char *)
1287 Bool_t TSystem::AccessPathName(
const char *, EAccessMode)
1296 Bool_t TSystem::IsPathLocal(
const char *path)
1298 Bool_t localPath = kTRUE;
1301 if (strlen(url.GetHost()) > 0) {
1304 TInetAddress a(gSystem->GetHostByName(url.GetHost()));
1305 TInetAddress b(gSystem->GetHostByName(gSystem->HostName()));
1306 if (!strcmp(a.GetHostName(), b.GetHostName()) ||
1307 !strcmp(a.GetHostAddress(), b.GetHostAddress())) {
1311 if (strlen(url.GetUser()) > 0) {
1312 UserGroup_t *u = gSystem->GetUserInfo();
1314 if (strcmp(u->fUser, url.GetUser()))
1332 int TSystem::CopyFile(
const char *,
const char *, Bool_t)
1334 AbstractMethod(
"CopyFile");
1341 int TSystem::Rename(
const char *,
const char *)
1343 AbstractMethod(
"Rename");
1350 int TSystem::Link(
const char *,
const char *)
1352 AbstractMethod(
"Link");
1359 int TSystem::Symlink(
const char *,
const char *)
1361 AbstractMethod(
"Symlink");
1372 int TSystem::Unlink(
const char *)
1374 AbstractMethod(
"Unlink");
1389 int TSystem::GetPathInfo(
const char *path, Long_t *
id, Long_t *size,
1390 Long_t *flags, Long_t *modtime)
1394 int res = GetPathInfo(path,
id, &lsize, flags, modtime);
1396 if (res == 0 && size) {
1397 if (
sizeof(Long_t) == 4 && lsize > kMaxInt) {
1398 Error(
"GetPathInfo",
"file %s > 2 GB, use GetPathInfo() with Long64_t size", path);
1401 *size = (Long_t)lsize;
1419 int TSystem::GetPathInfo(
const char *path, Long_t *
id, Long64_t *size,
1420 Long_t *flags, Long_t *modtime)
1424 int res = GetPathInfo(path, buf);
1428 *
id = (buf.fDev << 24) + buf.fIno;
1432 *modtime = buf.fMtime;
1435 if (buf.fMode & (kS_IXUSR|kS_IXGRP|kS_IXOTH))
1437 if (R_ISDIR(buf.fMode))
1439 if (!R_ISREG(buf.fMode) && !R_ISDIR(buf.fMode))
1453 int TSystem::GetPathInfo(
const char *, FileStat_t &)
1455 AbstractMethod(
"GetPathInfo(const char*, FileStat_t&)");
1463 int TSystem::GetFsInfo(
const char *, Long_t *, Long_t *, Long_t *, Long_t *)
1465 AbstractMethod(
"GetFsInfo");
1473 const char *TSystem::TempDirectory()
const
1475 AbstractMethod(
"TempDirectory");
1488 FILE *TSystem::TempFileName(TString &,
const char *)
1490 AbstractMethod(
"TempFileName");
1497 int TSystem::Chmod(
const char *, UInt_t)
1499 AbstractMethod(
"Chmod");
1506 int TSystem::Umask(Int_t)
1508 AbstractMethod(
"Umask");
1516 int TSystem::Utime(
const char *, Long_t, Long_t)
1518 AbstractMethod(
"Utime");
1527 const char *TSystem::FindFile(
const char *, TString&, EAccessMode)
1529 AbstractMethod(
"FindFile");
1537 char *TSystem::Which(
const char *search,
const char *wfil, EAccessMode mode)
1539 TString wfilString(wfil);
1540 FindFile(search, wfilString, mode);
1541 if (wfilString.IsNull())
return 0;
1542 return StrDup(wfilString.Data());
1550 Int_t TSystem::GetUid(
const char * )
1552 AbstractMethod(
"GetUid");
1560 Int_t TSystem::GetEffectiveUid()
1562 AbstractMethod(
"GetEffectiveUid");
1569 Int_t TSystem::GetGid(
const char * )
1571 AbstractMethod(
"GetGid");
1579 Int_t TSystem::GetEffectiveGid()
1581 AbstractMethod(
"GetEffectiveGid");
1589 UserGroup_t *TSystem::GetUserInfo(Int_t )
1591 AbstractMethod(
"GetUserInfo");
1600 UserGroup_t *TSystem::GetUserInfo(
const char * )
1602 AbstractMethod(
"GetUserInfo");
1613 UserGroup_t *TSystem::GetGroupInfo(Int_t )
1615 AbstractMethod(
"GetGroupInfo");
1626 UserGroup_t *TSystem::GetGroupInfo(
const char * )
1628 AbstractMethod(
"GetGroupInfo");
1637 void TSystem::Setenv(
const char*,
const char*)
1639 AbstractMethod(
"Setenv");
1645 void TSystem::Unsetenv(
const char *name)
1653 const char *TSystem::Getenv(
const char*)
1655 AbstractMethod(
"Getenv");
1665 void TSystem::Openlog(
const char *, Int_t, ELogFacility)
1667 AbstractMethod(
"Openlog");
1674 void TSystem::Syslog(ELogLevel,
const char *)
1676 AbstractMethod(
"Syslog");
1682 void TSystem::Closelog()
1684 AbstractMethod(
"Closelog");
1703 Int_t TSystem::RedirectOutput(
const char *,
const char *, RedirectHandle_t *)
1705 AbstractMethod(
"RedirectOutput");
1713 void TSystem::ShowOutput(RedirectHandle_t *h)
1717 Error(
"ShowOutput",
"handle not specified");
1722 if (gSystem->AccessPathName(h->fFile, kReadPermission)) {
1723 Error(
"ShowOutput",
"file '%s' cannot be read", h->fFile.Data());
1729 if (!(f = fopen(h->fFile.Data(),
"r"))) {
1730 Error(
"ShowOutput",
"file '%s' cannot be open", h->fFile.Data());
1735 off_t ltot = lseek(fileno(f), (off_t) 0, SEEK_END);
1736 Int_t begin = (h->fReadOffSet > 0 && h->fReadOffSet < ltot) ? h->fReadOffSet : 0;
1737 lseek(fileno(f), (off_t) begin, SEEK_SET);
1738 Int_t left = ltot - begin;
1741 const Int_t kMAXBUF = 16384;
1743 Int_t wanted = (left > kMAXBUF-1) ? kMAXBUF-1 : left;
1746 while ((len = read(fileno(f), buf, wanted)) < 0 &&
1747 TSystem::GetErrno() == EINTR)
1748 TSystem::ResetErrno();
1751 SysError(
"ShowOutput",
"error reading log file");
1757 fprintf(stderr,
"%s", buf);
1761 wanted = (left > kMAXBUF) ? kMAXBUF : left;
1763 }
while (len > 0 && left > 0);
1766 h->fReadOffSet = ltot;
1775 void TSystem::AddDynamicPath(
const char *)
1777 AbstractMethod(
"AddDynamicPath");
1783 const char* TSystem::GetDynamicPath()
1785 AbstractMethod(
"GetDynamicPath");
1794 void TSystem::SetDynamicPath(
const char *)
1796 AbstractMethod(
"SetDynamicPath");
1804 static bool R__MatchFilename(
const char *left,
const char *right)
1806 if (left == right)
return kTRUE;
1808 if (left==0 || right==0)
return kFALSE;
1810 if ( (strcmp(right,left)==0) ) {
1816 char leftname[_MAX_PATH];
1817 char rightname[_MAX_PATH];
1818 _fullpath( leftname, left, _MAX_PATH );
1819 _fullpath( rightname, right, _MAX_PATH );
1820 return ((stricmp(leftname, rightname)==0));
1822 struct stat rightBuf;
1823 struct stat leftBuf;
1824 return ( ( 0 == stat( left, & leftBuf ) )
1825 && ( 0 == stat( right, & rightBuf ) )
1826 && ( leftBuf.st_dev == rightBuf.st_dev )
1827 && ( leftBuf.st_ino == rightBuf.st_ino )
1828 && ( leftBuf.st_size == rightBuf.st_size )
1829 && ( leftBuf.st_mtime == rightBuf.st_mtime )
1844 int TSystem::Load(
const char *module,
const char *entry, Bool_t system)
1847 TString libs( GetLibraries() );
1848 TString moduleBasename( BaseName(module) );
1849 TString l(moduleBasename);
1851 Ssiz_t idx = l.Last(
'.');
1855 for (idx = libs.Index(l); idx != kNPOS; idx = libs.Index(l,idx+1)) {
1858 if (idx == 0 || libs[idx-1] ==
'/' || libs[idx-1] ==
'\\') {
1859 Ssiz_t len = libs.Length();
1861 if (!l.EndsWith(
".") && libs[idx]==
'.')
1864 while (idx < len && isdigit(libs[idx])) {
1867 if (libs[idx] ==
'.') {
1871 while (idx < len && libs[idx] !=
'.') {
1872 if (libs[idx] ==
' ' || idx+1 == len) {
1879 if (l[l.Length()-1] ==
'.') {
1880 l.Remove(l.Length()-1);
1882 if (l.BeginsWith(
"lib")) {
1883 l.Replace(0, 3,
"-l");
1884 for(idx = libs.Index(l); idx != kNPOS; idx = libs.Index(l,idx+1)) {
1885 if ((idx == 0 || libs[idx-1] ==
' ') &&
1886 (libs[idx+l.Length()] ==
' ' || libs[idx+l.Length()] == 0)) {
1892 char *path = DynamicPathName(module);
1897 TString deplibs = gInterpreter->GetSharedLibDeps(moduleBasename);
1898 if (deplibs.IsNull()) {
1899 TString libmapfilename;
1900 libmapfilename = path;
1901 idx = libmapfilename.Last(
'.');
1903 libmapfilename.Remove(idx);
1905 libmapfilename +=
".rootmap";
1906 if (gSystem->GetPathInfo(libmapfilename, 0, (Long_t*)0, 0, 0) == 0) {
1907 if (gDebug > 0) Info(
"Load",
"loading %s", libmapfilename.Data());
1908 gInterpreter->LoadLibraryMap(libmapfilename);
1909 deplibs = gInterpreter->GetSharedLibDeps(moduleBasename);
1913 TObjArray *tokens = deplibs.Tokenize(delim);
1914 for (Int_t i = tokens->GetEntriesFast()-1; i > 0; i--) {
1915 const char *deplib = ((TObjString*)tokens->At(i))->GetName();
1916 if (strcmp(module,deplib)==0) {
1920 Info(
"Load",
"loading dependent library %s for library %s",
1921 deplib, ((TObjString*)tokens->At(0))->GetName());
1922 if ((ret = Load(deplib,
"", system)) < 0) {
1932 const char *dirname = DirName(path);
1933 system = R__MatchFilename(TROOT::GetLibDir(), dirname);
1936 system = R__MatchFilename(TROOT::GetBinDir(), dirname);
1940 gLibraryVersionIdx++;
1941 if (gLibraryVersionIdx == gLibraryVersionMax) {
1942 gLibraryVersionMax *= 2;
1943 gLibraryVersion = TStorage::ReAllocInt(gLibraryVersion, gLibraryVersionMax, gLibraryVersionIdx);
1945 ret = gInterpreter->Load(path, system);
1946 if (ret < 0) ret = -1;
1948 Info(
"Load",
"loaded library %s, status %d", path, ret);
1949 if (ret == 0 && gLibraryVersion[gLibraryVersionIdx]) {
1950 int v = TROOT::ConvertVersionCode2Int(gLibraryVersion[gLibraryVersionIdx]);
1951 Error(
"Load",
"version mismatch, %s = %d, ROOT = %d",
1952 path, v, gROOT->GetVersionInt());
1954 gLibraryVersion[gLibraryVersionIdx] = 0;
1956 gLibraryVersionIdx--;
1960 if (!entry || !entry[0] || ret < 0)
return ret;
1962 Func_t f = DynFindSymbol(module, entry);
1971 UInt_t TSystem::LoadAllLibraries()
1975 TEnv* mapfile = gInterpreter->GetMapfile();
1976 if (!mapfile || !mapfile->GetTable())
return 0;
1978 std::set<std::string> loadedlibs;
1979 std::set<std::string> failedlibs;
1982 TIter iEnvRec(mapfile->GetTable());
1983 while ((rec = (TEnvRec*) iEnvRec())) {
1984 TString libs = rec->GetValue();
1987 while (libs.Tokenize(lib, pos)) {
1989 if (failedlibs.find(lib.Data()) != failedlibs.end()) {
1996 while (libs.Tokenize(lib, pos)) {
1998 if (lib.BeginsWith(
"libCore"))
2001 if (loadedlibs.find(lib.Data()) == loadedlibs.end()) {
2003 auto res = gSystem->Load(lib);
2005 if (res == 0) ++nlibs;
2006 loadedlibs.insert(lib.Data());
2008 failedlibs.insert(lib.Data());
2021 char *TSystem::DynamicPathName(
const char *lib, Bool_t quiet )
2024 if (FindDynamicLibrary(sLib, quiet))
2025 return StrDup(sLib);
2035 const char *TSystem::FindDynamicLibrary(TString&, Bool_t)
2037 AbstractMethod(
"FindDynamicLibrary");
2045 Func_t TSystem::DynFindSymbol(
const char * ,
const char *entry)
2047 return (Func_t) gInterpreter->FindSym(entry);
2053 void TSystem::Unload(
const char *module)
2056 if ((path = DynamicPathName(module))) {
2057 gInterpreter->UnloadFile(path);
2065 void TSystem::ListSymbols(
const char *,
const char *)
2067 AbstractMethod(
"ListSymbols");
2074 void TSystem::ListLibraries(
const char *regexp)
2076 TString libs = GetLibraries(regexp);
2077 TRegexp separator(
"[^ \\t\\s]+");
2079 Ssiz_t start = 0, index = 0, end = 0;
2083 Printf(
"Loaded shared libraries");
2084 Printf(
"=======================");
2086 while ((start < libs.Length()) && (index != kNPOS)) {
2087 index = libs.Index(separator, &end, start);
2089 s = libs(index, end);
2090 if (s.BeginsWith(
"-")) {
2091 if (s.BeginsWith(
"-l")) {
2092 Printf(
"%s", s.Data());
2096 Printf(
"%s", s.Data());
2103 Printf(
"-----------------------");
2104 Printf(
"%d libraries loaded", i);
2105 Printf(
"=======================");
2111 TString &TSystem::GetLastErrorString()
2113 TTHREAD_TLS_DECL( TString, gLastErrorString);
2114 return gLastErrorString;
2120 const TString &TSystem::GetLastErrorString()
const
2122 return const_cast<TSystem*
>(
this)->GetLastErrorString();
2129 const char *TSystem::GetLinkedLibraries()
2147 const char *TSystem::GetLibraries(
const char *regexp,
const char *options,
2153 TString opt(options);
2154 Bool_t so2dylib = (opt.First(
'L') != kNPOS);
2156 opt.ReplaceAll(
"L",
"");
2158 if (opt.IsNull() || opt.First(
'D') != kNPOS)
2159 libs += gInterpreter->GetSharedLibs();
2168 if ((linked = GetLinkedLibraries())) {
2169 if (fLinkedLibs != LINKEDLIBS) {
2171 TString custom = fLinkedLibs;
2172 custom.ReplaceAll(LINKEDLIBS,linked);
2173 if (custom == fLinkedLibs) {
2175 slinked.Append(linked);
2176 slinked.Append(
" ");
2178 slinked.Append(custom);
2180 slinked.Append(linked);
2183 slinked.Append(fLinkedLibs);
2186 if (opt.IsNull() || opt.First(
'S') != kNPOS) {
2188 if (libs.Length() == 0) {
2193 static TString lastLinked;
2194 static TString lastAddMissing;
2195 if ( lastLinked != slinked ) {
2197 static TRegexp separator(
"[^ \\t\\s]+");
2198 lastLinked = slinked;
2199 lastAddMissing.Clear();
2201 Ssiz_t start, index, end;
2202 start = index = end = 0;
2204 while ((start < slinked.Length()) && (index != kNPOS)) {
2205 index = slinked.Index(separator,&end,start);
2207 TString sub = slinked(index,end);
2208 if (sub[0]==
'-' && sub[1]==
'L') {
2209 lastAddMissing.Prepend(
" ");
2210 lastAddMissing.Prepend(sub);
2212 if (libs.Index(sub) == kNPOS) {
2213 lastAddMissing.Prepend(
" ");
2214 lastAddMissing.Prepend(sub);
2221 libs.Prepend(lastAddMissing);
2223 }
else if (libs.Length() != 0) {
2226 static TRegexp separator(
"[^ \\t\\s]+");
2227 Ssiz_t start, index, end;
2228 start = index = end = 0;
2230 while ((start < slinked.Length()) && (index != kNPOS)) {
2231 index = slinked.Index(separator,&end,start);
2233 TString sub = slinked(index,end);
2234 if (sub[0]!=
'-' && sub[1]!=
'L') {
2235 libs.ReplaceAll(sub,
"");
2240 libs = libs.Strip(TString::kBoth);
2244 if (regexp && *regexp) {
2245 static TRegexp separator(
"[^ \\t\\s]+");
2246 TRegexp user_re(regexp, kTRUE);
2248 Ssiz_t start, index, end;
2249 start = index = end = 0;
2251 while ((start < libs.Length()) && (index != kNPOS)) {
2252 index = libs.Index(separator,&end,start);
2254 s = libs(index,end);
2255 if ((isRegexp && s.Index(user_re) != kNPOS) ||
2256 (!isRegexp && s.Index(regexp) != kNPOS)) {
2257 if (!fListLibs.IsNull())
2258 fListLibs.Append(
" ");
2259 fListLibs.Append(s);
2267 #if defined(R__MACOSX)
2270 TString libs2 = fListLibs;
2273 static TRegexp separator(
"[^ \\t\\s]+");
2274 static TRegexp dynload(
"/lib-dynload/");
2276 Ssiz_t start, index, end;
2277 start = index = end = 0;
2279 while ((start < libs2.Length()) && (index != kNPOS)) {
2280 index = libs2.Index(separator, &end, start);
2282 TString s = libs2(index, end);
2283 if (s.Index(dynload) == kNPOS) {
2284 if (!maclibs.IsNull()) maclibs.Append(
" ");
2290 fListLibs = maclibs;
2294 #if defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5)
2296 TString libs2 = fListLibs;
2299 static TRegexp separator(
"[^ \\t\\s]+");
2300 static TRegexp user_so(
"\\.so$");
2302 Ssiz_t start, index, end;
2303 start = index = end = 0;
2305 while ((start < libs2.Length()) && (index != kNPOS)) {
2306 index = libs2.Index(separator, &end, start);
2310 TString s = libs2(index, end);
2311 if (s.Index(user_so) != kNPOS) {
2312 s.ReplaceAll(
".so",
".dylib");
2313 if ( GetPathInfo( s, 0, (Long_t*)0, 0, 0 ) != 0 ) {
2314 s.Replace( 0, s.Last(
'/')+1, 0, 0);
2315 s.Replace( 0, s.Last(
'\\')+1, 0, 0);
2318 if (!maclibs.IsNull()) maclibs.Append(
" ");
2323 fListLibs = maclibs;
2327 return fListLibs.Data();
2335 TInetAddress TSystem::GetHostByName(
const char *)
2337 AbstractMethod(
"GetHostByName");
2338 return TInetAddress();
2344 TInetAddress TSystem::GetPeerName(
int)
2346 AbstractMethod(
"GetPeerName");
2347 return TInetAddress();
2353 TInetAddress TSystem::GetSockName(
int)
2355 AbstractMethod(
"GetSockName");
2356 return TInetAddress();
2362 int TSystem::GetServiceByName(
const char *)
2364 AbstractMethod(
"GetServiceByName");
2371 char *TSystem::GetServiceByPort(
int)
2373 AbstractMethod(
"GetServiceByPort");
2380 int TSystem::OpenConnection(
const char*,
int,
int,
const char*)
2382 AbstractMethod(
"OpenConnection");
2389 int TSystem::AnnounceTcpService(
int, Bool_t,
int,
int)
2391 AbstractMethod(
"AnnounceTcpService");
2398 int TSystem::AnnounceUdpService(
int,
int)
2400 AbstractMethod(
"AnnounceUdpService");
2407 int TSystem::AnnounceUnixService(
int,
int)
2409 AbstractMethod(
"AnnounceUnixService");
2416 int TSystem::AnnounceUnixService(
const char *,
int)
2418 AbstractMethod(
"AnnounceUnixService");
2425 int TSystem::AcceptConnection(
int)
2427 AbstractMethod(
"AcceptConnection");
2434 void TSystem::CloseConnection(
int, Bool_t)
2436 AbstractMethod(
"CloseConnection");
2443 int TSystem::RecvRaw(
int,
void *,
int,
int)
2445 AbstractMethod(
"RecvRaw");
2453 int TSystem::SendRaw(
int,
const void *,
int,
int)
2455 AbstractMethod(
"SendRaw");
2462 int TSystem::RecvBuf(
int,
void *,
int)
2464 AbstractMethod(
"RecvBuf");
2471 int TSystem::SendBuf(
int,
const void *,
int)
2473 AbstractMethod(
"SendBuf");
2480 int TSystem::SetSockOpt(
int,
int,
int)
2482 AbstractMethod(
"SetSockOpt");
2489 int TSystem::GetSockOpt(
int,
int,
int*)
2491 AbstractMethod(
"GetSockOpt");
2502 int TSystem::GetSysInfo(SysInfo_t *)
const
2504 AbstractMethod(
"GetSysInfo");
2513 int TSystem::GetCpuInfo(CpuInfo_t *, Int_t)
const
2515 AbstractMethod(
"GetCpuInfo");
2523 int TSystem::GetMemInfo(MemInfo_t *)
const
2525 AbstractMethod(
"GetMemInfo");
2533 int TSystem::GetProcInfo(ProcInfo_t *)
const
2535 AbstractMethod(
"GetProcInfo");
2541 void AssignAndDelete(TString& target,
char *tobedeleted)
2545 target = tobedeleted;
2546 delete [] tobedeleted;
2551 static TString R__Exec(
const char *cmd)
2555 FILE * f = gSystem->OpenPipe(cmd,
"r");
2562 while ((x = fgetc(f))!=EOF ) {
2563 if (x==
'\n' || x==
'\r')
break;
2571 static void R__FixLink(TString &cmd)
2577 TString res = R__Exec(
"link 2>&1");
2579 if (res.Contains(
"Microsoft (R) Incremental Linker"))
2583 res = R__Exec(
"cygpath . 2>&1");
2589 res = R__Exec(
"which cl.exe 2>&1|grep cl|sed 's,cl\\.exe$,link\\.exe,' 2>&1");
2591 res = R__Exec(Form(
"cygpath -w '%s' 2>&1",res.Data()));
2593 cmd.ReplaceAll(
" link ",Form(
" \"%s\" ",res.Data()));
2599 #if defined(__CYGWIN__)
2600 static void R__AddPath(TString &target,
const TString &path) {
2601 if (path.Length() > 2 && path[1]==
':') {
2602 target += TString::Format(
"/cygdrive/%c",path[0]) + path(2,path.Length()-2);
2608 static void R__AddPath(TString &target,
const TString &path) {
2613 static void R__WriteDependencyFile(
const TString & build_loc,
const TString &depfilename,
const TString &filename,
const TString &library,
const TString &libname,
2614 const TString &extension,
const char *version_var_prefix,
const TString &includes,
const TString &defines,
const TString &incPath)
2620 const char * stderrfile =
"/dev/null";
2623 AssignAndDelete( stderrfile, gSystem->ConcatFileName(build_loc,
"stderr.tmp") );
2625 TString bakdepfilename = depfilename +
".bak";
2628 TString touch =
"echo # > "; touch +=
"\"" + depfilename +
"\"";
2630 TString touch =
"echo > "; touch +=
"\"" + depfilename +
"\"";
2632 TString builddep =
"rmkdepend";
2633 gSystem->PrependPathName(TROOT::GetBinDir(), builddep);
2634 builddep +=
" \"-f";
2635 builddep += depfilename;
2636 builddep +=
"\" -o_" + extension +
"." + gSystem->GetSoExt() +
" ";
2637 if (build_loc.BeginsWith(gSystem->WorkingDirectory())) {
2638 Int_t len = strlen(gSystem->WorkingDirectory());
2639 if ( build_loc.Length() > (len+1) ) {
2640 builddep +=
" \"-p";
2641 if (build_loc[len] ==
'/' || build_loc[len+1] !=
'\\' ) {
2643 R__AddPath(builddep, build_loc.Data() + len + 1 );
2646 R__AddPath(builddep, build_loc.Data() + len + 2 );
2651 builddep +=
" \"-p";
2652 R__AddPath(builddep, build_loc);
2655 builddep +=
" -Y -- ";
2656 TString rootsysInclude = TROOT::GetIncludeDir();
2657 builddep +=
" \"-I"+rootsysInclude+
"\" ";
2658 builddep += includes;
2659 builddep += defines;
2660 builddep +=
" -- \"";
2661 builddep += filename;
2664 if (library.BeginsWith(gSystem->WorkingDirectory())) {
2665 Int_t len = strlen(gSystem->WorkingDirectory());
2666 if ( library.Length() > (len+1) ) {
2667 if (library[len] ==
'/' || library[len+1] !=
'\\' ) {
2668 targetname = library.Data() + len + 1;
2670 targetname = library.Data() + len + 2;
2673 targetname = library;
2676 targetname = library;
2680 R__AddPath(builddep, targetname);
2681 builddep +=
"\" > ";
2682 builddep += stderrfile;
2683 builddep +=
" 2>&1 ";
2685 TString adddictdep =
"echo ";
2686 R__AddPath(adddictdep,targetname);
2688 #if defined(R__HAS_CLING_DICTVERSION)
2690 char *clingdictversion = gSystem->Which(incPath,
"clingdictversion.h");
2691 if (clingdictversion) {
2692 R__AddPath(adddictdep,clingdictversion);
2694 delete [] clingdictversion;
2696 R__AddPath(adddictdep,rootsysInclude+
"/clingdictversion.h ");
2701 const char *dictHeaders[] = {
"RVersion.h",
"RConfig.h",
"TClass.h",
2702 "TDictAttributeMap.h",
"TInterpreter.h",
"TROOT.h",
"TBuffer.h",
2703 "TMemberInspector.h",
"TError.h",
"RtypesImp.h",
"TIsAProxy.h",
2704 "TFileMergeInfo.h",
"TCollectionProxyInfo.h"};
2706 for (
unsigned int h=0; h <
sizeof(dictHeaders)/
sizeof(dictHeaders[0]); ++h)
2708 char *rootVersion = gSystem->Which(incPath,dictHeaders[h]);
2710 R__AddPath(adddictdep,rootVersion);
2711 delete [] rootVersion;
2713 R__AddPath(adddictdep,rootsysInclude +
"/" + dictHeaders[h]);
2720 char *rootCling = gSystem->Which(gSystem->Getenv(
"PATH"),
"rootcling");
2722 R__AddPath(adddictdep,rootCling);
2724 delete [] rootCling;
2727 adddictdep +=
" >> \""+depfilename+
"\"";
2729 TString addversiondep(
"echo ");
2730 addversiondep += libname + version_var_prefix +
" \"" + ROOT_RELEASE +
"\" >> \""+depfilename+
"\"";
2733 ::Info(
"ACLiC",
"%s", touch.Data());
2734 ::Info(
"ACLiC",
"%s", builddep.Data());
2735 ::Info(
"ACLiC",
"%s", adddictdep.Data());
2738 Int_t depbuilt = !gSystem->Exec(touch);
2739 if (depbuilt) depbuilt = !gSystem->Exec(builddep);
2740 if (depbuilt) depbuilt = !gSystem->Exec(adddictdep);
2741 if (depbuilt) depbuilt = !gSystem->Exec(addversiondep);
2744 ::Warning(
"ACLiC",
"Failed to generate the dependency file for %s",
2748 gSystem->Unlink(stderrfile);
2750 gSystem->Unlink(bakdepfilename);
2874 int TSystem::CompileMacro(
const char *filename, Option_t *opt,
2875 const char *library_specified,
2876 const char *build_dir,
2879 static const char *version_var_prefix =
"__ROOTBUILDVERSION=";
2882 Bool_t keep = kFALSE;
2883 Bool_t recompile = kFALSE;
2884 EAclicMode mode = fAclicMode;
2885 Bool_t loadLib = kTRUE;
2886 Bool_t withInfo = kTRUE;
2887 Bool_t verbose = kFALSE;
2888 Bool_t internalDebug = kFALSE;
2890 keep = (strchr(opt,
'k')!=0);
2891 recompile = (strchr(opt,
'f')!=0);
2892 if (strchr(opt,
'O')!=0) {
2895 if (strchr(opt,
'g')!=0) {
2898 if (strchr(opt,
'c')!=0) {
2901 withInfo = strchr(opt,
's') == 0;
2902 verbose = strchr(opt,
'v') != 0;
2903 internalDebug = strchr(opt,
'd') != 0;
2905 if (mode==kDefault) {
2906 TString rootbuild = ROOTBUILD;
2907 if (rootbuild.Index(
"debug",0,TString::kIgnoreCase)==kNPOS) {
2913 UInt_t verboseLevel = verbose ? 7 : gDebug;
2914 Bool_t flatBuildDir = (fAclicProperties & kFlatBuildDir) || (strchr(opt,
'-')!=0);
2917 TString build_loc = ExpandFileName(GetBuildDir());
2918 if (build_dir && strlen(build_dir)) build_loc = build_dir;
2919 if (build_loc ==
".") {
2920 build_loc = WorkingDirectory();
2921 }
else if (build_loc.Length() && (!IsAbsoluteFileName(build_loc)) ) {
2922 AssignAndDelete( build_loc , ConcatFileName( WorkingDirectory(), build_loc ) );
2928 TString incPath = GetIncludePath();
2929 incPath.Append(
":").Prepend(
" ");
2931 TString fromConfig = gEnv->GetValue(
"ACLiC.IncludePaths",
"");
2932 incPath.Append(fromConfig);
2934 incPath.ReplaceAll(
" -I",
":");
2935 auto posISysRoot = incPath.Index(
" -isysroot \"");
2936 if (posISysRoot != kNPOS) {
2937 auto posISysRootEnd = incPath.Index(
'"', posISysRoot + 12);
2938 if (posISysRootEnd != kNPOS) {
2941 incPath.Insert(posISysRootEnd - 1,
"/usr/include/");
2942 incPath.Replace(posISysRoot, 12,
":\"");
2945 while ( incPath.Index(
" :") != -1 ) {
2946 incPath.ReplaceAll(
" :",
":");
2948 incPath.Prepend(
":.:");
2949 incPath.Prepend(WorkingDirectory());
2952 TString expFileName(filename);
2953 ExpandPathName( expFileName );
2954 expFileName = gSystem->UnixPathName(expFileName);
2955 TString library = expFileName;
2956 if (! IsAbsoluteFileName(library) )
2958 const char *whichlibrary = Which(incPath,library);
2960 library = whichlibrary;
2961 delete [] whichlibrary;
2963 ::Error(
"ACLiC",
"The file %s can not be found in the include path: %s",filename,incPath.Data());
2967 if (gSystem->AccessPathName(library)) {
2968 ::Error(
"ACLiC",
"The file %s can not be found.",filename);
2974 while ((pos = library.Index(
"//", 2, pos, TString::kExact)) != kNPOS) {
2975 library.Remove(pos, 1);
2978 library = gSystem->UnixPathName(library);
2979 TString filename_fullpath = library;
2981 TString file_dirname = DirName( filename_fullpath );
2986 if (library.Length()>1 && isalpha(library[0]) && library[1]==
':') {
2987 file_dirname.Prepend(library(0,2));
2989 TString file_location( file_dirname );
2990 incPath.Prepend( file_location +
":" );
2992 Ssiz_t dot_pos = library.Last(
'.');
2993 TString extension = library;
2994 extension.Replace( 0, dot_pos+1, 0 , 0);
2995 TString libname_noext = library;
2996 if (dot_pos>=0) libname_noext.Remove( dot_pos );
2999 library.Replace( dot_pos, library.Length()-dot_pos,
3000 TString(
"_") + extension +
"." + fSoExt );
3002 TString libname ( BaseName( libname_noext ) );
3003 libname.Append(
"_").Append(extension);
3005 if (library_specified && strlen(library_specified) ) {
3007 libname = BaseName( library_specified );
3008 library = library_specified;
3009 ExpandPathName( library );
3010 if (! IsAbsoluteFileName(library) ) {
3011 AssignAndDelete( library , ConcatFileName( WorkingDirectory(), library ) );
3013 library = TString(library) +
"." + fSoExt;
3015 library = gSystem->UnixPathName(library);
3017 TString libname_ext ( libname );
3018 libname_ext +=
"." + fSoExt;
3020 TString lib_dirname = DirName( library );
3025 if (library.Length()>1 && isalpha(library[0]) && library[1]==
':') {
3026 lib_dirname.Prepend(library(0,2));
3029 if ( strncmp( &(lib_dirname[lib_dirname.Length()-2]),
"/.", 2) == 0 ) {
3030 lib_dirname.Remove(lib_dirname.Length()-2);
3032 if ( strncmp( &(lib_dirname[lib_dirname.Length()-2]),
"\\.", 2) == 0 ) {
3033 lib_dirname.Remove(lib_dirname.Length()-2);
3035 TString lib_location( lib_dirname );
3036 Bool_t mkdirFailed = kFALSE;
3038 if (build_loc.Length()==0) {
3039 build_loc = lib_location;
3042 TRegexp disk_finder (
"[A-z]:");
3043 Int_t pos = library.Index( disk_finder );
3044 if (pos==0) library.Remove(pos,3);
3045 pos = lib_location.Index( disk_finder );
3046 if (pos==0) lib_location.Remove(pos,3);
3049 AssignAndDelete( library, ConcatFileName( build_loc, libname_ext) );
3051 AssignAndDelete( library, ConcatFileName( build_loc, library) );
3054 Bool_t canWriteBuild_loc = !gSystem->AccessPathName(build_loc,kWritePermission);
3055 TString build_loc_store( build_loc );
3056 if (!flatBuildDir) {
3057 AssignAndDelete( build_loc, ConcatFileName( build_loc, lib_location) );
3060 if (gSystem->AccessPathName(build_loc,kFileExists)) {
3061 mkdirFailed = (0 != mkdir(build_loc,
true));
3062 if (mkdirFailed && !canWriteBuild_loc) {
3065 build_loc = build_loc_store;
3066 mkdirFailed = kFALSE;
3067 }
else if (!mkdirFailed && dirmode!=0) {
3068 Chmod(build_loc,dirmode);
3072 library = gSystem->UnixPathName(library);
3075 if (!gInterpreter->IsLibraryLoaded(library) && gInterpreter->IsLoaded(expFileName)) {
3080 ::Info(
"ACLiC",
"script has already been loaded in interpreted mode");
3081 ::Info(
"ACLiC",
"unloading %s and compiling it", filename);
3084 if ( gInterpreter->UnloadFile( expFileName ) != 0 ) {
3091 TString includes = GetIncludePath();
3092 includes.Prepend(
' ');
3096 TRegexp rel_inc(
" -I[^\"/\\$%-][^:-]+");
3098 pos = rel_inc.Index(includes,&len);
3100 TString sub = includes(pos,len);
3102 AssignAndDelete( sub, ConcatFileName( WorkingDirectory(), sub ) );
3103 sub.Prepend(
" -I\"");
3106 includes.Replace(pos,len,sub);
3107 pos = rel_inc.Index(includes,&len);
3112 TRegexp rel_inc(
" -I\"[^/\\$%-][^:-]+");
3114 pos = rel_inc.Index(includes,&len);
3116 TString sub = includes(pos,len);
3118 AssignAndDelete( sub, ConcatFileName( WorkingDirectory(), sub ) );
3119 sub.Prepend(
" -I\"");
3120 includes.Replace(pos,len,sub);
3121 pos = rel_inc.Index(includes,&len);
3134 TString fromConfig = gEnv->GetValue(
"ACLiC.IncludePaths",
"");
3135 includes.Append(
" ").Append(fromConfig).Append(
" ");
3139 TString defines =
" ";
3141 TString cmd = GetMakeSharedLib();
3142 TRegexp rel_def(
"-D[^\\s\\t\\n\\r]*");
3144 pos = rel_def.Index(cmd,&len);
3146 defines += cmd(pos,len);
3148 pos = rel_def.Index(cmd,&len,pos+1);
3153 TString emergency_loc;
3155 UserGroup_t *ug = gSystem->GetUserInfo(gSystem->GetUid());
3157 AssignAndDelete( emergency_loc, ConcatFileName( TempDirectory(), ug->fUser ) );
3160 emergency_loc = TempDirectory();
3164 Bool_t canWrite = !gSystem->AccessPathName(build_loc,kWritePermission);
3166 Bool_t modified = kFALSE;
3169 TString depdir = build_loc;
3170 TString depfilename;
3171 AssignAndDelete( depfilename, ConcatFileName(depdir, BaseName(libname_noext)) );
3172 depfilename +=
"_" + extension +
".d";
3176 Long_t lib_time, file_time;
3178 if ((gSystem->GetPathInfo( library, 0, (Long_t*)0, 0, &lib_time ) != 0) ||
3179 (gSystem->GetPathInfo( expFileName, 0, (Long_t*)0, 0, &file_time ) == 0 &&
3180 (lib_time < file_time))) {
3188 if ( gSystem->GetPathInfo( depfilename, 0,(Long_t*) 0, 0, &file_time ) != 0 ) {
3190 depdir = emergency_loc;
3191 AssignAndDelete( depfilename, ConcatFileName(depdir, BaseName(libname_noext)) );
3192 depfilename +=
"_" + extension +
".d";
3194 R__WriteDependencyFile(build_loc, depfilename, filename_fullpath, library, libname, extension, version_var_prefix, includes, defines, incPath);
3201 FILE * depfile = fopen(depfilename.Data(),
"r");
3210 TString version_var = libname + version_var_prefix;
3213 char *line =
new char[sz];
3219 Bool_t hasversion =
false;
3221 while ((c = fgetc(depfile)) != EOF) {
3224 while ((c = fgetc(depfile)) != EOF) {
3231 if (current && line[current-1]==
'=' && strncmp(version_var.Data(),line,current)==0) {
3237 }
else if (isspace(c) && !nested) {
3239 if (line[current-1]!=
':') {
3245 modified |= strcmp(ROOT_RELEASE,line)!=0;
3246 hasversion = kFALSE;
3247 }
else if ( gSystem->GetPathInfo( line, 0, (Long_t*)0, 0, &filetime ) == 0 ) {
3248 modified |= ( lib_time <= filetime );
3255 if (current==sz-1) {
3257 char *newline =
new char[sz];
3258 memcpy(newline,line, current);
3262 if (c==
'"') nested = !nested;
3271 recompile = modified;
3278 if ( gInterpreter->IsLibraryLoaded(library)
3279 || strlen(GetLibraries(library,
"D",kFALSE)) != 0 ) {
3282 Bool_t reload = kFALSE;
3283 TNamed *libinfo = (TNamed*)fCompiled->FindObject(library);
3285 Long_t load_time = libinfo->GetUniqueID();
3287 if ( gSystem->GetPathInfo( library, 0, (Long_t*)0, 0, &lib_time ) == 0
3288 && (lib_time>load_time)) {
3293 if ( !recompile && reload ) {
3296 ::Info(
"ACLiC",
"%s has been modified and will be reloaded",
3299 if ( gInterpreter->UnloadFile( library.Data() ) != 0 ) {
3304 fCompiled->Remove(libinfo);
3308 TNamed *k =
new TNamed(library,library);
3310 gSystem->GetPathInfo( library, 0, (Long_t*)0, 0, &lib_time );
3311 k->SetUniqueID(lib_time);
3312 if (!keep) k->SetBit(kMustCleanup);
3315 return !gSystem->Load(library);
3319 ::Info(
"ACLiC",
"%s script has already been compiled and loaded",
3320 modified ?
"modified" :
"unmodified");
3327 ::Info(
"ACLiC",
"it will be regenerated and reloaded!");
3329 if ( gInterpreter->UnloadFile( library.Data() ) != 0 ) {
3334 fCompiled->Remove(libinfo);
3343 TString libmapfilename;
3344 AssignAndDelete( libmapfilename, ConcatFileName( build_loc, libname ) );
3345 libmapfilename +=
".rootmap";
3346 #if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5)) || defined(R__WIN32)
3347 Bool_t produceRootmap = kTRUE;
3349 Bool_t produceRootmap = kFALSE;
3351 Bool_t linkDepLibraries = !produceRootmap;
3353 #if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5))
3354 Int_t linkLibs = gEnv->GetValue(
"ACLiC.LinkLibs",2);
3355 #elif defined(R__WIN32)
3356 Int_t linkLibs = gEnv->GetValue(
"ACLiC.LinkLibs",3);
3358 Int_t linkLibs = gEnv->GetValue(
"ACLiC.LinkLibs",1);
3360 produceRootmap = linkLibs & 0x2;
3361 linkDepLibraries = linkLibs & 0x1;
3365 bool useCxxModules =
3366 #ifdef R__USE_CXXMODULES
3372 auto LoadLibrary = [useCxxModules, produceRootmap](
const TString& lib) {
3381 if (useCxxModules && !produceRootmap) {
3382 using namespace std;
3383 string deps = gInterpreter->GetSharedLibDeps(lib,
true);
3384 istringstream iss(deps);
3385 vector<string> libs {istream_iterator<std::string>{iss}, istream_iterator<string>{}};
3387 for (
auto I = libs.begin() + 1, E = libs.end(); I != E; ++I)
3388 if (gInterpreter->Load(I->c_str(),
false) < 0)
3391 return !gSystem->Load(lib);
3397 TNamed *k =
new TNamed(library,library);
3399 gSystem->GetPathInfo( library, 0, (Long_t*)0, 0, &lib_time );
3400 k->SetUniqueID(lib_time);
3401 if (!keep) k->SetBit(kMustCleanup);
3404 if (gInterpreter->GetSharedLibDeps(libname) == 0) {
3405 gInterpreter->LoadLibraryMap(libmapfilename);
3408 return LoadLibrary(library);
3413 if (!canWrite && recompile) {
3416 ::Warning(
"ACLiC",
"Could not create the directory: %s",
3419 ::Warning(
"ACLiC",
"%s is not writable!",
3422 if (emergency_loc == build_dir ) {
3423 ::Error(
"ACLiC",
"%s is the last resort location (i.e. temp location)",build_loc.Data());
3426 ::Warning(
"ACLiC",
"Output will be written to %s",
3427 emergency_loc.Data());
3428 return CompileMacro(expFileName, opt, library_specified, emergency_loc, dirmode);
3432 Info(
"ACLiC",
"creating shared library %s",library.Data());
3435 R__WriteDependencyFile(build_loc, depfilename, filename_fullpath, library, libname, extension, version_var_prefix, includes, defines, incPath);
3438 TString dict = libname +
"_ACLiC_dict";
3442 static const int maxforbidden = 27;
3443 static const char *forbidden_chars[maxforbidden] =
3444 {
"+",
"-",
"*",
"/",
"&",
"%",
"|",
"^",
">",
"<",
3445 "=",
"~",
".",
"(",
")",
"[",
"]",
"!",
",",
"$",
3446 " ",
":",
"'",
"#",
"@",
"\\",
"\"" };
3447 for(
int ic = 0; ic < maxforbidden; ic++ ) {
3448 dict.ReplaceAll( forbidden_chars[ic],
"_" );
3450 if ( dict.Last(
'.')!=dict.Length()-1 ) dict.Append(
".");
3451 AssignAndDelete( dict, ConcatFileName( build_loc, dict ) );
3452 TString dicth = dict;
3453 TString dictObj = dict;
3461 AssignAndDelete( linkdef, ConcatFileName( build_loc, libname ) );
3462 linkdef +=
"_ACLiC_linkdef.h";
3463 std::ofstream linkdefFile( linkdef, std::ios::out );
3464 linkdefFile <<
"// File Automatically generated by the ROOT Script Compiler "
3466 linkdefFile << std::endl;
3467 linkdefFile <<
"#ifdef __CINT__" << std::endl;
3468 linkdefFile << std::endl;
3469 linkdefFile <<
"#pragma link C++ nestedclasses;" << std::endl;
3470 linkdefFile <<
"#pragma link C++ nestedtypedefs;" << std::endl;
3471 linkdefFile << std::endl;
3475 const char * extensions[] = {
".h",
".hh",
".hpp",
".hxx",
".hPP",
".hXX" };
3478 for (i = 0; i < 6; i++ ) {
3480 TString extra_linkdef = BaseName( libname_noext );
3481 extra_linkdef.Append(GetLinkdefSuffix());
3482 extra_linkdef.Append(extensions[i]);
3483 name = Which(incPath,extra_linkdef);
3485 if (verboseLevel>4 && withInfo) {
3486 Info(
"ACLiC",
"including extra linkdef file: %s",name);
3488 linkdefFile <<
"#include \"" << name <<
"\"" << std::endl;
3493 if (verboseLevel>5 && withInfo) {
3494 Info(
"ACLiC",
"looking for header in: %s",incPath.Data());
3496 for (i = 0; i < 6; i++ ) {
3498 TString lookup = BaseName( libname_noext );
3499 lookup.Append(extensions[i]);
3500 name = Which(incPath,lookup);
3502 linkdefFile <<
"#pragma link C++ defined_in "<<gSystem->UnixPathName(name)<<
";"<< std::endl;
3506 linkdefFile <<
"#pragma link C++ defined_in \""<<filename_fullpath <<
"\";" << std::endl;
3507 linkdefFile << std::endl;
3508 linkdefFile <<
"#endif" << std::endl;
3509 linkdefFile.close();
3513 AssignAndDelete( mapfile, ConcatFileName( build_loc, libname ) );
3514 mapfile +=
"_ACLiC_map";
3515 TString mapfilein = mapfile +
".in";
3516 TString mapfileout = mapfile +
".out";
3518 Bool_t needLoadMap = kFALSE;
3519 if (!useCxxModules) {
3520 if (gInterpreter->GetSharedLibDeps(libname) !=0 ) {
3521 gInterpreter->UnloadLibraryMap(libname);
3522 needLoadMap = kTRUE;
3526 std::ofstream mapfileStream( mapfilein, std::ios::out );
3528 TString name =
".rootmap";
3529 TString sname =
"system.rootmap";
3531 AssignAndDelete(file, ConcatFileName(TROOT::GetEtcDir(), sname) );
3532 if (gSystem->AccessPathName(file)) {
3535 AssignAndDelete(file, ConcatFileName(TROOT::GetRootSys(), sname));
3536 if (gSystem->AccessPathName(file)) {
3539 AssignAndDelete(file, ConcatFileName(TROOT::GetRootSys(), name));
3542 mapfileStream << file << std::endl;
3543 AssignAndDelete(file, ConcatFileName(gSystem->HomeDirectory(), name) );
3544 mapfileStream << file << std::endl;
3545 mapfileStream << name << std::endl;
3546 if (gInterpreter->GetRootMapFiles()) {
3547 for (i = 0; i < gInterpreter->GetRootMapFiles()->GetEntriesFast(); i++) {
3548 mapfileStream << ((TNamed*)gInterpreter->GetRootMapFiles()->At(i))->GetTitle() << std::endl;
3552 mapfileStream.close();
3555 TString rcling =
"rootcling";
3556 PrependPathName(TROOT::GetBinDir(), rcling);
3557 rcling +=
" -v0 \"--lib-list-prefix=";
3559 rcling +=
"\" -f \"";
3560 rcling.Append(dict).Append(
"\" ");
3562 if (produceRootmap && !useCxxModules) {
3563 rcling +=
" -rml " + libname +
" -rmf \"" + libmapfilename +
"\" ";
3564 rcling.Append(
"-DR__ACLIC_ROOTMAP ");
3566 rcling.Append(GetIncludePath()).Append(
" -D__ACLIC__ ");
3568 TString fromConfig = gEnv->GetValue(
"ACLiC.IncludePaths",
"");
3569 rcling.Append(fromConfig);
3574 if (useCxxModules && produceRootmap) {
3575 rcling +=
" -cxxmodule ";
3577 TString moduleName = libname +
"_ACLiC_dict";
3578 if (moduleName.BeginsWith(
"lib"))
3579 moduleName = moduleName.Remove(0, 3);
3580 TString moduleMapName = moduleName +
".modulemap";
3581 TString moduleMapFullPath = build_loc +
"/" + moduleMapName;
3583 if (verboseLevel > 3 && !AccessPathName(moduleMapFullPath))
3584 ::Info(
"ACLiC",
"File %s already exists!", moduleMapFullPath.Data());
3586 std::string curDir = ROOT::FoundationUtils::GetCurrentDir();
3587 std::string relative_path = ROOT::FoundationUtils::MakePathRelative(filename_fullpath.Data(), curDir);
3588 std::ofstream moduleMapFile(moduleMapFullPath, std::ios::out);
3589 moduleMapFile <<
"module \"" << moduleName <<
"\" {" << std::endl;
3590 moduleMapFile <<
" header \"" << relative_path <<
"\"" << std::endl;
3591 moduleMapFile <<
" export *" << std::endl;
3592 moduleMapFile <<
" link \"" << libname_ext <<
"\"" << std::endl;
3593 moduleMapFile <<
"}" << std::endl;
3594 moduleMapFile.close();
3595 gInterpreter->RegisterPrebuiltModulePath(build_loc.Data(), moduleMapName.Data());
3596 rcling.Append(
" \"-fmodule-map-file=" + moduleMapFullPath +
"\" ");
3599 rcling.Append(
" \"").Append(filename_fullpath).Append(
"\" ");
3600 rcling.Append(
"\"").Append(linkdef).Append(
"\"");
3604 if (verboseLevel>3) {
3605 ::Info(
"ACLiC",
"creating the dictionary files");
3606 if (verboseLevel>4) ::Info(
"ACLiC",
"%s", rcling.Data());
3610 Int_t dictResult = gSystem->Exec(rcling);
3612 if (dictResult==139) ::Error(
"ACLiC",
"Dictionary generation failed with a core dump!");
3613 else ::Error(
"ACLiC",
"Dictionary generation failed!");
3616 Bool_t result = !dictResult;
3617 TString depLibraries;
3621 TString linkedlibs = GetLibraries(
"",
"S");
3623 TString all_libtoload;
3624 std::ifstream liblist(mapfileout);
3626 while ( liblist >> libtoload ) {
3628 if (libtoload ==
"#") {
3630 std::string toskipcomment;
3631 std::getline(liblist,toskipcomment);
3634 if (libtoload != library && libtoload != libname && libtoload != libname_ext) {
3635 if (produceRootmap) {
3636 if (loadLib || linkDepLibraries ) {
3637 result = gROOT->LoadClass(
"", libtoload) >= 0;
3643 if (!linkedlibs.Contains(libtoload)) {
3644 all_libtoload.Append(
" ").Append(libtoload);
3645 depLibraries.Append(
" ");
3646 depLibraries.Append(GetLibraries(libtoload,
"DSL",kFALSE));
3647 depLibraries = depLibraries.Strip();
3650 gROOT->LoadClass(
"", libtoload);
3653 unsigned char c = liblist.peek();
3654 if (c==
'\n' || c==
'\r') {
3667 TString linkLibraries;
3675 TString linkLibrariesNoQuotes(GetLibraries(
"",
"SDL"));
3677 TString librariesWithQuotes;
3678 TString singleLibrary;
3679 Bool_t collectingSingleLibraryNameTokens = kFALSE;
3680 for (
auto tokenObj : *linkLibrariesNoQuotes.Tokenize(
" ")) {
3681 singleLibrary = ((TObjString*)tokenObj)->GetString();
3682 if (!AccessPathName(singleLibrary) || singleLibrary[0]==
'-') {
3683 if (collectingSingleLibraryNameTokens) {
3684 librariesWithQuotes.Chop();
3685 librariesWithQuotes +=
"\" \"" + singleLibrary +
"\"";
3686 collectingSingleLibraryNameTokens = kFALSE;
3688 librariesWithQuotes +=
" \"" + singleLibrary +
"\"";
3691 if (collectingSingleLibraryNameTokens) {
3692 librariesWithQuotes += singleLibrary +
" ";
3694 collectingSingleLibraryNameTokens = kTRUE;
3695 librariesWithQuotes +=
" \"" + singleLibrary +
" ";
3701 linkLibraries.Prepend(linkLibrariesNoQuotes);
3703 linkLibraries.Prepend(librariesWithQuotes);
3707 TString cmd = fMakeSharedLib;
3710 cmd.ReplaceAll(
"$SourceFiles",
"-D__ACLIC__ \"$SourceFiles\"");
3711 cmd.ReplaceAll(
"$SourceFiles",dict);
3712 cmd.ReplaceAll(
"$ObjectFiles",
"\"$ObjectFiles\"");
3713 cmd.ReplaceAll(
"$ObjectFiles",dictObj);
3714 cmd.ReplaceAll(
"$IncludePath",includes);
3715 cmd.ReplaceAll(
"$SharedLib",
"\"$SharedLib\"");
3716 cmd.ReplaceAll(
"$SharedLib",library);
3717 if (linkDepLibraries) {
3718 if (produceRootmap) {
3719 cmd.ReplaceAll(
"$DepLibs",depLibraries);
3721 cmd.ReplaceAll(
"$DepLibs",linkLibraries);
3724 cmd.ReplaceAll(
"$LinkedLibs",linkLibraries);
3725 cmd.ReplaceAll(
"$LibName",libname);
3726 cmd.ReplaceAll(
"\"$BuildDir",
"$BuildDir");
3727 cmd.ReplaceAll(
"$BuildDir",
"\"$BuildDir\"");
3728 cmd.ReplaceAll(
"$BuildDir",build_loc);
3730 cmd.ReplaceAll(
"$Opt",fFlagsDebug);
3732 cmd.ReplaceAll(
"$Opt",fFlagsOpt);
3736 cmd.ReplaceAll(
"-std=",
"-std:");
3739 TString testcmd = fMakeExe;
3741 AssignAndDelete( fakeMain, ConcatFileName( build_loc, libname ) );
3742 fakeMain +=
"_ACLiC_main";
3743 fakeMain += extension;
3744 std::ofstream fakeMainFile( fakeMain, std::ios::out );
3745 fakeMainFile <<
"// File Automatically generated by the ROOT Script Compiler "
3747 fakeMainFile <<
"int main(char*argc,char**argvv) {};" << std::endl;
3748 fakeMainFile.close();
3758 AssignAndDelete( exec, ConcatFileName( build_loc, libname ) );
3759 exec +=
"_ACLiC_exec";
3760 testcmd.ReplaceAll(
"$SourceFiles",
"-D__ACLIC__ \"$SourceFiles\"");
3761 testcmd.ReplaceAll(
"$SourceFiles",dict);
3762 testcmd.ReplaceAll(
"$ObjectFiles",
"\"$ObjectFiles\"");
3763 testcmd.ReplaceAll(
"$ObjectFiles",dictObj);
3764 testcmd.ReplaceAll(
"$IncludePath",includes);
3765 testcmd.ReplaceAll(
"$ExeName",exec);
3766 testcmd.ReplaceAll(
"$LinkedLibs",linkLibraries);
3767 testcmd.ReplaceAll(
"$BuildDir",build_loc);
3769 testcmd.ReplaceAll(
"$Opt",fFlagsDebug);
3771 testcmd.ReplaceAll(
"$Opt",fFlagsOpt);
3774 R__FixLink(testcmd);
3775 testcmd.ReplaceAll(
"-std=",
"-std:");
3780 if (verboseLevel>3 && withInfo) {
3781 ::Info(
"ACLiC",
"compiling the dictionary and script files");
3782 if (verboseLevel>4) ::Info(
"ACLiC",
"%s", cmd.Data());
3784 Int_t compilationResult = gSystem->Exec( cmd );
3785 if (compilationResult) {
3786 if (compilationResult==139) ::Error(
"ACLiC",
"Compilation failed with a core dump!");
3787 else ::Error(
"ACLiC",
"Compilation failed!");
3788 if (produceRootmap) {
3789 gSystem->Unlink(libmapfilename);
3792 result = !compilationResult;
3797 TNamed *k =
new TNamed(library,library);
3799 gSystem->GetPathInfo( library, 0, (Long_t*)0, 0, &lib_time );
3800 k->SetUniqueID(lib_time);
3801 if (!keep) k->SetBit(kMustCleanup);
3805 gInterpreter->LoadLibraryMap(libmapfilename);
3807 if (verboseLevel>3 && withInfo) ::Info(
"ACLiC",
"loading the shared library");
3809 result = LoadLibrary(library);
3814 if (verboseLevel>3 && withInfo) {
3815 ::Info(
"ACLiC",
"testing for missing symbols:");
3816 if (verboseLevel>4) ::Info(
"ACLiC",
"%s", testcmd.Data());
3818 gSystem->Exec(testcmd);
3819 gSystem->Unlink( exec );
3824 if (verboseLevel<=5 && !internalDebug) {
3825 gSystem->Unlink( dict );
3826 gSystem->Unlink( dicth );
3827 gSystem->Unlink( dictObj );
3828 gSystem->Unlink( linkdef );
3829 gSystem->Unlink( mapfilein );
3830 gSystem->Unlink( mapfileout );
3831 gSystem->Unlink( fakeMain );
3832 gSystem->Unlink( exec );
3834 if (verboseLevel>6) {
3835 rcling.Prepend(
"echo ");
3836 cmd.Prepend(
"echo \" ").Append(
" \" ");
3837 testcmd.Prepend(
"echo \" ").Append(
" \" ");
3838 gSystem->Exec(rcling);
3839 gSystem->Exec( cmd );
3840 gSystem->Exec(testcmd);
3850 Int_t TSystem::GetAclicProperties()
const
3852 return fAclicProperties;
3858 const char *TSystem::GetBuildArch()
const
3866 const char *TSystem::GetBuildCompiler()
const
3868 return fBuildCompiler;
3874 const char *TSystem::GetBuildCompilerVersion()
const
3876 return fBuildCompilerVersion;
3882 const char *TSystem::GetBuildNode()
const
3890 const char *TSystem::GetBuildDir()
const
3892 if (fBuildDir.Length()==0) {
3893 if (!gEnv)
return "";
3894 const_cast<TSystem*
>(
this)->fBuildDir = gEnv->GetValue(
"ACLiC.BuildDir",
"");
3902 const char *TSystem::GetFlagsDebug()
const
3910 const char *TSystem::GetFlagsOpt()
const
3922 TSystem::EAclicMode TSystem::GetAclicMode()
const
3931 const char *TSystem::GetMakeSharedLib()
const
3933 return fMakeSharedLib;
3940 const char *TSystem::GetMakeExe()
const
3948 const char *TSystem::GetIncludePath()
3950 fListPaths = fIncludePath;
3958 fListPaths.Append(
" ").Append(gInterpreter->GetIncludePath());
3967 const char *TSystem::GetLinkedLibs()
const
3976 const char *TSystem::GetLinkdefSuffix()
const
3978 if (fLinkdefSuffix.Length()==0) {
3979 if (!gEnv)
return "_linkdef";
3980 const_cast<TSystem*
>(
this)->fLinkdefSuffix = gEnv->GetValue(
"ACLiC.Linkdef",
"_linkdef");
3982 return fLinkdefSuffix;
3988 const char *TSystem::GetSoExt()
const
3996 const char *TSystem::GetObjExt()
const
4014 void TSystem::SetBuildDir(
const char* build_dir, Bool_t isflat)
4016 fBuildDir = build_dir;
4017 if (isflat) fAclicProperties |= (kFlatBuildDir & kBitMask);
4018 else fAclicProperties &= ~(kFlatBuildDir & kBitMask);
4025 void TSystem::SetFlagsDebug(
const char *flags)
4027 fFlagsDebug = flags;
4034 void TSystem::SetFlagsOpt(
const char *flags)
4046 void TSystem::SetAclicMode(EAclicMode mode)
4062 void TSystem::SetMakeExe(
const char *directives)
4064 fMakeExe = directives;
4114 void TSystem::SetMakeSharedLib(
const char *directives)
4116 fMakeSharedLib = directives;
4126 void TSystem::AddIncludePath(
const char *includePath)
4129 fIncludePath +=
" ";
4130 fIncludePath += includePath;
4137 void TSystem::AddLinkedLibs(
const char *linkedLib)
4141 fLinkedLibs += linkedLib;
4161 void TSystem::SetIncludePath(
const char *includePath)
4163 fIncludePath = includePath;
4172 void TSystem::SetLinkedLibs(
const char *linkedLibs)
4174 fLinkedLibs = linkedLibs;
4194 void TSystem::SetLinkdefSuffix(
const char *suffix)
4196 fLinkdefSuffix = suffix;
4203 void TSystem::SetSoExt(
const char *SoExt)
4211 void TSystem::SetObjExt(
const char *ObjExt)
4225 TString TSystem::SplitAclicMode(
const char* filename, TString &aclicMode,
4226 TString &arguments, TString &io)
const
4228 char *fname = Strip(filename);
4229 TString filenameCopy = fname;
4230 filenameCopy = filenameCopy.Strip();
4232 if (filenameCopy.EndsWith(
";")) {
4233 filenameCopy.Remove(filenameCopy.Length() - 1);
4234 filenameCopy = filenameCopy.Strip();
4236 if (filenameCopy.EndsWith(
")")) {
4237 Ssiz_t posArgEnd = filenameCopy.Length() - 1;
4239 int parenNestCount = 1;
4240 bool inString =
false;
4241 Ssiz_t posArgBegin = posArgEnd - 1;
4242 for (; parenNestCount && posArgBegin >= 0; --posArgBegin) {
4245 if (posArgBegin > 0 && filenameCopy[posArgBegin] ==
'\\' &&
4246 (posArgBegin == 1 || filenameCopy[posArgBegin - 1] !=
'\\')) {
4251 switch (filenameCopy[posArgBegin]) {
4260 case '"': inString = !inString;
break;
4263 if (parenNestCount || inString) {
4264 Error(
"SplitAclicMode",
"Cannot parse argument in %s", filename);
4266 arguments = filenameCopy(posArgBegin + 1, posArgEnd - 1);
4267 fname[posArgBegin + 1] = 0;
4275 s2 = strstr(fname,
">>");
4276 if (!s2) s2 = strstr(fname,
"2>");
4277 if (!s2) s2 = strchr(fname,
'>');
4278 s3 = strchr(fname,
'<');
4279 if (s2 && s3) s2 = s2<s3 ? s2 : s3;
4280 if (s3 && !s2) s2 = s3;
4289 while (s2 && *s2 ==
' ') s2--;
4299 int len = strlen(fname);
4302 if (strchr(
"kfgOcsdv-", fname[len - 1])) {
4303 mode += fname[len - 1];
4309 Bool_t compile = len && fname[len - 1] ==
'+';
4310 Bool_t
remove = compile && len > 1 && fname[len - 2] ==
'+';
4312 if (mode.Length()) {
4316 fname[strlen(fname)-2] = 0;
4319 fname[strlen(fname)-1] = 0;
4326 TString resFilename = fname;
4335 void TSystem::CleanCompiledMacros()
4337 TIter next(fCompiled);
4339 while ((lib = (TNamed*)next())) {
4340 if (lib->TestBit(kMustCleanup)) Unlink(lib->GetTitle());
4347 TVersionCheck::TVersionCheck(
int versionCode)
4349 if (versionCode != TROOT::RootVersionCode() && gLibraryVersion)
4350 gLibraryVersion[gLibraryVersionIdx] = versionCode;