mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: compile codedFixedValueFvPatchScalarField into local directory only
This commit is contained in:
@ -106,7 +106,7 @@ bool Foam::functionEntries::codeStream::execute
|
|||||||
// "code" is mandatory
|
// "code" is mandatory
|
||||||
string code = stringOps::trimLeft(codeDict["code"]);
|
string code = stringOps::trimLeft(codeDict["code"]);
|
||||||
|
|
||||||
// Create name from the contents
|
// Create SHA1 digest from the contents
|
||||||
SHA1Digest sha;
|
SHA1Digest sha;
|
||||||
{
|
{
|
||||||
OSHA1stream os;
|
OSHA1stream os;
|
||||||
@ -196,7 +196,9 @@ bool Foam::functionEntries::codeStream::execute
|
|||||||
// Write Make/options
|
// Write Make/options
|
||||||
filesContents[1].first() = "Make/options";
|
filesContents[1].first() = "Make/options";
|
||||||
filesContents[1].second() =
|
filesContents[1].second() =
|
||||||
"EXE_INC = -g \\\n" + codeOptions + "\n\nLIB_LIBS =";
|
"EXE_INC = -g \\\n"
|
||||||
|
+ codeOptions
|
||||||
|
+ "\n\nLIB_LIBS =";
|
||||||
|
|
||||||
codeStreamTools writer(codeName, copyFiles, filesContents);
|
codeStreamTools writer(codeName, copyFiles, filesContents);
|
||||||
if (!writer.copyFilesContents(codeDir))
|
if (!writer.copyFilesContents(codeDir))
|
||||||
@ -225,8 +227,8 @@ bool Foam::functionEntries::codeStream::execute
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dummy = true;
|
// bool dummy = true;
|
||||||
reduce(dummy, orOp<bool>());
|
// reduce(dummy, orOp<bool>());
|
||||||
|
|
||||||
if (!dlLibraryTable::open(libPath, false))
|
if (!dlLibraryTable::open(libPath, false))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -29,7 +29,7 @@ Description
|
|||||||
generate the entry itself. So
|
generate the entry itself. So
|
||||||
- codeStream reads three entries: 'code', 'codeInclude' (optional),
|
- codeStream reads three entries: 'code', 'codeInclude' (optional),
|
||||||
'codeOptions' (optional)
|
'codeOptions' (optional)
|
||||||
and uses those to generate library sources inside \f constant/codeStream/
|
and uses those to generate library sources inside \f codeStream/
|
||||||
- these get compiled using 'wmake libso'
|
- these get compiled using 'wmake libso'
|
||||||
- the resulting library is loaded in executed with as arguments
|
- the resulting library is loaded in executed with as arguments
|
||||||
\code
|
\code
|
||||||
@ -123,7 +123,7 @@ public:
|
|||||||
// Static data members
|
// Static data members
|
||||||
|
|
||||||
//- Name of the C code template to be used
|
//- Name of the C code template to be used
|
||||||
const static word codeTemplateC;
|
static const word codeTemplateC;
|
||||||
|
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
|
|||||||
@ -113,15 +113,15 @@ public:
|
|||||||
|
|
||||||
//- Name of the code template environment variable
|
//- Name of the code template environment variable
|
||||||
// Used to located the codeTemplateName
|
// Used to located the codeTemplateName
|
||||||
const static word codeTemplateEnvName;
|
static const word codeTemplateEnvName;
|
||||||
|
|
||||||
//- Name of the code template sub-directory
|
//- Name of the code template sub-directory
|
||||||
// Used when locating the codeTemplateName via Foam::findEtcFile
|
// Used when locating the codeTemplateName via Foam::findEtcFile
|
||||||
const static fileName codeTemplateDirName;
|
static const fileName codeTemplateDirName;
|
||||||
|
|
||||||
|
|
||||||
static int allowSystemOperations;
|
static int allowSystemOperations;
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
|
|||||||
@ -79,7 +79,7 @@ public:
|
|||||||
modified_ = false;
|
modified_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Read the solution dictionary
|
//- Read the dictionary
|
||||||
virtual bool read();
|
virtual bool read();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -32,6 +32,8 @@ License
|
|||||||
#include "dlLibraryTable.H"
|
#include "dlLibraryTable.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
|
#include "SHA1Digest.H"
|
||||||
|
#include "OSHA1stream.H"
|
||||||
#include "codeStreamTools.H"
|
#include "codeStreamTools.H"
|
||||||
#include "codeProperties.H"
|
#include "codeProperties.H"
|
||||||
#include "stringOps.H"
|
#include "stringOps.H"
|
||||||
@ -78,7 +80,7 @@ Foam::codedFixedValueFvPatchScalarField::dict() const
|
|||||||
|
|
||||||
void Foam::codedFixedValueFvPatchScalarField::writeLibrary
|
void Foam::codedFixedValueFvPatchScalarField::writeLibrary
|
||||||
(
|
(
|
||||||
const fileName& dir,
|
const fileName& codeDir,
|
||||||
const fileName& libPath,
|
const fileName& libPath,
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
@ -106,25 +108,22 @@ void Foam::codedFixedValueFvPatchScalarField::writeLibrary
|
|||||||
// "code" is mandatory
|
// "code" is mandatory
|
||||||
string code = stringOps::trimLeft(dict["code"]);
|
string code = stringOps::trimLeft(dict["code"]);
|
||||||
|
|
||||||
|
// Create SHA1 digest from the contents
|
||||||
|
SHA1Digest sha;
|
||||||
|
{
|
||||||
|
OSHA1stream os;
|
||||||
|
os << codeInclude << codeOptions << code;
|
||||||
|
sha = os.digest();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!codeStreamTools::upToDate(codeDir, sha))
|
||||||
|
{
|
||||||
Info<< "Creating new library in " << libPath << endl;
|
Info<< "Creating new library in " << libPath << endl;
|
||||||
|
|
||||||
const fileName fileCsrc
|
const fileName fileCsrc(codeStreamTools::findTemplate(codeTemplateC));
|
||||||
(
|
const fileName fileHsrc(codeStreamTools::findTemplate(codeTemplateH));
|
||||||
codeStreamTools::findTemplate
|
|
||||||
(
|
|
||||||
codeTemplateC
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
const fileName fileHsrc
|
|
||||||
(
|
|
||||||
codeStreamTools::findTemplate
|
|
||||||
(
|
|
||||||
codeTemplateH
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
// not found!
|
||||||
if (fileCsrc.empty() || fileHsrc.empty())
|
if (fileCsrc.empty() || fileHsrc.empty())
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
@ -153,17 +152,19 @@ void Foam::codedFixedValueFvPatchScalarField::writeLibrary
|
|||||||
filesContents[0].first() = "Make/files";
|
filesContents[0].first() = "Make/files";
|
||||||
filesContents[0].second() =
|
filesContents[0].second() =
|
||||||
codeTemplateC + "\n\n"
|
codeTemplateC + "\n\n"
|
||||||
"LIB = $(FOAM_USER_LIBBIN)/lib" + redirectType_;
|
"LIB = $(PWD)/../platforms/$(WM_OPTIONS)/lib/lib"
|
||||||
|
+ redirectType_;
|
||||||
|
|
||||||
// Write Make/options
|
// Write Make/options
|
||||||
filesContents[1].first() = "Make/options";
|
filesContents[1].first() = "Make/options";
|
||||||
filesContents[1].second() =
|
filesContents[1].second() =
|
||||||
"EXE_INC = -g \\\n-I$(LIB_SRC)/finiteVolume/lnInclude\\\n"
|
"EXE_INC = -g \\\n"
|
||||||
|
"-I$(LIB_SRC)/finiteVolume/lnInclude\\\n"
|
||||||
+ codeOptions
|
+ codeOptions
|
||||||
+ "\n\nLIB_LIBS = ";
|
+ "\n\nLIB_LIBS = ";
|
||||||
|
|
||||||
codeStreamTools writer(redirectType_, copyFiles, filesContents);
|
codeStreamTools writer(redirectType_, copyFiles, filesContents);
|
||||||
if (!writer.copyFilesContents(dir))
|
if (!writer.copyFilesContents(codeDir))
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
@ -174,6 +175,7 @@ void Foam::codedFixedValueFvPatchScalarField::writeLibrary
|
|||||||
<< filesContents
|
<< filesContents
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -192,17 +194,31 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
|
|||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileName dir =
|
// local directory for compile/link
|
||||||
db().time().constantPath()/"codeStream"/redirectType_;
|
const fileName baseDir
|
||||||
//Info<< "dir:" << dir << endl;
|
(
|
||||||
|
stringOps::expandEnv("$FOAM_CASE/codeStream")
|
||||||
|
);
|
||||||
|
|
||||||
|
// code is written into redirectType_ subdir
|
||||||
|
const fileName codeDir
|
||||||
|
(
|
||||||
|
baseDir
|
||||||
|
/ redirectType_
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//Info<< "codeDir:" << codeDir << endl;
|
||||||
|
|
||||||
|
// library is written into platforms/$WM_OPTIONS/lib subdir
|
||||||
const fileName libPath
|
const fileName libPath
|
||||||
(
|
(
|
||||||
Foam::getEnv("FOAM_USER_LIBBIN")
|
baseDir
|
||||||
/ "lib"
|
/ stringOps::expandEnv("platforms/$WM_OPTIONS/lib")
|
||||||
+ redirectType_
|
/ "lib" + redirectType_ + ".so"
|
||||||
+ ".so"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//Info<< "libPath:" << libPath << endl;
|
//Info<< "libPath:" << libPath << endl;
|
||||||
|
|
||||||
void* lib = dlLibraryTable::findLibrary(libPath);
|
void* lib = dlLibraryTable::findLibrary(libPath);
|
||||||
@ -211,7 +227,7 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
|
|||||||
{
|
{
|
||||||
if (!lib)
|
if (!lib)
|
||||||
{
|
{
|
||||||
writeLibrary(dir, libPath, dict_);
|
writeLibrary(codeDir, libPath, dict_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -240,7 +256,7 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dictionary& codeDict = onTheFlyDict.subDict(redirectType_);
|
const dictionary& codeDict = onTheFlyDict.subDict(redirectType_);
|
||||||
writeLibrary(dir, libPath, codeDict);
|
writeLibrary(codeDir, libPath, codeDict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +264,7 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
|
|||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
const Foam::string wmakeCmd("wmake libso " + dir);
|
const Foam::string wmakeCmd("wmake libso " + codeDir);
|
||||||
Info<< "Invoking " << wmakeCmd << endl;
|
Info<< "Invoking " << wmakeCmd << endl;
|
||||||
if (Foam::system(wmakeCmd))
|
if (Foam::system(wmakeCmd))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user