Skip to content

Commit 64a3cd0

Browse files
authored
Build info fixup (#54)
* added build flags to enable optional git information from Allwmake, and added AdditivefoamInfo class to write information to log * fixup: removed .nfs file * fixup: added undefined to git info in Allwmake for shell failure
1 parent cb831c5 commit 64a3cd0

File tree

5 files changed

+72
-29
lines changed

5 files changed

+72
-29
lines changed

applications/solvers/additiveFoam/Allwclean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
cd ${0%/*} || exit 1 # Run from this directory
33

4-
rm -rf Make/additiveFoamVersion.H
4+
rm -rf Make/gitInfo.H
55

66
wclean libso functionObjects/ExaCA
77
wclean libso movingHeatSource

applications/solvers/additiveFoam/Allwmake

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@ cd ${0%/*} || exit 1 # Run from this directory
55
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
66

77
#------------------------------------------------------------------------------
8-
# Generate AdditiveFOAM version header
9-
HEADER_FILE="${0%/*}/Make/additiveFoamVersion.H"
8+
# Generate header for git information
9+
HEADER_FILE="${0%/*}/Make/gitInfo.H"
1010
GIT_DESCRIBE=$(git describe --tags --always 2>/dev/null) || GIT_DESCRIBE="undefined"
1111
GIT_SHA1=$(git rev-parse HEAD 2>/dev/null) || GIT_SHA1="undefined"
12-
STATIC_VERSION="1.1.0-dev"
1312

1413
cat > "$HEADER_FILE" << EOF
15-
#ifndef AdditiveFOAMVersion_H
16-
#define AdditiveFOAMVersion_H
17-
18-
// Static Version
19-
#define ADDITIVEFOAM_VERSION "$STATIC_VERSION"
14+
#ifndef gitInfo_H
15+
#define gitInfo_H
2016
2117
// Git describe
2218
#define ADDITIVEFOAM_GIT_DESCRIBE "$GIT_DESCRIBE"
@@ -27,11 +23,7 @@ cat > "$HEADER_FILE" << EOF
2723
#endif
2824
EOF
2925

30-
if [ $? -ne 0 ]; then
31-
echo "Error: Failed to write to $HEADER_FILE" >&2
32-
fi
33-
34-
echo "Generated version header: $HEADER_FILE" >&2
26+
export ADDITIVEFOAM_BUILD_FLAGS="-DGIT_MODULE_ENABLED=1"
3527

3628
#------------------------------------------------------------------------------
3729
# Build libraries and solver

applications/solvers/additiveFoam/Make/options

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
EXE_INC = \
2+
$(ADDITIVEFOAM_BUILD_FLAGS) \
23
-I. \
34
-ImovingHeatSource/lnInclude \
45
-I$(LIB_SRC)/finiteVolume/lnInclude \

applications/solvers/additiveFoam/additiveFoam.C

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ Description
3131
simulations.
3232
3333
\*---------------------------------------------------------------------------*/
34-
35-
#include "Make/additiveFoamVersion.H"
36-
34+
#include "additiveFoamInfo.H"
3735
#include "fvCFD.H"
3836
#include "pimpleControl.H"
3937
#include "graph.H"
@@ -49,18 +47,7 @@ int main(int argc, char *argv[])
4947
{
5048
#include "postProcess.H"
5149
#include "setRootCase.H"
52-
53-
Info << "AdditiveFOAM Information:" << nl;
54-
#ifdef ADDITIVEFOAM_VERSION
55-
Info << "Version: " << ADDITIVEFOAM_VERSION << nl;
56-
#endif
57-
#ifdef ADDITIVEFOAM_GIT_DESCRIBE
58-
Info << "Build: " << ADDITIVEFOAM_GIT_DESCRIBE << nl;
59-
#endif
60-
#ifdef ADDITIVEFOAM_GIT_SHA1
61-
Info << "Git SHA1: " << ADDITIVEFOAM_GIT_SHA1 << nl << endl;
62-
#endif
63-
50+
AdditiveFoamInfo::write();
6451
#include "createTime.H"
6552
#include "createMesh.H"
6653
#include "createControl.H"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*---------------------------------------------------------------------------*\
2+
-------------------------------------------------------------------------------
3+
Copyright (C) 2023 Oak Ridge National Laboratory
4+
-------------------------------------------------------------------------------
5+
6+
Class
7+
Foam::AdditiveFoamInfo
8+
9+
Description
10+
Outputs version and build information for AdditiveFOAM.
11+
12+
\*---------------------------------------------------------------------------*/
13+
14+
#ifndef AdditiveFoamInfo_H
15+
#define AdditiveFoamInfo_H
16+
17+
#include "OSspecific.H"
18+
19+
#ifdef GIT_MODULE_ENABLED
20+
#include "Make/gitInfo.H"
21+
#endif
22+
23+
// Static version
24+
#define ADDITIVEFOAM_VERSION "1.1.0-dev"
25+
26+
namespace Foam
27+
{
28+
29+
class AdditiveFoamInfo
30+
{
31+
public:
32+
33+
//- Disallow default construction, copy, assignment, and destruction
34+
AdditiveFoamInfo() = delete;
35+
~AdditiveFoamInfo() = delete;
36+
AdditiveFoamInfo(const AdditiveFoamInfo&) = delete;
37+
AdditiveFoamInfo& operator=(const AdditiveFoamInfo&) = delete;
38+
39+
//- Print version/build information to Info stream
40+
static void write()
41+
{
42+
Info<< "AdditiveFOAM Information:" << nl;
43+
Info<< "Version: " << ADDITIVEFOAM_VERSION << nl;
44+
45+
//- Print git describe and SHA1 (optional)
46+
#ifdef ADDITIVEFOAM_GIT_DESCRIBE
47+
Info<< "Build: " << ADDITIVEFOAM_GIT_DESCRIBE << nl;
48+
#endif
49+
50+
#ifdef ADDITIVEFOAM_GIT_SHA1
51+
Info<< "Git SHA1: " << ADDITIVEFOAM_GIT_SHA1 << nl;
52+
#endif
53+
54+
Info<< endl;
55+
}
56+
};
57+
58+
} // End namespace Foam
59+
60+
#endif
61+
62+
// ************************************************************************* //
63+

0 commit comments

Comments
 (0)