mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user