void BuildSettingsConfig::SaveBuilderConfig(BuilderPtr builder)
{
    //update configuration file
    BuilderConfigPtr bsptr(new BuilderConfig(NULL));
    bsptr->SetName(builder->GetName());
   bsptr->SetIsActive(builder->IsActive());
    SetBuildSystem(bsptr);
}
Beispiel #2
0
void BuildPage::CustomInit()
{
	//rest of builders list
	std::list<wxString> builders;
	BuildManagerST::Get()->GetBuilders(builders);

	std::list<wxString>::iterator iter = builders.begin();
	for(; iter != builders.end(); iter++){
		BuilderPtr builder = BuildManagerST::Get()->GetBuilder(*iter);
		m_bookBuildSystems->AddPage(CreateBuildSystemPage(*iter), *iter, builder->IsActive());
	}
}
Beispiel #3
0
void BuildSystemPage::Save()
{
	//update cached builders
	BuilderPtr builder = BuildManagerST::Get()->GetBuilder(m_name);
	builder->SetBuildTool(m_filePicker->GetPath());
	builder->SetBuildToolOptions(m_textBuildToolOptions->GetValue());
	builder->SetBuildToolJobs(m_choiceJobs->GetValue());
	BuildManagerST::Get()->AddBuilder(builder);
	
	// Save the configuration
	BuildSettingsConfigST::Get()->SaveBuilderConfig(builder);
}
Beispiel #4
0
void BuildManager::AddBuilder(BuilderPtr builder)
{
    if(!builder) {
        return;
    }

    m_builders[builder->GetName()] = builder;
}
Beispiel #5
0
ObjectInfoPtr ConfigObjectLoader::getObjectInfo( expr_cref expr, str_cref name ) const
{
	if( !name.empty() )
	{
		ObjectInfoPtr obj;

		// already found.
		if( Utility::mapLookup( m_objects, name, obj ) )
		{
			return obj;
		}
	}

	if( expr.type() == EObject ) // it's an object expression
	{
		std::string className = expr.value();
		ClassInfoPtr classInfo = getClassInfo( className );
		BuilderPtr builder = classInfo->createBuilder( name, expr );
        ObjectInfoPtr obj( new ObjectInfo( name, expr, *classInfo, builder ) );

        // It needs to be in the map before we bind its parameters so a circular reference can be detected
        m_objects[name] = obj;
        builder->bindParams( *this );
		return obj;
	}
	else if( expr.type() == EVariable )
	{
		// this could recurse indefinitely with circular reference..

		// NOTE: if anything throws here, let ParamBinderBase manage the context of the error.

		std::string objName;
		expr_cref expr2 = underlying( expr, &objName );
		return getObjectInfo( expr2, objName );
	}
	else // this isn't a class. It might be a map or list or whatever but isn't an object
	{
		std::ostringstream oss;
		oss << expr.value() << " is not an object";

		// Do not throw TypeError here. If it isn't an object it can't be a proxy either
		throw std::invalid_argument( oss.str() );
	}

}
// do the actual cleanup
void CompileRequest::Process(IManager* manager)
{
    wxString cmd;
    wxString errMsg;
    wxStringMap_t om;

    BuildSettingsConfig* bsc(manager ? manager->GetBuildSettingsConfigManager() : BuildSettingsConfigST::Get());
    BuildManager* bm(manager ? manager->GetBuildManager() : BuildManagerST::Get());
    clCxxWorkspace* w(manager ? manager->GetWorkspace() : clCxxWorkspaceST::Get());
    EnvironmentConfig* env(manager ? manager->GetEnv() : EnvironmentConfig::Instance());

    ProjectPtr proj = w->FindProjectByName(m_info.GetProject(), errMsg);
    if(!proj) {
        AppendLine(_("Cant find project: ") + m_info.GetProject());
        return;
    }

    wxString pname(proj->GetName());
    // BuilderPtr builder = bm->GetBuilder(wxT("GNU makefile for g++/gcc"));
    BuilderPtr builder = bm->GetSelectedBuilder();
    if(m_fileName.IsEmpty() == false) {
        // we got a complie request of a single file
        cmd = m_preprocessOnly ?
                  builder->GetPreprocessFileCmd(m_info.GetProject(), m_info.GetConfiguration(), m_fileName, errMsg) :
                  builder->GetSingleFileCmd(m_info.GetProject(), m_info.GetConfiguration(), m_fileName);
    } else if(m_info.GetProjectOnly()) {

        switch(m_info.GetKind()) {
        case QueueCommand::kRebuild:
            cmd = builder->GetPORebuildCommand(m_info.GetProject(), m_info.GetConfiguration());
            break;
        default:
        case QueueCommand::kBuild:
            cmd = builder->GetPOBuildCommand(m_info.GetProject(), m_info.GetConfiguration());
            break;
        }

    } else {
        cmd = builder->GetBuildCommand(m_info.GetProject(), m_info.GetConfiguration());
    }

    // Notify plugins that a compile process is going to start
    clBuildEvent event(wxEVT_BUILD_STARTING);
    event.SetProjectName(pname);
    event.SetConfigurationName(m_info.GetConfiguration());

    if(EventNotifier::Get()->ProcessEvent(event)) {

        // the build is being handled by some plugin, no need to build it
        // using the standard way
        return;
    }

    // Send the EVENT_STARTED : even if this event is sent, next event will
    // be post, so no way to be sure the the build process has not started
    SendStartMsg();

    // if we require to run the makefile generation command only, replace the 'cmd' with the
    // generation command line
    BuildConfigPtr bldConf = w->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration());
    if(m_premakeOnly && bldConf) {
        BuildConfigPtr bldConf = w->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration());
        if(bldConf) {
            cmd = bldConf->GetMakeGenerationCommand();
        }
    }

    if(bldConf) {
        wxString cmpType = bldConf->GetCompilerType();
        CompilerPtr cmp = bsc->GetCompiler(cmpType);
        if(cmp) {
            // Add the 'bin' folder of the compiler to the PATH environment variable
            wxString scxx = cmp->GetTool("CXX");
            scxx.Trim().Trim(false);
            scxx.StartsWith("\"", &scxx);
            scxx.EndsWith("\"", &scxx);
            // Strip the double quotes
            wxFileName cxx(scxx);
            wxString pathvar;
            pathvar << cxx.GetPath() << clPATH_SEPARATOR;
            
            // If we have an additional path, add it as well
            if(!cmp->GetPathVariable().IsEmpty()) {
                pathvar << cmp->GetPathVariable() << clPATH_SEPARATOR;
            }
            pathvar << "$PATH";
            om["PATH"] = pathvar;
        }
    }

    if(cmd.IsEmpty()) {
        // if we got an error string, use it
        if(errMsg.IsEmpty() == false) {
            AppendLine(errMsg);
        } else {
            AppendLine(_("Command line is empty. Build aborted."));
        }
        return;
    }

    WrapInShell(cmd);
    DirSaver ds;

    DoSetWorkingDirectory(proj, false, m_fileName.IsEmpty() == false);

    // expand the variables of the command
    cmd = ExpandAllVariables(cmd, w, m_info.GetProject(), m_info.GetConfiguration(), m_fileName);

    // print the build command
    AppendLine(cmd + wxT("\n"));
    if(m_info.GetProjectOnly() || m_fileName.IsEmpty() == false) {
        // set working directory
        DoSetWorkingDirectory(proj, false, m_fileName.IsEmpty() == false);
    }

    // print the prefix message of the build start. This is important since the parser relies
    // on this message
    if(m_info.GetProjectOnly() || m_fileName.IsEmpty() == false) {
        wxString configName(m_info.GetConfiguration());

        // also, send another message to the main frame, indicating which project is being built
        // and what configuration
        wxString text;
        text << wxGetTranslation(BUILD_PROJECT_PREFIX) << m_info.GetProject() << wxT(" - ") << configName << wxT(" ]");
        if(m_fileName.IsEmpty()) {
            text << wxT("----------\n");
        } else if(m_preprocessOnly) {
            text << wxT(" (Preprocess Single File)----------\n");
        } else {
            text << wxT(" (Single File Build)----------\n");
        }
        AppendLine(text);
    }

    EnvSetter envir(env, &om, proj->GetName());
    m_proc = CreateAsyncProcess(this, cmd);
    if(!m_proc) {
        wxString message;
        message << _("Failed to start build process, command: ") << cmd << _(", process terminated with exit code: 0");
        AppendLine(message);
        return;
    }
}
Beispiel #7
0
//do the actual cleanup
void CleanRequest::Process(IManager *manager)
{
    wxString cmd;
    wxString errMsg;
    wxStringMap_t om;

    BuildSettingsConfig *bsc(manager ? manager->GetBuildSettingsConfigManager() : BuildSettingsConfigST::Get());
    BuildManager *       bm(manager ? manager->GetBuildManager() : BuildManagerST::Get());
    Workspace *          w(manager ? manager->GetWorkspace() : WorkspaceST::Get());


    ProjectPtr proj = w->FindProjectByName(m_info.GetProject(), errMsg);
    if (!proj) {
        AppendLine(_("Cant find project: ") + m_info.GetProject());
        return;
    }
    wxString             pname (proj->GetName());

    //BuilderPtr builder = bm->GetBuilder(wxT("GNU makefile for g++/gcc"));
    BuilderPtr builder = bm->GetSelectedBuilder();
    if (m_info.GetProjectOnly()) {
        cmd = builder->GetPOCleanCommand(m_info.GetProject(), m_info.GetConfiguration());
    } else {
        cmd = builder->GetCleanCommand(m_info.GetProject(), m_info.GetConfiguration());
    }

    if ( cmd.IsEmpty() ) {
        AppendLine(_("Sorry, there is no 'Clean' command available\n"));
        return;
    }

    BuildConfigPtr bldConf = w->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration());
    if(bldConf) {
        wxString cmpType = bldConf->GetCompilerType();
        CompilerPtr cmp = bsc->GetCompiler(cmpType);
        if(cmp) {
            wxString value( cmp->GetPathVariable() );
            if(value.Trim().Trim(false).IsEmpty() == false) {
                wxLogMessage(wxString::Format(wxT("Setting PATH to '%s'"), value.c_str()));
                om[wxT("PATH")] = value.Trim().Trim(false);
            }
        }
    } else {
        AppendLine(_("Sorry, couldn't find the Build configuration\n"));
        return;
    }

    // Notify plugins that a compile process is going to start
    clBuildEvent event(wxEVT_BUILD_STARTING);
    event.SetProjectName( pname );
    event.SetConfigurationName( m_info.GetConfiguration() );
    
    if (EventNotifier::Get()->ProcessEvent(event)) {
        // the build is being handled by some plugin, no need to build it
        // using the standard way
        return;
    }
    
    SendStartMsg();
    // Expand the variables of the command
    cmd = ExpandAllVariables(cmd, w, m_info.GetProject(), m_info.GetConfiguration(), wxEmptyString);
    WrapInShell(cmd);
    DirSaver ds;
    DoSetWorkingDirectory(proj, false, false);

    if (m_info.GetProjectOnly() ) {
        //need to change directory to project dir
        wxSetWorkingDirectory(proj->GetFileName().GetPath());
    }
    //print the build command
    AppendLine(cmd + wxT("\n"));

    // print the prefix message of the build start. This is important since the parser relies
    // on this message
    if(m_info.GetProjectOnly()) {
        wxString configName(m_info.GetConfiguration());

        //also, send another message to the main frame, indicating which project is being built
        //and what configuration
        wxString text;
        text << wxGetTranslation(CLEAN_PROJECT_PREFIX) << m_info.GetProject() << wxT(" - ") << configName << wxT(" ]");
        text << wxT("----------\n");
        AppendLine(text);
    }

    //apply environment settings
    EnvSetter env(NULL, &om, proj->GetName());
    m_proc = CreateAsyncProcess(this, cmd);
    if ( !m_proc ) {

        //remove environment settings applied
        wxString message;
        message << _("Failed to start clean process, command: ") << cmd << _(", process terminated with exit code: 0");
        AppendLine(message);
        return;
    }
}
Beispiel #8
0
void BuildSystemPage::SetSelected()
{
	BuilderPtr builder = BuildManagerST::Get()->GetBuilder(m_name);
	builder->SetActive();
}
void ContinuousBuild::DoBuild(const wxString& fileName)
{
	PRINT_MESSAGE(wxT("DoBuild\n"));
	// Make sure a workspace is opened
	if (!m_mgr->IsWorkspaceOpen()) {
		PRINT_MESSAGE(wxT("No workspace opened!\n"));
		return;
	}
		

	// Filter non source files
	FileExtManager::FileType type = FileExtManager::GetType(fileName);
	switch(type) {
		case FileExtManager::TypeSourceC:
		case FileExtManager::TypeSourceCpp:
		case FileExtManager::TypeResource:
			break;

		default: {
			PRINT_MESSAGE(wxT("Non source file\n"));
			return;
		}
	}

	wxString projectName = m_mgr->GetProjectNameByFile(fileName);
	if(projectName.IsEmpty()) {
		PRINT_MESSAGE(wxT("Project name is empty\n"));
		return;
	}
	
	wxString errMsg;
	ProjectPtr project = m_mgr->GetSolution()->FindProjectByName(projectName, errMsg);
	if(!project){
		PRINT_MESSAGE(wxT("Could not find project for file\n"));
		return;
	}

	// get the selected configuration to be build
	BuildConfigPtr bldConf = m_mgr->GetSolution()->GetProjBuildConf( project->GetName(), wxEmptyString );
	if ( !bldConf ) {
		PRINT_MESSAGE(wxT("Failed to locate build configuration\n"));
		return;
	}

	BuilderPtr builder = m_mgr->GetBuildManager()->GetBuilder( wxT( "GNU makefile for g++/gcc" ) );
	if(!builder){
		PRINT_MESSAGE(wxT("Failed to located builder\n"));
		return;
	}

	// Only normal file builds are supported
	if(bldConf->IsCustomBuild()){
		PRINT_MESSAGE(wxT("Build is custom. Skipping\n"));
		return;
	}

	// get the single file command to use
	wxString cmd      = builder->GetSingleFileCmd(projectName, bldConf->GetName(), fileName);
	WrapInShell(cmd);

	if( m_buildProcess.IsBusy() ) {
		// add the build to the queue
		if (m_files.Index(fileName) == wxNOT_FOUND) {
			m_files.Add(fileName);

			// update the UI
			m_view->AddFile(fileName);
		}
		return;
	}
	
	PRINT_MESSAGE(wxString::Format(wxT("cmd:%s\n"), cmd.c_str()));
	if(!m_buildProcess.Execute(cmd, fileName, project->GetFileName().GetPath(), this))
		return;

	// Set some messages
	m_mgr->SetStatusMessage(wxString::Format(wxT("Compiling %s..."), wxFileName(fileName).GetFullName().c_str()), 0);

	// Add this file to the UI queue
	m_view->AddFile(fileName);
}