diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index 3aa50706..c400b6c3 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -68,6 +68,8 @@ QEGlobals_t g_qeglobals; #define PATH_MAX 260 #endif +#define RADIANT_MONITOR_ADDRESS "127.0.0.1:39000" + void QE_InitVFS(){ // VFS initialization ----------------------- @@ -165,7 +167,7 @@ void bsp_init(){ build_set_variable( "ExecutableType", RADIANT_EXECUTABLE ); build_set_variable( "EnginePath", EnginePath_get() ); build_set_variable( "UserEnginePath", g_qeglobals.m_userEnginePath.c_str() ); - build_set_variable( "MonitorAddress", ( g_WatchBSP_Enabled ) ? "127.0.0.1:39000" : "" ); + build_set_variable( "MonitorAddress", ( g_WatchBSP_Enabled ) ? RADIANT_MONITOR_ADDRESS : "" ); build_set_variable( "GameName", gamename_get() ); const char* mapname = Map_Name( g_map ); @@ -226,14 +228,10 @@ BatchCommandListener( TextOutputStream& file, const char* outputRedirect ) : m_f void execute( const char* command ){ m_file << command; - if ( m_commandCount == 0 ) { - m_file << " > "; + if( m_outputRedirect ){ + m_file << ( m_commandCount == 0? " > " : " >> " ); + m_file << "\"" << m_outputRedirect << "\""; } - else - { - m_file << " >> "; - } - m_file << "\"" << m_outputRedirect << "\""; m_file << "\n"; ++m_commandCount; } @@ -282,9 +280,14 @@ void RunBSP( const char* name ){ bsp_init(); - if ( g_WatchBSP_Enabled ) { - ArrayCommandListener listener; - build_run( name, listener ); + ArrayCommandListener listener; + build_run( name, listener ); + bool monitor = false; + for ( guint i = 0; i < listener.array()->len; ++i ) + if( strstr( (char*)g_ptr_array_index( listener.array(), i ), RADIANT_MONITOR_ADDRESS ) ) + monitor = true; + + if ( g_WatchBSP_Enabled && monitor ) { // grab the file name for engine running const char* fullname = Map_Name( g_map ); StringOutputStream bspname( 64 ); @@ -314,7 +317,7 @@ void RunBSP( const char* name ){ #if defined ( POSIX ) batchFile << "#!/bin/sh \n\n"; #endif - BatchCommandListener listener( batchFile, junkpath ); + BatchCommandListener listener( batchFile, g_WatchBSP0_DumpLog? junkpath : 0 ); build_run( name, listener ); written = true; } @@ -324,7 +327,8 @@ void RunBSP( const char* name ){ chmod( batpath, 0744 ); #endif globalOutputStream() << "Writing the compile script to '" << batpath << "'\n"; - globalOutputStream() << "The build output will be saved in '" << junkpath << "'\n"; + if( g_WatchBSP0_DumpLog ) + globalOutputStream() << "The build output will be saved in '" << junkpath << "'\n"; Q_Exec( batpath, NULL, NULL, true, false ); } } diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index 59bf7533..36e59076 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -168,9 +168,10 @@ bool g_WatchBSP_Enabled = true; // do we stop the compilation process if we come accross a leak? bool g_WatchBSP_LeakStop = true; bool g_WatchBSP_RunQuake = false; +bool g_WatchBSP0_DumpLog = false; // timeout when beginning a step (in seconds) // if we don't get a connection quick enough we assume something failed and go back to idling -int g_WatchBSP_Timeout = 10; +const int g_WatchBSP_Timeout = 5; void Build_constructPreferences( PreferencesPage& page ){ @@ -179,6 +180,7 @@ void Build_constructPreferences( PreferencesPage& page ){ GtkWidget* runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake ); Widget_connectToggleDependency( leakstop, monitorbsp ); Widget_connectToggleDependency( runengine, monitorbsp ); + page.appendCheckBox( "", "Dump non Monitored Builds Log", g_WatchBSP0_DumpLog ); } void Build_constructPage( PreferenceGroup& group ){ PreferencesPage page( group.createPage( "Build", "Build Preferences" ) ); @@ -196,9 +198,10 @@ void BuildMonitor_Construct(){ g_WatchBSP_Enabled = !string_equal( g_pGameDescription->getKeyValue( "no_bsp_monitor" ), "1" ); - GlobalPreferenceSystem().registerPreference( "WatchBSP", BoolImportStringCaller( g_WatchBSP_Enabled ), BoolExportStringCaller( g_WatchBSP_Enabled ) ); - GlobalPreferenceSystem().registerPreference( "RunQuake2Run", BoolImportStringCaller( g_WatchBSP_RunQuake ), BoolExportStringCaller( g_WatchBSP_RunQuake ) ); - GlobalPreferenceSystem().registerPreference( "LeakStop", BoolImportStringCaller( g_WatchBSP_LeakStop ), BoolExportStringCaller( g_WatchBSP_LeakStop ) ); + GlobalPreferenceSystem().registerPreference( "BuildMonitor", BoolImportStringCaller( g_WatchBSP_Enabled ), BoolExportStringCaller( g_WatchBSP_Enabled ) ); + GlobalPreferenceSystem().registerPreference( "BuildRunGame", BoolImportStringCaller( g_WatchBSP_RunQuake ), BoolExportStringCaller( g_WatchBSP_RunQuake ) ); + GlobalPreferenceSystem().registerPreference( "BuildLeakStop", BoolImportStringCaller( g_WatchBSP_LeakStop ), BoolExportStringCaller( g_WatchBSP_LeakStop ) ); + GlobalPreferenceSystem().registerPreference( "BuildDumpLog", BoolImportStringCaller( g_WatchBSP0_DumpLog ), BoolExportStringCaller( g_WatchBSP0_DumpLog ) ); Build_registerPreferencesPage(); } @@ -764,7 +767,7 @@ GPtrArray* str_ptr_array_clone( GPtrArray* array ){ void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ){ m_sBSPName = string_clone( sBSPName ); if ( m_eState != EIdle ) { - globalOutputStream() << "WatchBSP got a monitoring request while not idling...\n"; + globalWarningStream() << "WatchBSP got a monitoring request while not idling...\n"; // prompt the user, should we cancel the current process and go ahead? // if ( gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?", // "Build process monitoring", eMB_YESNO ) == eIDYES ) { diff --git a/radiant/watchbsp.h b/radiant/watchbsp.h index 94b5a584..49b35204 100644 --- a/radiant/watchbsp.h +++ b/radiant/watchbsp.h @@ -39,5 +39,6 @@ void BuildMonitor_Run( GPtrArray* commands, const char* mapName ); extern bool g_WatchBSP_Enabled; extern bool g_WatchBSP_LeakStop; +extern bool g_WatchBSP0_DumpLog; #endif