Skip to content

Commit

Permalink
Merge pull request #21966 from wddgit/modifyFileInPath
Browse files Browse the repository at this point in the history
Modify FileInPath to not lookup file in edmWriteConfigs
  • Loading branch information
cmsbuild committed Jan 26, 2018
2 parents 0948330 + 506abcd commit 985517e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions FWCore/ParameterSet/bin/edmWriteConfigs.cpp
Expand Up @@ -29,6 +29,7 @@
#include "FWCore/Utilities/interface/TimeOfDay.h"
#include "FWCore/PluginManager/interface/PluginManager.h"
#include "FWCore/PluginManager/interface/standard.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescriptionFillerPluginFactory.h"
#include "FWCore/Utilities/interface/Algorithms.h"
#include "FWCore/PluginManager/interface/PluginInfo.h"
Expand Down Expand Up @@ -141,6 +142,9 @@ namespace {

int main (int argc, char **argv)
try {

edm::FileInPath::disableFileLookup();

using std::placeholders::_1;
boost::filesystem::path initialWorkingDirectory =
boost::filesystem::initial_path<boost::filesystem::path>();
Expand Down
4 changes: 4 additions & 0 deletions FWCore/ParameterSet/interface/FileInPath.h
Expand Up @@ -116,6 +116,10 @@ namespace edm
void read(std::istream& is);

void readFromParameterSetBlob(std::istream& is);

/// Should only be called while the edmWriteConfigs executable runs
static void disableFileLookup();

private:
std::string relativePath_;
std::string canonicalFilename_;
Expand Down
21 changes: 19 additions & 2 deletions FWCore/ParameterSet/src/FileInPath.cc
@@ -1,6 +1,7 @@
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

#include <atomic>
#include <cstdlib>
#include <vector>
#include "boost/filesystem/path.hpp"
Expand All @@ -15,9 +16,12 @@ namespace bf = boost::filesystem;

namespace
{

std::atomic<bool> s_fileLookupDisabled{false};

/// These are the names of the environment variables which control
/// the behavior of the FileInPath class. They are local to this
/// class; other code should not even know about them!
/// the behavior of the FileInPath class. They are local to this
/// class; other code should not even know about them!

const std::string PathVariableName("CMSSW_SEARCH_PATH");
// Environment variables for local and release areas:
Expand Down Expand Up @@ -111,6 +115,9 @@ namespace edm
canonicalFilename_(),
location_(Unknown)
{
if (s_fileLookupDisabled) {
return;
}
getEnvironment();
}

Expand All @@ -119,6 +126,9 @@ namespace edm
canonicalFilename_(),
location_(Unknown)
{
if (s_fileLookupDisabled) {
return;
}
getEnvironment();
initialize_();
}
Expand All @@ -128,6 +138,9 @@ namespace edm
canonicalFilename_(),
location_(Unknown)
{
if (s_fileLookupDisabled) {
return;
}
if(r == nullptr) {
throw edm::Exception(edm::errors::FileInPathError) << "Relative path must not be null\n";
}
Expand Down Expand Up @@ -508,5 +521,9 @@ namespace edm
<< "\n";
}

void FileInPath::disableFileLookup() {
s_fileLookupDisabled = true;
}

}

0 comments on commit 985517e

Please sign in to comment.