mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-06 21:46:29 +03:00
ecode: Added clean stage to the project build config.
This commit is contained in:
@@ -81,8 +81,18 @@ UIPushButton* StatusBuildOutputController::getBuildButton( App* app ) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void StatusBuildOutputController::run( const std::string& buildName, const std::string& buildType,
|
||||
const ProjectBuildOutputParser& outputParser ) {
|
||||
UIPushButton* StatusBuildOutputController::getCleanButton( App* app ) {
|
||||
if ( app->getSidePanel() ) {
|
||||
UIWidget* tab = app->getSidePanel()->find<UIWidget>( "build_tab" );
|
||||
if ( tab )
|
||||
return tab->find<UIPushButton>( "clean_button" );
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void StatusBuildOutputController::runBuild( const std::string& buildName,
|
||||
const std::string& buildType,
|
||||
const ProjectBuildOutputParser& outputParser ) {
|
||||
if ( !mApp->getProjectBuildManager() )
|
||||
return;
|
||||
|
||||
@@ -115,8 +125,14 @@ void StatusBuildOutputController::run( const std::string& buildName, const std::
|
||||
UIPushButton* buildButton = getBuildButton( mApp );
|
||||
if ( buildButton )
|
||||
buildButton->setText( mApp->i18n( "cancel_build", "Cancel Build" ) );
|
||||
UIPushButton* cleanButton = getCleanButton( mApp );
|
||||
bool enableCleanButton = false;
|
||||
if ( cleanButton && cleanButton->isEnabled() ) {
|
||||
cleanButton->setEnabled( false );
|
||||
enableCleanButton = true;
|
||||
}
|
||||
|
||||
auto res = pbm->run(
|
||||
auto res = pbm->build(
|
||||
buildName, [this]( const auto& key, const auto& def ) { return mApp->i18n( key, def ); },
|
||||
buildType,
|
||||
[this]( auto, auto buffer ) {
|
||||
@@ -127,7 +143,7 @@ void StatusBuildOutputController::run( const std::string& buildName, const std::
|
||||
mContainer->setScrollY( mContainer->getMaxScroll().y );
|
||||
} );
|
||||
},
|
||||
[this]( auto exitCode ) {
|
||||
[this, enableCleanButton]( auto exitCode ) {
|
||||
String buffer;
|
||||
|
||||
if ( EXIT_SUCCESS == exitCode ) {
|
||||
@@ -145,9 +161,102 @@ void StatusBuildOutputController::run( const std::string& buildName, const std::
|
||||
mContainer->setScrollY( mContainer->getMaxScroll().y );
|
||||
} );
|
||||
|
||||
UIPushButton* buildButton = nullptr;
|
||||
if ( ( buildButton = getBuildButton( mApp ) ) )
|
||||
UIPushButton* buildButton = getBuildButton( mApp );
|
||||
if ( buildButton )
|
||||
buildButton->setText( mApp->i18n( "build", "Build" ) );
|
||||
|
||||
if ( enableCleanButton ) {
|
||||
UIPushButton* cleanButton = getCleanButton( mApp );
|
||||
if ( cleanButton )
|
||||
cleanButton->setEnabled( true );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( !res.isValid() ) {
|
||||
mApp->getNotificationCenter()->addNotification( res.errorMsg );
|
||||
}
|
||||
}
|
||||
|
||||
void StatusBuildOutputController::runClean( const std::string& buildName,
|
||||
const std::string& buildType,
|
||||
const ProjectBuildOutputParser& outputParser ) {
|
||||
if ( !mApp->getProjectBuildManager() )
|
||||
return;
|
||||
|
||||
auto pbm = mApp->getProjectBuildManager();
|
||||
|
||||
show();
|
||||
|
||||
mContainer->getDocument().reset();
|
||||
mContainer->setScrollY( mContainer->getMaxScroll().y );
|
||||
|
||||
std::vector<SyntaxPattern> patterns;
|
||||
|
||||
for ( const auto& parser : outputParser.getConfig() ) {
|
||||
SyntaxPattern ptn( { parser.pattern }, getProjectOutputParserTypeToString( parser.type ) );
|
||||
patterns.emplace_back( std::move( ptn ) );
|
||||
}
|
||||
|
||||
patterns.emplace_back(
|
||||
SyntaxPattern( { "%d%d%d%d%-%d%d%-%d%d%s%d%d%:%d%d%:%d%d%:.*error.*[^\n]+" }, "error" ) );
|
||||
patterns.emplace_back( SyntaxPattern(
|
||||
{ "%d%d%d%d%-%d%d%-%d%d%s%d%d%:%d%d%:%d%d%:.*warning.*[^\n]+" }, "warning" ) );
|
||||
patterns.emplace_back(
|
||||
SyntaxPattern( { "%d%d%d%d%-%d%d%-%d%d%s%d%d%:%d%d%:%d%d%:[^\n]+" }, "notice" ) );
|
||||
|
||||
SyntaxDefinition synDef( "custom_build", {}, patterns );
|
||||
|
||||
mContainer->getDocument().setSyntaxDefinition( synDef );
|
||||
mContainer->getVScrollBar()->setValue( 1.f );
|
||||
|
||||
UIPushButton* buildButton = getBuildButton( mApp );
|
||||
bool enableBuildButton = false;
|
||||
if ( buildButton && buildButton->isEnabled() ) {
|
||||
buildButton->setEnabled( false );
|
||||
enableBuildButton = true;
|
||||
}
|
||||
UIPushButton* cleanButton = getCleanButton( mApp );
|
||||
if ( cleanButton )
|
||||
cleanButton->setText( mApp->i18n( "cancel_clean", "Cancel Clean" ) );
|
||||
|
||||
auto res = pbm->clean(
|
||||
buildName, [this]( const auto& key, const auto& def ) { return mApp->i18n( key, def ); },
|
||||
buildType,
|
||||
[this]( auto, auto buffer ) {
|
||||
mContainer->runOnMainThread( [this, buffer]() {
|
||||
bool scrollToBottom = mContainer->getVScrollBar()->getValue() == 1.f;
|
||||
mContainer->getDocument().textInput( buffer );
|
||||
if ( scrollToBottom )
|
||||
mContainer->setScrollY( mContainer->getMaxScroll().y );
|
||||
} );
|
||||
},
|
||||
[this, enableBuildButton]( auto exitCode ) {
|
||||
String buffer;
|
||||
|
||||
if ( EXIT_SUCCESS == exitCode ) {
|
||||
buffer = Sys::getDateTimeStr() + ": " +
|
||||
mApp->i18n( "build_successful", "Build run successfully\n" );
|
||||
} else {
|
||||
buffer = Sys::getDateTimeStr() + ": " +
|
||||
mApp->i18n( "build_failed", "Build run with errors\n" );
|
||||
}
|
||||
|
||||
mContainer->runOnMainThread( [this, buffer]() {
|
||||
bool scrollToBottom = mContainer->getVScrollBar()->getValue() == 1.f;
|
||||
mContainer->getDocument().textInput( buffer );
|
||||
if ( scrollToBottom )
|
||||
mContainer->setScrollY( mContainer->getMaxScroll().y );
|
||||
} );
|
||||
|
||||
UIPushButton* cleanButton = getCleanButton( mApp );
|
||||
if ( cleanButton )
|
||||
cleanButton->setText( mApp->i18n( "clean", "Clean" ) );
|
||||
|
||||
if ( enableBuildButton ) {
|
||||
UIPushButton* buildButton = getBuildButton( mApp );
|
||||
if ( buildButton )
|
||||
buildButton->setEnabled( true );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( !res.isValid() ) {
|
||||
|
||||
Reference in New Issue
Block a user