Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions core/dictgen/res/rootcling_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ namespace RootCling {
void (*fAddEnumToROOTFile)(const char *tdname) = nullptr;
bool (*fCloseStreamerInfoROOTFile)(bool writeEmptyRootPCM) = nullptr;
};

struct TROOTSYSSetter {
TROOTSYSSetter();
};
} // namespace RootCling
} // namespace Internal
} // namespace ROOT
Expand Down
76 changes: 0 additions & 76 deletions core/dictgen/src/rootcling_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,6 @@ static llvm::cl::OptionCategory gRootclingOptions("rootcling common options");

////////////////////////////////////////////////////////////////////////////////

void SetRootSys();

ROOT::Internal::RootCling::TROOTSYSSetter::TROOTSYSSetter() {
// rootcling's libCore needs "our" ROOTSYS:
SetRootSys();
};

////////////////////////////////////////////////////////////////////////////////

void EmitStreamerInfo(const char *normName)
{
if (gDriverConfig->fAddStreamerInfoToROOTFile)
Expand Down Expand Up @@ -469,73 +460,6 @@ bool IsSelectionFile(const char *filename)
return ROOT::TMetaUtils::IsLinkdefFile(filename) || IsSelectionXml(filename);
}

////////////////////////////////////////////////////////////////////////////////
/// Set the ROOTSYS env var based on the executable location.

void SetRootSys()
{
const char *exepath = GetExePath();
if (exepath && *exepath) {
#if !defined(_WIN32)
char *ep = new char[PATH_MAX];
if (!realpath(exepath, ep)) {
fprintf(stderr, "rootcling: error getting realpath of rootcling!");
strlcpy(ep, exepath, PATH_MAX);
}
#else
int nche = strlen(exepath) + 1;
char *ep = new char[nche];
strlcpy(ep, exepath, nche);
#endif
char *s;

if ((s = strrchr(ep, '/'))) {
// $ROOTSYS/bin/rootcling
int removesubdirs = 2;
if (!strncmp(s + 1, "rootcling_stage1.exe", 20)) {
// $ROOTSYS/bin/rootcling_stage1.exe
removesubdirs = 2;
gBuildingROOT = true;
} else if (!strncmp(s + 1, "rootcling_stage1", 16)) {
// $ROOTSYS/core/rootcling_stage1/src/rootcling_stage1
removesubdirs = 4;
gBuildingROOT = true;
}
for (int i = 1; s && i < removesubdirs; ++i) {
*s = 0;
s = strrchr(ep, '/');
}
if (s) *s = 0;
} else {
// There was no slashes at all let now change ROOTSYS
delete [] ep;
return;
}

if (!gBuildingROOT) {
delete [] ep;
return; // don't mess with user's ROOTSYS.
}

int ncha = strlen(ep) + 10;
char *env = new char[ncha];
snprintf(env, ncha, "ROOTSYS=%s", ep);

if (gDriverConfig) {
// After the putenv below, gRootDir might point to the old ROOTSYS
// entry, i.e. to deleted memory. Update it.
const char** pRootDir = gDriverConfig->fPRootDir;
if (pRootDir) {
*pRootDir = env + 8;
}
}

putenv(env);
// intentionally not call delete [] env, while GLIBC keep use pointer
delete [] ep;
}
}

////////////////////////////////////////////////////////////////////////////////
/// Check whether the `#pragma` line contains expectedTokens (0-terminated array).

Expand Down
1 change: 1 addition & 0 deletions core/rootcling_stage1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ROOT_EXECUTABLE(rootcling_stage1 src/rootcling_stage1.cxx
$<TARGET_OBJECTS:Foundation_Stage1>
LIBRARIES ${CLING_LIBRARIES} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${ROOT_ATOMIC_LIBS}
NOINSTALL)
target_compile_options(rootcling_stage1 PRIVATE -DCMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}")

target_include_directories(rootcling_stage1 PRIVATE
${CMAKE_SOURCE_DIR}/core/foundation/inc # for RConfig.hxx
Expand Down
12 changes: 2 additions & 10 deletions core/rootcling_stage1/src/rootcling_stage1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,13 @@ extern "C" {
// force compiler to emit symbol for function above
static void (*dlsymaddr)() = &usedToIdentifyRootClingByDlSym;

ROOT::Internal::RootCling::TROOTSYSSetter gROOTSYSSetter;

static const char *GetIncludeDir() {
auto renv = std::getenv("ROOTSYS");
if (!renv)
return nullptr;
static std::string incdir = std::string(renv) + "/include";
static std::string incdir = CMAKE_BINARY_DIR "/include";
return incdir.c_str();
}

static const char *GetEtcDir() {
auto renv = std::getenv("ROOTSYS");
if (!renv)
return nullptr;
static std::string etcdir = std::string(renv) + "/etc";
static std::string etcdir = CMAKE_BINARY_DIR "/etc";
return etcdir.c_str();
}

Expand Down
Loading