Split info() function into separate file as it depends on too many defines and external libs

master
Marius Kintel 2014-07-22 13:32:44 -04:00
parent 50ac9c262c
commit 28864037ee
10 changed files with 122 additions and 110 deletions

View File

@ -292,6 +292,7 @@ HEADERS += src/typedefs.h \
src/system-gl.h \
src/stl-utils.h \
src/boost-utils.h \
src/LibraryInfo.h \
src/svg.h \
\
src/lodepng.h \
@ -350,6 +351,7 @@ SOURCES += src/version_check.cc \
src/stl-utils.cc \
src/boost-utils.cc \
src/PlatformUtils.cc \
src/LibraryInfo.cc \
\
src/nodedumper.cc \
src/traverser.cc \

102
src/LibraryInfo.cc Normal file
View File

@ -0,0 +1,102 @@
#include "LibraryInfo.h"
#include <glib.h>
#include <vector>
#include "version_check.h"
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#ifdef ENABLE_CGAL
#include "cgal.h"
#include <boost/algorithm/string.hpp>
#if defined(__GNUG__)
#define GCC_INT_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 )
#if GCC_INT_VERSION > 40600 || defined(__clang__)
#include <cxxabi.h>
#define __openscad_info_demangle__ 1
#endif // GCC_INT_VERSION
#endif // GNUG
#endif // ENABLE_CGAL
extern std::vector<std::string> librarypath;
extern std::vector<std::string> fontpath;
std::string LibraryInfo::info()
{
std::stringstream s;
#if defined(__GNUG__) && !defined(__clang__)
std::string compiler_info( "GCC " + std::string(TOSTRING(__VERSION__)) );
#elif defined(_MSC_VER)
std::string compiler_info( "MSVC " + std::string(TOSTRING(_MSC_FULL_VER)) );
#elif defined(__clang__)
std::string compiler_info( "Clang " + std::string(TOSTRING(__clang_version__)) );
#else
std::string compiler_info( "unknown compiler" );
#endif
#if defined( __MINGW64__ )
std::string mingwstatus("MingW64");
#elif defined( __MINGW32__ )
std::string mingwstatus("MingW32");
#else
std::string mingwstatus("No");
#endif
#ifndef OPENCSG_VERSION_STRING
#define OPENCSG_VERSION_STRING "unknown, <1.3.2"
#endif
#ifdef QT_VERSION
std::string qtVersion = qVersion();
#else
std::string qtVersion = "Qt disabled - Commandline Test Version";
#endif
#ifdef ENABLE_CGAL
std::string cgal_3d_kernel = typeid(CGAL_Kernel3).name();
std::string cgal_2d_kernel = typeid(CGAL_Kernel2).name();
std::string cgal_2d_kernelEx = typeid(CGAL_ExactKernel2).name();
#if defined(__openscad_info_demangle__)
int status;
cgal_3d_kernel = std::string( abi::__cxa_demangle( cgal_3d_kernel.c_str(), 0, 0, &status ) );
cgal_2d_kernel = std::string( abi::__cxa_demangle( cgal_2d_kernel.c_str(), 0, 0, &status ) );
cgal_2d_kernelEx = std::string( abi::__cxa_demangle( cgal_2d_kernelEx.c_str(), 0, 0, &status ) );
#endif // demangle
boost::replace_all( cgal_3d_kernel, "CGAL::", "" );
boost::replace_all( cgal_2d_kernel, "CGAL::", "" );
boost::replace_all( cgal_2d_kernelEx, "CGAL::", "" );
#else // ENABLE_CGAL
std::string cgal_3d_kernel = "";
std::string cgal_2d_kernel = "";
std::string cgal_2d_kernelEx = "";
#endif // ENABLE_CGAL
const char *env_path = getenv("OPENSCADPATH");
const char *env_font_path = getenv("OPENSCAD_FONT_PATH");
s << "OpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION)
<< "\nCompiler, build date: " << compiler_info << ", " << __DATE__
<< "\nBoost version: " << BOOST_LIB_VERSION
<< "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION
<< "\nCGAL version, kernels: " << TOSTRING(CGAL_VERSION) << ", " << cgal_3d_kernel << ", " << cgal_2d_kernel << ", " << cgal_2d_kernelEx
<< "\nOpenCSG version: " << OPENCSG_VERSION_STRING
<< "\nQt version: " << qtVersion
<< "\nMingW build: " << mingwstatus
<< "\nGLib version: " << GLIB_MAJOR_VERSION << "." << GLIB_MINOR_VERSION << "." << GLIB_MICRO_VERSION
<< "\nOPENSCADPATH: " << (env_path == NULL ? "<not set>" : env_path)
<< "\nOpenSCAD library path:\n";
for (std::vector<std::string>::iterator it = librarypath.begin();it != librarypath.end();it++) {
s << " " << *it << "\n";
}
s << "\nOPENSCAD_FONT_PATH: " << (env_font_path == NULL ? "<not set>" : env_font_path)
<< "\nOpenSCAD font path:\n";
for (std::vector<std::string>::iterator it = fontpath.begin();it != fontpath.end();it++) {
s << " " << *it << "\n";
}
return s.str();
}

7
src/LibraryInfo.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#include <string>
namespace LibraryInfo {
std::string info();
}

View File

@ -1,11 +1,8 @@
#include <glib.h>
#include "PlatformUtils.h"
#include "boosty.h"
#include <Eigen/Core>
extern std::vector<std::string> librarypath;
extern std::vector<std::string> fontpath;
bool PlatformUtils::createLibraryPath()
@ -79,103 +76,3 @@ bool PlatformUtils::createBackupPath()
}
return OK;
}
#include "version_check.h"
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#ifdef ENABLE_CGAL
#include "cgal.h"
#include <boost/algorithm/string.hpp>
#if defined(__GNUG__)
#define GCC_INT_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 )
#if GCC_INT_VERSION > 40600 || defined(__clang__)
#include <cxxabi.h>
#define __openscad_info_demangle__ 1
#endif // GCC_INT_VERSION
#endif // GNUG
#endif // ENABLE_CGAL
#ifdef ENABLE_OPENCSG
#include <opencsg.h>
#endif
std::string PlatformUtils::info()
{
std::stringstream s;
#if defined(__GNUG__) && !defined(__clang__)
std::string compiler_info( "GCC " + std::string(TOSTRING(__VERSION__)) );
#elif defined(_MSC_VER)
std::string compiler_info( "MSVC " + std::string(TOSTRING(_MSC_FULL_VER)) );
#elif defined(__clang__)
std::string compiler_info( "Clang " + std::string(TOSTRING(__clang_version__)) );
#else
std::string compiler_info( "unknown compiler" );
#endif
#if defined( __MINGW64__ )
std::string mingwstatus("MingW64");
#elif defined( __MINGW32__ )
std::string mingwstatus("MingW32");
#else
std::string mingwstatus("No");
#endif
#ifndef OPENCSG_VERSION_STRING
#define OPENCSG_VERSION_STRING "unknown, <1.3.2"
#endif
#ifdef QT_VERSION
std::string qtVersion = qVersion();
#else
std::string qtVersion = "Qt disabled - Commandline Test Version";
#endif
#ifdef ENABLE_CGAL
std::string cgal_3d_kernel = typeid(CGAL_Kernel3).name();
std::string cgal_2d_kernel = typeid(CGAL_Kernel2).name();
std::string cgal_2d_kernelEx = typeid(CGAL_ExactKernel2).name();
#if defined(__openscad_info_demangle__)
int status;
cgal_3d_kernel = std::string( abi::__cxa_demangle( cgal_3d_kernel.c_str(), 0, 0, &status ) );
cgal_2d_kernel = std::string( abi::__cxa_demangle( cgal_2d_kernel.c_str(), 0, 0, &status ) );
cgal_2d_kernelEx = std::string( abi::__cxa_demangle( cgal_2d_kernelEx.c_str(), 0, 0, &status ) );
#endif // demangle
boost::replace_all( cgal_3d_kernel, "CGAL::", "" );
boost::replace_all( cgal_2d_kernel, "CGAL::", "" );
boost::replace_all( cgal_2d_kernelEx, "CGAL::", "" );
#else // ENABLE_CGAL
std::string cgal_3d_kernel = "";
std::string cgal_2d_kernel = "";
std::string cgal_2d_kernelEx = "";
#endif // ENABLE_CGAL
const char *env_path = getenv("OPENSCADPATH");
const char *env_font_path = getenv("OPENSCAD_FONT_PATH");
s << "OpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION)
<< "\nCompiler, build date: " << compiler_info << ", " << __DATE__
<< "\nBoost version: " << BOOST_LIB_VERSION
<< "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION
<< "\nCGAL version, kernels: " << TOSTRING(CGAL_VERSION) << ", " << cgal_3d_kernel << ", " << cgal_2d_kernel << ", " << cgal_2d_kernelEx
<< "\nOpenCSG version: " << OPENCSG_VERSION_STRING
<< "\nQt version: " << qtVersion
<< "\nMingW build: " << mingwstatus
<< "\nGLib version: " << GLIB_MAJOR_VERSION << "." << GLIB_MINOR_VERSION << "." << GLIB_MICRO_VERSION
<< "\nOPENSCADPATH: " << (env_path == NULL ? "<not set>" : env_path)
<< "\nOpenSCAD library path:\n";
for (std::vector<std::string>::iterator it = librarypath.begin();it != librarypath.end();it++) {
s << " " << *it << "\n";
}
s << "\nOPENSCAD_FONT_PATH: " << (env_font_path == NULL ? "<not set>" : env_font_path)
<< "\nOpenSCAD font path:\n";
for (std::vector<std::string>::iterator it = fontpath.begin();it != fontpath.end();it++) {
s << " " << *it << "\n";
}
return s.str();
}

View File

@ -9,7 +9,6 @@ namespace PlatformUtils {
bool createLibraryPath();
std::string backupPath();
bool createBackupPath();
std::string info();
/**
* Single character separating path specifications in a list

View File

@ -55,6 +55,7 @@
#include "CocoaUtils.h"
#endif
#include "PlatformUtils.h"
#include "LibraryInfo.h"
#include <QMenu>
#include <QTime>
@ -2276,14 +2277,14 @@ MainWindow::helpManual()
void MainWindow::helpLibrary()
{
QString info( PlatformUtils::info().c_str() );
info += QString( qglview->getRendererInfo().c_str() );
QString info(LibraryInfo::info().c_str());
info += QString(qglview->getRendererInfo().c_str());
if (!this->openglbox) {
this->openglbox = new QMessageBox(QMessageBox::Information,
"OpenGL Info", "OpenSCAD Detailed Library and Build Information",
QMessageBox::Ok, this);
}
this->openglbox->setDetailedText( info );
this->openglbox->setDetailedText(info);
this->openglbox->show();
}

View File

@ -37,6 +37,7 @@
#include "parsersettings.h"
#include "rendersettings.h"
#include "PlatformUtils.h"
#include "LibraryInfo.h"
#include "nodedumper.h"
#include "CocoaUtils.h"
@ -135,7 +136,7 @@ static void version()
static void info()
{
std::cout << PlatformUtils::info() << "\n\n";
std::cout << LibraryInfo::info() << "\n\n";
CsgInfo csgInfo = CsgInfo();
try {

View File

@ -14,6 +14,8 @@ The extensive #else #endif is to ensure only a single error is printed at
a time, to avoid confusion.
*/
#pragma once
#ifndef OPENSCAD_SKIP_VERSION_CHECK

View File

@ -631,6 +631,8 @@ set(CORE_SOURCES
../src/DrawingCallback.cc
../src/FreetypeRenderer.cc
../src/lodepng.cpp
../src/PlatformUtils.cc
../src/${PLATFORMUTILS_SOURCE}
${FLEX_OpenSCADlexer_OUTPUTS}
${BISON_OpenSCADparser_OUTPUTS})
@ -638,8 +640,7 @@ set(NOCGAL_SOURCES
../src/builtin.cc
../src/import.cc
../src/export.cc
../src/PlatformUtils.cc
../src/${PLATFORMUTILS_SOURCE})
../src/LibraryInfo.cc)
set(CGAL_SOURCES
${NOCGAL_SOURCES}