ecode: Project Build WIP.

This commit is contained in:
Martín Lucas Golini
2023-04-08 13:22:31 -03:00
parent 9eef0748f6
commit 1ba74ae338
11 changed files with 263 additions and 37 deletions

View File

@@ -60,6 +60,83 @@ void StatusBuildOutputController::show() {
}
}
static std::string getProjectOutputParserTypeToString( const ProjectOutputParserTypes& type ) {
switch ( type ) {
case ProjectOutputParserTypes::Error:
return "error";
case ProjectOutputParserTypes::Warning:
return "warning";
case ProjectOutputParserTypes::Notice:
return "notice";
}
return "notice";
}
void StatusBuildOutputController::run( 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]+" }, "error" ) );
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 );
auto res = pbm->run(
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]( 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 );
} );
} );
if ( !res.isValid() ) {
mApp->getNotificationCenter()->addNotification( res.errorMsg );
}
}
UICodeEditor* StatusBuildOutputController::createContainer() {
UICodeEditor* editor = UICodeEditor::NewOpt( true, true );
editor->setLocked( true );