COMP: add minimal test application

- uses wmake, without OpenFOAM libraries.

  The application and libray serve as a minimal test case for wmake,
  but can also be used to generate a minimal library/executable pair
  target for testing of packaging etc.
This commit is contained in:
Mark Olesen
2018-11-23 00:21:10 +01:00
parent 8f4067015d
commit 45d5d7bbc1
9 changed files with 281 additions and 0 deletions

View File

@ -0,0 +1,7 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
wclean libso dummy
wclean
#------------------------------------------------------------------------------

View File

@ -0,0 +1,13 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Can never be too certain ...
# Compile tools for wmake
( cd "${WM_DIR:?}/src" && make )
#------------------------------------------------------------------------------
wmake libso dummy
wmake
#------------------------------------------------------------------------------

View File

@ -0,0 +1,3 @@
Test-dummyLib.C
EXE = $(FOAM_APPBIN)/Test-dummyLib

View File

@ -0,0 +1,9 @@
/* Without the normal defaults */
PROJECT_INC =
PROJECT_LIBS =
EXE_INC = -Idummy
EXE_LIBS = \
-lOpenFOAM-dummy

View File

@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Minimal compilation test with wmake, without OpenFOAM libraries.
The application and libray can also serve as a minimal test case for
wmake, or to provide a minimal library/executable target for testing.
\*---------------------------------------------------------------------------*/
#include "dummyLib.H"
#include <iostream>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
using wmake = Foam::Detail::dummyLib;
std::cout
<< '\n'
<< "OPENFOAM = " << OPENFOAM << '\n'
<< "label = " << wmake::label_size << '\n'
<< "scalar = " << wmake::scalar_size
<< " (" << wmake::precision << ")\n"
<< "arch = " << wmake::arch << '\n'
<< "compiler = " << wmake::compiler << '\n';
std::cout
<< '\n'
<< "archComp = " << wmake::archComp << '\n'
<< "archCompBase = " << wmake::archCompBase << '\n'
<< "archCompFull = " << wmake::archCompFull << '\n';
std::cout
<< '\n';
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
dummyLib.C
LIB = $(FOAM_LIBBIN)/libOpenFOAM-dummy

View File

@ -0,0 +1,12 @@
/* Without the normal defaults */
PROJECT_INC =
PROJECT_LIBS =
EXE_INC = \
-DWM_ARCH=\"$(WM_ARCH)\" \
-DWM_COMPILER=\"$(WM_COMPILER)\" \
-DWM_COMPILE_OPTION=\"$(WM_COMPILE_OPTION)\" \
-DWM_OPTIONS=\"$(WM_OPTIONS)\"
/* LIB_LIBS = */

View File

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "dummyLib.H"
// We know that our options file has properly defined types here
#if defined WM_SP
# define PRECISION "SP"
# define SCALAR_SIZE (8*sizeof(float))
#elif defined WM_DP
# define PRECISION "DP"
# define SCALAR_SIZE (8*sizeof(double))
#else
# define PRECISION "QP"
# define SCALAR_SIZE (8*sizeof(long double))
#endif
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const std::string Foam::Detail::dummyLib::arch(WM_ARCH);
const std::string Foam::Detail::dummyLib::compiler(WM_COMPILER);
const std::string Foam::Detail::dummyLib::precision(PRECISION);
const std::string Foam::Detail::dummyLib::scalar_size
(
std::to_string(SCALAR_SIZE)
);
const std::string Foam::Detail::dummyLib::label_size
(
std::to_string(WM_LABEL_SIZE)
);
const std::string Foam::Detail::dummyLib::archComp
(
WM_ARCH WM_COMPILER
);
const std::string Foam::Detail::dummyLib::archCompBase
(
WM_ARCH WM_COMPILER PRECISION "Int"
+ std::to_string(WM_LABEL_SIZE)
);
const std::string Foam::Detail::dummyLib::archCompFull
(
WM_ARCH WM_COMPILER PRECISION "Int"
+ std::to_string(WM_LABEL_SIZE)
+ WM_COMPILE_OPTION
);
// ************************************************************************* //

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::Detail::dummyLib
Description
This class serves little useful purpose, but can be used to compile
into a dummy library and link against for a minimal application
that uses the wmake framework
SourceFiles
dummyLib.C
\*---------------------------------------------------------------------------*/
#ifndef dummyLib_H
#define dummyLib_H
#include <string>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class dummyLib Declaration
\*---------------------------------------------------------------------------*/
struct dummyLib
{
//- Compile-time value of WM_ARCH
static const std::string arch;
//- Compile-time value of WM_COMPILER
static const std::string compiler;
//- Compile-time equivalent to WM_PRECISION_OPTION
static const std::string scalar_size;
//- Compile-time of WM_LABEL_SIZE
static const std::string label_size;
//- Compile-time value of WM_PRECISION_OPTION
static const std::string precision;
//- Compile-time value of WM_ARCH + WM_COMPILER
static const std::string archComp;
//- Compile-time value of WM_ARCH + WM_COMPILER, precision, label-size
static const std::string archCompBase;
//- DIY Compile-time value of WM_OPTIONS
static const std::string archCompFull;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Detail
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //