myincdirs : HSequenceOfPath from WOKUtils;
mydbdirs : HSequenceOfPath from WOKUtils;
myoptions : HAsciiString from TCollection;
+ myCmdLine : HAsciiString from TCollection;
+
+friends
+
+ class CompilerIterator from WOKBuilder
end Compiler;
#include <stdio.h>
+#include <OSD_Protection.hxx>
+#include <OSD_File.hxx>
+#include <WOKUtils_AdmFile.hxx>
+
//=======================================================================
//function : WOKBuilder_Compiler
//purpose :
//=======================================================================
WOKBuilder_BuildStatus WOKBuilder_Compiler::Execute()
{
+
+ static Handle( TCollection_HAsciiString ) NL = new TCollection_HAsciiString ( " \\\n " );
+ static Handle( TCollection_HAsciiString ) LF = new TCollection_HAsciiString ( "\n" );
+
int start;
#ifdef WNT
Shell()->ClearOutput();
Shell()->Execute(astr);
+ myCmdLine = new TCollection_HAsciiString ( astr );
+
Handle(TColStd_HSequenceOfHAsciiString) resseq = Shell()->Errors();
if(Shell()->Status())
Shell()->ClearOutput();
SetProduction(EvalProduction());
+
+ astr -> Clear ();
+
+ for ( start = 1; start <= Produces () -> Length (); ++start ) {
+
+ Handle( WOKBuilder_Entity ) ent = Produces () -> Value ( start );
+
+ if ( ent -> IsKind (
+ STANDARD_TYPE( WOKBuilder_ObjectFile )
+ )
+ ) {
+
+ astr -> AssignCat ( ent -> Path () -> FileName () );
+ astr -> AssignCat ( ": " );
+
+ } else if ( ent -> IsKind (
+ STANDARD_TYPE( WOKBuilder_MFile )
+ )
+ ) {
+
+ WOKUtils_AdmFile mFile ( ent -> Path () );
+
+ Handle( TColStd_HSequenceOfHAsciiString ) deps = mFile.Read ();
+
+ for ( int i = 1; i <= deps -> Length (); ++i ) {
+
+ astr -> AssignCat ( NL );
+ astr -> AssignCat ( deps -> Value ( i ) );
+
+ } // end for
+
+ astr -> AssignCat ( LF );
+
+ } // end if
+
+ } // end for
+
+ if ( !astr -> IsEmpty () ) {
+
+ OSD_Path dPath ( OutputDir () -> Name () -> ToCString () );
+
+ dPath.SetName ( Compilable () -> Path () -> BaseName () -> ToCString () );
+ dPath.SetExtension ( ".d" );
+
+ OSD_File dFile ( dPath );
+
+ dFile.Build (
+ OSD_WriteOnly,
+ OSD_Protection ( OSD_RWXD, OSD_RWXD, OSD_R, OSD_R )
+ );
+
+ if ( !dFile.Failed () ) {
+
+ dFile.Write ( astr -> String (), astr -> Length () );
+
+ if ( dFile.Failed () ) {
+
+ TCollection_AsciiString name;
+
+ dPath.SystemName ( name );
+
+ ErrorMsg << "WOKBuilder_Compiler::Execute"
+ << "could not create '" << new TCollection_HAsciiString ( name )
+ << "'" << endm;
+
+ } // end if
+
+ dFile.Close ();
+
+ } // end if
+
+ } // end if
+
return WOKBuilder_Success;
}
Execute(me:out; acompilable : Compilable from WOKBuilder)
returns BuildStatus from WOKBuilder;
+ CmdLine ( me ) returns HAsciiString from TCollection;
fields
myincdirs : HSequenceOfPath from WOKUtils;
mydbdirs : HSequenceOfPath from WOKUtils;
+ myCmdLine: HAsciiString from TCollection;
end CompilerIterator;
if(status == WOKBuilder_Success)
{
myproduction = acompiler->Produces();
+
+ if ( !acompiler -> myCmdLine.IsNull () ) myCmdLine = new TCollection_HAsciiString ( acompiler -> myCmdLine );
+
}
return status;
}
//=======================================================================
Handle(TCollection_HAsciiString) WOKBuilder_Linker::EvalDatabaseDirectives()
{
- Handle(TCollection_HAsciiString) res = new TCollection_HAsciiString;
+ Handle(TCollection_HAsciiString) res = new TCollection_HAsciiString ( "\\\n" );
if(!mydbdirs.IsNull())
{
Standard_Integer i;
Handle(TCollection_HAsciiString) line;
- line = new TCollection_HAsciiString;
+ line = new TCollection_HAsciiString ( "\\\n" );
for(i=1; i<=mylibs->Length(); i++)
{
Shell()->Send(EvalHeader());
Shell()->Send(EvalObjectList());
Shell()->Send(EvalLibraryList());
+#ifndef LIN
Shell()->Execute(EvalFooter());
+#else
+ static Handle( TCollection_HAsciiString ) skipStr =
+ new TCollection_HAsciiString ( "/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to " );
+ Shell () -> Send ( EvalFooter () );
+
+ Handle( TCollection_HAsciiString ) paramH = EvalToolTemplate ( "CheckUndefHeader" );
+ Handle( TCollection_HAsciiString ) paramF = EvalToolTemplate ( "CheckUndefFooter" );
+
+ if ( !paramH.IsNull () && !paramF.IsNull () &&
+ !paramH -> IsEmpty () && !paramF -> IsEmpty ()
+ ) {
+
+ Shell () -> Send ( paramH );
+ Shell () -> Send ( EvalLibSearchDirectives () );
+ Shell () -> Send ( EvalDatabaseDirectives () );
+ Shell () -> Send ( EvalObjectList () );
+ Shell () -> Send ( EvalLibraryList () );
+ Shell () -> Execute ( paramF );
+
+ } else Shell () -> Execute ( new TCollection_HAsciiString ( "\n" ) );
+#endif // LIN
if(Shell()->Status())
{
ErrorMsg.DontPrintHeader();
for(Standard_Integer i=1; i<= errmsgs->Length(); i++)
{
+#ifdef LIN
+ if ( errmsgs -> Value ( i ) -> Search ( skipStr ) == 1 ) continue;
+#endif // LIN
ErrorMsg << "WOKBuilder_Linker::Execute" << errmsgs->Value(i) << endm;
}
if(ph) ErrorMsg.DoPrintHeader();
errmsgs = Shell()->Errors();
for(Standard_Integer i=1; i<= errmsgs->Length(); i++)
{
+#ifdef LIN
+ if ( errmsgs -> Value ( i ) -> Search ( skipStr ) == 1 ) continue;
+#endif // LIN
InfoMsg << "WOKBuilder_Linker::Execute" << errmsgs->Value(i) << endm;
}
if(ph) InfoMsg.DoPrintHeader();