* build monitoring: determine if pending stack got monitorable commands, use non monitorable path, if not

* preferences->Build->Dump non Monitored Builds Log (default = no)
This commit is contained in:
Garux 2018-03-30 01:47:28 +03:00
parent b9dca3b000
commit 21db492d73
3 changed files with 26 additions and 18 deletions

View File

@ -68,6 +68,8 @@ QEGlobals_t g_qeglobals;
#define PATH_MAX 260 #define PATH_MAX 260
#endif #endif
#define RADIANT_MONITOR_ADDRESS "127.0.0.1:39000"
void QE_InitVFS(){ void QE_InitVFS(){
// VFS initialization ----------------------- // VFS initialization -----------------------
@ -165,7 +167,7 @@ void bsp_init(){
build_set_variable( "ExecutableType", RADIANT_EXECUTABLE ); build_set_variable( "ExecutableType", RADIANT_EXECUTABLE );
build_set_variable( "EnginePath", EnginePath_get() ); build_set_variable( "EnginePath", EnginePath_get() );
build_set_variable( "UserEnginePath", g_qeglobals.m_userEnginePath.c_str() ); 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() ); build_set_variable( "GameName", gamename_get() );
const char* mapname = Map_Name( g_map ); const char* mapname = Map_Name( g_map );
@ -226,14 +228,10 @@ BatchCommandListener( TextOutputStream& file, const char* outputRedirect ) : m_f
void execute( const char* command ){ void execute( const char* command ){
m_file << command; m_file << command;
if ( m_commandCount == 0 ) { if( m_outputRedirect ){
m_file << " > "; m_file << ( m_commandCount == 0? " > " : " >> " );
m_file << "\"" << m_outputRedirect << "\"";
} }
else
{
m_file << " >> ";
}
m_file << "\"" << m_outputRedirect << "\"";
m_file << "\n"; m_file << "\n";
++m_commandCount; ++m_commandCount;
} }
@ -282,9 +280,14 @@ void RunBSP( const char* name ){
bsp_init(); bsp_init();
if ( g_WatchBSP_Enabled ) { ArrayCommandListener listener;
ArrayCommandListener listener; build_run( name, 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 // grab the file name for engine running
const char* fullname = Map_Name( g_map ); const char* fullname = Map_Name( g_map );
StringOutputStream bspname( 64 ); StringOutputStream bspname( 64 );
@ -314,7 +317,7 @@ void RunBSP( const char* name ){
#if defined ( POSIX ) #if defined ( POSIX )
batchFile << "#!/bin/sh \n\n"; batchFile << "#!/bin/sh \n\n";
#endif #endif
BatchCommandListener listener( batchFile, junkpath ); BatchCommandListener listener( batchFile, g_WatchBSP0_DumpLog? junkpath : 0 );
build_run( name, listener ); build_run( name, listener );
written = true; written = true;
} }
@ -324,7 +327,8 @@ void RunBSP( const char* name ){
chmod( batpath, 0744 ); chmod( batpath, 0744 );
#endif #endif
globalOutputStream() << "Writing the compile script to '" << batpath << "'\n"; 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 ); Q_Exec( batpath, NULL, NULL, true, false );
} }
} }

View File

@ -168,9 +168,10 @@ bool g_WatchBSP_Enabled = true;
// do we stop the compilation process if we come accross a leak? // do we stop the compilation process if we come accross a leak?
bool g_WatchBSP_LeakStop = true; bool g_WatchBSP_LeakStop = true;
bool g_WatchBSP_RunQuake = false; bool g_WatchBSP_RunQuake = false;
bool g_WatchBSP0_DumpLog = false;
// timeout when beginning a step (in seconds) // 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 // 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 ){ 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 ); GtkWidget* runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake );
Widget_connectToggleDependency( leakstop, monitorbsp ); Widget_connectToggleDependency( leakstop, monitorbsp );
Widget_connectToggleDependency( runengine, monitorbsp ); Widget_connectToggleDependency( runengine, monitorbsp );
page.appendCheckBox( "", "Dump non Monitored Builds Log", g_WatchBSP0_DumpLog );
} }
void Build_constructPage( PreferenceGroup& group ){ void Build_constructPage( PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Build", "Build Preferences" ) ); 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" ); 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( "BuildMonitor", BoolImportStringCaller( g_WatchBSP_Enabled ), BoolExportStringCaller( g_WatchBSP_Enabled ) );
GlobalPreferenceSystem().registerPreference( "RunQuake2Run", BoolImportStringCaller( g_WatchBSP_RunQuake ), BoolExportStringCaller( g_WatchBSP_RunQuake ) ); GlobalPreferenceSystem().registerPreference( "BuildRunGame", BoolImportStringCaller( g_WatchBSP_RunQuake ), BoolExportStringCaller( g_WatchBSP_RunQuake ) );
GlobalPreferenceSystem().registerPreference( "LeakStop", BoolImportStringCaller( g_WatchBSP_LeakStop ), BoolExportStringCaller( g_WatchBSP_LeakStop ) ); GlobalPreferenceSystem().registerPreference( "BuildLeakStop", BoolImportStringCaller( g_WatchBSP_LeakStop ), BoolExportStringCaller( g_WatchBSP_LeakStop ) );
GlobalPreferenceSystem().registerPreference( "BuildDumpLog", BoolImportStringCaller( g_WatchBSP0_DumpLog ), BoolExportStringCaller( g_WatchBSP0_DumpLog ) );
Build_registerPreferencesPage(); Build_registerPreferencesPage();
} }
@ -764,7 +767,7 @@ GPtrArray* str_ptr_array_clone( GPtrArray* array ){
void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ){ void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ){
m_sBSPName = string_clone( sBSPName ); m_sBSPName = string_clone( sBSPName );
if ( m_eState != EIdle ) { 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? // 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?", // 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 ) { // "Build process monitoring", eMB_YESNO ) == eIDYES ) {

View File

@ -39,5 +39,6 @@ void BuildMonitor_Run( GPtrArray* commands, const char* mapName );
extern bool g_WatchBSP_Enabled; extern bool g_WatchBSP_Enabled;
extern bool g_WatchBSP_LeakStop; extern bool g_WatchBSP_LeakStop;
extern bool g_WatchBSP0_DumpLog;
#endif #endif