kicad2step: Report function name and line number only in debug builds

This commit is contained in:
Maciej Suminski 2018-03-19 12:09:15 +01:00
parent 2ff74cb3fc
commit 47e4798423
1 changed files with 69 additions and 23 deletions

View File

@ -160,9 +160,11 @@ FormatType fileType( const char* aFileName )
if( !lfile.FileExists() ) if( !lfile.FileExists() )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * no such file: '" << aFileName << "'\n"; ostr << " * no such file: '" << aFileName << "'\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return FMT_NONE; return FMT_NONE;
} }
@ -250,9 +252,11 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
if( distance < MIN_LENGTH2 ) if( distance < MIN_LENGTH2 )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * rejected a zero-length line\n"; ostr << " * rejected a zero-length line\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -267,9 +271,11 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
if( rad < MIN_LENGTH2 ) if( rad < MIN_LENGTH2 )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * rejected a zero-radius arc or circle\n"; ostr << " * rejected a zero-radius arc or circle\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -305,9 +311,11 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
if( rad < MIN_LENGTH2 ) if( rad < MIN_LENGTH2 )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * rejected an arc with equivalent end points\n"; ostr << " * rejected an arc with equivalent end points\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
} }
@ -408,9 +416,11 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
do do
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * unsupported curve type: '" << aCurve->m_form << "'\n"; ostr << " * unsupported curve type: '" << aCurve->m_form << "'\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
} while( 0 ); } while( 0 );
return false; return false;
@ -571,9 +581,11 @@ bool PCBMODEL::AddComponent( const std::string& aFileName, const std::string aRe
if( !getModelLabel( aFileName, lmodel ) ) if( !getModelLabel( aFileName, lmodel ) )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * no model for filename '" << aFileName << "'\n"; ostr << " * no model for filename '" << aFileName << "'\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -583,9 +595,11 @@ bool PCBMODEL::AddComponent( const std::string& aFileName, const std::string aRe
if( !getModelLocation( aBottom, aPosition, aRotation, aOffset, aOrientation, toploc ) ) if( !getModelLocation( aBottom, aPosition, aRotation, aOffset, aOrientation, toploc ) )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * no location data for filename '" << aFileName << "'\n"; ostr << " * no location data for filename '" << aFileName << "'\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -595,9 +609,11 @@ bool PCBMODEL::AddComponent( const std::string& aFileName, const std::string aRe
if( llabel.IsNull() ) if( llabel.IsNull() )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * could not add component with filename '" << aFileName << "'\n"; ostr << " * could not add component with filename '" << aFileName << "'\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -637,9 +653,11 @@ bool PCBMODEL::CreatePCB()
{ {
m_hasPCB = true; m_hasPCB = true;
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * no valid board outline\n"; ostr << " * no valid board outline\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -658,9 +676,11 @@ bool PCBMODEL::CreatePCB()
if( !oln.MakeShape( board, m_thickness ) ) if( !oln.MakeShape( board, m_thickness ) )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * could not create board extrusion\n"; ostr << " * could not create board extrusion\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -676,9 +696,11 @@ bool PCBMODEL::CreatePCB()
else else
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * could not create board cutout\n"; ostr << " * could not create board cutout\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
} }
} }
@ -710,9 +732,11 @@ bool PCBMODEL::CreatePCB()
if( sC == eC && !oln.m_curves.empty() ) if( sC == eC && !oln.m_curves.empty() )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * could not close outline (dropping outline data with " << oln.m_curves.size() << " segments)\n"; ostr << " * could not close outline (dropping outline data with " << oln.m_curves.size() << " segments)\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
oln.Clear(); oln.Clear();
if( !m_curves.empty() ) if( !m_curves.empty() )
@ -730,9 +754,11 @@ bool PCBMODEL::CreatePCB()
if( !oln.MakeShape( board, m_thickness ) ) if( !oln.MakeShape( board, m_thickness ) )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * could not create board extrusion\n"; ostr << " * could not create board extrusion\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
} }
@ -747,9 +773,11 @@ bool PCBMODEL::CreatePCB()
else else
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * could not create board cutout\n"; ostr << " * could not create board cutout\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
} }
} }
} }
@ -790,9 +818,11 @@ bool PCBMODEL::WriteIGES( const std::string& aFileName, bool aOverwrite )
if( m_pcb_label.IsNull() ) if( m_pcb_label.IsNull() )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * No valid PCB assembly; cannot create output file " << aFileName << "\n"; ostr << " * No valid PCB assembly; cannot create output file " << aFileName << "\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -822,9 +852,11 @@ bool PCBMODEL::WriteSTEP( const std::string& aFileName, bool aOverwrite )
if( m_pcb_label.IsNull() ) if( m_pcb_label.IsNull() )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * No valid PCB assembly; cannot create output file " << aFileName << "\n"; ostr << " * No valid PCB assembly; cannot create output file " << aFileName << "\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -874,9 +906,11 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TDF_Label& aLabel )
if( !readIGES( doc, aFileName.c_str() ) ) if( !readIGES( doc, aFileName.c_str() ) )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * readIGES() failed on filename '" << aFileName << "'\n"; ostr << " * readIGES() failed on filename '" << aFileName << "'\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
break; break;
@ -885,9 +919,11 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TDF_Label& aLabel )
if( !readSTEP( doc, aFileName.c_str() ) ) if( !readSTEP( doc, aFileName.c_str() ) )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * readSTEP() failed on filename '" << aFileName << "'\n"; ostr << " * readSTEP() failed on filename '" << aFileName << "'\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
break; break;
@ -960,9 +996,11 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TDF_Label& aLabel )
if( aLabel.IsNull() ) if( aLabel.IsNull() )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * could not transfer model data from file '" << aFileName << "'\n"; ostr << " * could not transfer model data from file '" << aFileName << "'\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -1342,9 +1380,11 @@ bool OUTLINE::MakeShape( TopoDS_Shape& aShape, double aThickness )
if( !addEdge( &wire, i, lastPoint ) ) if( !addEdge( &wire, i, lastPoint ) )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * failed to add an edge\n"; ostr << " * failed to add an edge\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
} }
@ -1355,9 +1395,11 @@ bool OUTLINE::MakeShape( TopoDS_Shape& aShape, double aThickness )
if( aShape.IsNull() ) if( aShape.IsNull() )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * failed to create a prismatic shape\n"; ostr << " * failed to create a prismatic shape\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }
@ -1405,9 +1447,11 @@ bool OUTLINE::addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBL
do do
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * unsupported curve type: " << aCurve.m_form << "\n"; ostr << " * unsupported curve type: " << aCurve.m_form << "\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} while( 0 ); } while( 0 );
@ -1422,9 +1466,11 @@ bool OUTLINE::addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBL
if( BRepBuilderAPI_DisconnectedWire == aWire->Error() ) if( BRepBuilderAPI_DisconnectedWire == aWire->Error() )
{ {
std::ostringstream ostr; std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ostr << " * failed to add curve\n"; ostr << " * failed to add curve\n";
wxLogMessage( "%s\n", ostr.str().c_str() ); wxLogMessage( "%s", ostr.str().c_str() );
return false; return false;
} }