ENH: exposed access to compile-time project, etc directories
- less frequently used, but the information was previously inaccessible under etcFiles.C. Now exposed within the foamVersion namespace and defined under <global.Cver> to improve configuration possibilities.
This commit is contained in:
parent
6a16db3708
commit
435957ac87
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,14 +35,15 @@ Description
|
||||
|
||||
#include "argList.H"
|
||||
#include "etcFiles.H"
|
||||
#include "foamVersion.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
void printList(const fileNameList& list)
|
||||
{
|
||||
forAll(list, i)
|
||||
for (const fileName& f : list)
|
||||
{
|
||||
Info<< list[i].c_str() << nl;
|
||||
Info<< f.c_str() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,6 +57,11 @@ int main(int argc, char *argv[])
|
||||
argList::noFunctionObjects();
|
||||
argList::removeOption("case");
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"config",
|
||||
"Print compile-time configuration values"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"all",
|
||||
@ -69,7 +75,7 @@ int main(int argc, char *argv[])
|
||||
argList::addBoolOption
|
||||
(
|
||||
"list-all",
|
||||
"List all directories (including non-existence ones)"
|
||||
"List all directories (including non-existent ones)"
|
||||
);
|
||||
argList::addArgument("file...");
|
||||
|
||||
@ -84,7 +90,13 @@ int main(int argc, char *argv[])
|
||||
// First handle no parameters
|
||||
if (args.size() == 1)
|
||||
{
|
||||
if (args.found("list-all"))
|
||||
if (args.found("config"))
|
||||
{
|
||||
Info<<"config:project=" << foamVersion::configuredProjectDir << nl;
|
||||
Info<<"config:etc=" << foamVersion::configuredEtcDir << nl;
|
||||
return 0;
|
||||
}
|
||||
else if (args.found("list-all"))
|
||||
{
|
||||
fileNameList results = etcDirs(false);
|
||||
printList(results);
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,14 +30,6 @@ License
|
||||
#include "foamVersion.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// Note contains handling for compile-time configuration of some paths
|
||||
// via defines:
|
||||
// - FOAM_CONFIGURED_PROJECT_DIR
|
||||
// - FOAM_CONFIGURED_PROJECT_ETC
|
||||
|
||||
// Eg,
|
||||
// #define FOAM_CONFIGURED_PROJECT_ETC "/usr/share/openfoam/etc"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Functions * * * * * * * * * * * * * * //
|
||||
|
||||
//
|
||||
@ -151,14 +143,11 @@ static inline bool groupResourceDir(Foam::fileName& queried)
|
||||
#endif
|
||||
|
||||
// Compile-time paths
|
||||
|
||||
#ifdef FOAM_CONFIGURED_PROJECT_DIR
|
||||
queried = FOAM_CONFIGURED_PROJECT_DIR/Foam::string("site/etc");
|
||||
queried = Foam::foamVersion::configuredProjectDir/Foam::string("site/etc");
|
||||
if (queried.size() > 8 && Foam::isDir(queried))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
queried.clear();
|
||||
return false;
|
||||
@ -186,21 +175,17 @@ static inline bool projectResourceDir(Foam::fileName& queried)
|
||||
|
||||
// Compile-time paths
|
||||
|
||||
#ifdef FOAM_CONFIGURED_PROJECT_ETC
|
||||
queried = FOAM_CONFIGURED_PROJECT_ETC;
|
||||
queried = Foam::foamVersion::configuredEtcDir;
|
||||
if (Foam::isDir(queried))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FOAM_CONFIGURED_PROJECT_DIR
|
||||
queried = FOAM_CONFIGURED_PROJECT_DIR/Foam::word("etc");
|
||||
queried = Foam::foamVersion::configuredProjectDir/Foam::word("etc");
|
||||
if (queried.size() > 3 && Foam::isDir(queried))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
queried.clear();
|
||||
return false;
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -68,28 +68,28 @@ static inline unsigned getTaggedSize(const char* tag, const std::string& s)
|
||||
|
||||
// Value of OPENFOAM defined in wmake rules
|
||||
const int Foam::foamVersion::api
|
||||
(
|
||||
{
|
||||
OPENFOAM
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// Value of PATCH generated by the build-script
|
||||
const std::string Foam::foamVersion::patch
|
||||
(
|
||||
{
|
||||
"@PATCH@"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// Value of BUILD generated by the build-script
|
||||
const std::string Foam::foamVersion::build
|
||||
(
|
||||
{
|
||||
"@BUILD@"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// Information about machine endian, label and scalar sizes
|
||||
const std::string Foam::foamVersion::buildArch
|
||||
(
|
||||
{
|
||||
#ifdef WM_LITTLE_ENDIAN
|
||||
"LSB"
|
||||
#elif defined (WM_BIG_ENDIAN)
|
||||
@ -103,15 +103,15 @@ const std::string Foam::foamVersion::buildArch
|
||||
#ifdef WM_SPDP
|
||||
+ ";solveScalar=" + std::to_string(8*sizeof(Foam::solveScalar))
|
||||
#endif
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// Value of VERSION generated by the build-script
|
||||
// Only required for compatibility
|
||||
const std::string Foam::foamVersion::version
|
||||
(
|
||||
{
|
||||
"@VERSION@"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
unsigned Foam::foamVersion::labelByteSize(const std::string& str)
|
||||
@ -126,6 +126,22 @@ unsigned Foam::foamVersion::scalarByteSize(const std::string& str)
|
||||
}
|
||||
|
||||
|
||||
const std::string Foam::foamVersion::configuredProjectDir
|
||||
{
|
||||
#ifdef FOAM_CONFIGURED_PROJECT_DIR
|
||||
FOAM_CONFIGURED_PROJECT_DIR
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
const std::string Foam::foamVersion::configuredEtcDir
|
||||
{
|
||||
#ifdef FOAM_CONFIGURED_PROJECT_ETC
|
||||
FOAM_CONFIGURED_PROJECT_ETC
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Setup an error handler for the global new operator
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,6 +36,15 @@ Note
|
||||
directory for easier use by external packages and to allow easier
|
||||
modification during packaging.
|
||||
|
||||
Provisions for compile-time configuration of some paths
|
||||
- FOAM_CONFIGURED_PROJECT_DIR
|
||||
- FOAM_CONFIGURED_PROJECT_ETC
|
||||
|
||||
For example,
|
||||
\verbatim
|
||||
FOAM_EXTRA_CXXFLAGS='-DFOAM_CONFIGURED_PROJECT_ETC=\"/etc/openfoam\"'
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
foamVersion.C
|
||||
global.Cver
|
||||
@ -115,6 +124,14 @@ namespace Foam
|
||||
//
|
||||
// \param full includes Arch information
|
||||
void printBuildInfo(const bool full=true);
|
||||
|
||||
//- Compile-time definition of the OpenFOAM project directory
|
||||
// Usually not defined - functional equivalent to WM_PROJECT_DIR
|
||||
extern const std::string configuredProjectDir;
|
||||
|
||||
//- Compile-time definition of the OpenFOAM etc/ directory
|
||||
// Usually not defined - functional equivalent to WM_PROJECT_DIR/etc
|
||||
extern const std::string configuredEtcDir;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user