void ClangCodeCompletion::OnBuildStarting(clBuildEvent& e)
{
    e.Skip();
    CHECK_CLANG_ENABLED_RET();

    // Determine the compilation database
    CompilationDatabase cdb;
    cdb.Open();
    cdb.Close();

    // Set the compilation database environment variable
    ::wxSetEnv(wxT("CL_COMPILATION_DB"), cdb.GetFileName().GetFullPath());

    // If this is NOT a custom project, set the CXX and CC environment
    wxString  project = e.GetProjectName();
    wxString  config  = e.GetConfigurationName();
    
    BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf(project, config);
    if( bldConf && !bldConf->IsCustomBuild()) {
        wxString cxx = bldConf->GetCompiler()->GetTool(wxT("CXX"));
        wxString cc  = bldConf->GetCompiler()->GetTool(wxT("CC"));
        
        cxx.Prepend(wxT("codelitegcc "));
        cc.Prepend(wxT("codelitegcc "));
        
        ::wxSetEnv("CXX", cxx);
        ::wxSetEnv("CC" ,  cc);
    }
}
Example #2
0
void QMakePlugin::OnBuildStarting(clBuildEvent& event)
{
    // call Skip() to allow the standard compilation to take place
    event.Skip();

    QmakePluginData::BuildConfPluginData bcpd;
    wxString project = event.GetProjectName();
    wxString config = event.GetConfigurationName();

    if(!DoGetData(project, config, bcpd)) { return; }

    if(!bcpd.m_enabled) { return; }

    // OK this is a qmake project
    event.Skip(false);

    wxString errMsg;
    ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project, errMsg);
    if(!p) { return; }
    QMakeProFileGenerator generator(m_mgr, project, config);
    if(!wxFileName::Exists(generator.GetProFileName())) {
        // alert and return
        ::wxMessageBox(_("Could not locate pro file.\nDid you remember to run qmake? (right click on the project"),
                       "QMake", wxICON_WARNING | wxCENTER);
        return;
    } else {
        event.Skip();
    }
}
Example #3
0
void QMakePlugin::OnBuildStarting(clBuildEvent& event)
{
    // call Skip() to allow the standard compilation to take place
    event.Skip();

    QmakePluginData::BuildConfPluginData bcpd;
    wxString  project = event.GetProjectName();
    wxString  config  = event.GetConfigurationName();

    if ( !DoGetData(project, config, bcpd) ) {
        return;
    }

    if ( !bcpd.m_enabled ) {
        return;
    }

    wxString errMsg;
    ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project, errMsg);
    if ( !p ) {
        return;
    }
    QMakeProFileGenerator generator(m_mgr, project, config);

    // regenrate the .pro file
    bool needRegeneration = generator.Generate();

    wxString qmake_exe = m_conf->Read(wxString::Format(wxT("%s/qmake"),     bcpd.m_qmakeConfig.c_str()));
    wxString qmakespec = m_conf->Read(wxString::Format(wxT("%s/qmakespec"), bcpd.m_qmakeConfig.c_str()));
    wxString qtdir     = m_conf->Read(wxString::Format(wxT("%s/qtdir"),     bcpd.m_qmakeConfig.c_str()));

    // Create qmake comand
    wxString qmake_exe_line;
    qmake_exe.Trim().Trim(false);
    qmakespec.Trim().Trim(false);

    // Set QTDIR
    DirSaver ds;
    {

        wxSetWorkingDirectory ( p->GetFileName().GetPath(wxPATH_GET_SEPARATOR|wxPATH_GET_VOLUME) );
        wxSetEnv(wxT("QTDIR"), qtdir);
        qmake_exe_line << wxT("\"") << qmake_exe << wxT("\" -spec ") << qmakespec << wxT(" ") << generator.GetProFileName();

        if ( needRegeneration ) {
            wxArrayString output;
            ProcUtils::SafeExecuteCommand(qmake_exe_line, output);
        }

    }
}
Example #4
0
void
CMakePlugin::ProcessBuildEvent(clBuildEvent& event, wxString param)
{
    wxString project = event.GetProjectName();
    const wxString config  = event.GetConfigurationName();

    // Get settings
    const CMakeProjectSettings* settings = GetSettingsManager()->GetProjectSettings(project, config);

    // Doesn't exists or not enabled
    if (!settings || !settings->enabled) {
        // Unable to export makefile
        event.Skip();
        return;
    }

    // Project has parent project
    if (!settings->parentProject.IsEmpty()) {
        // Add project name as target
        param = project + " " + param;
        // Build parent project
        project = settings->parentProject;
    }

    // Workspace directory
    const wxFileName workspaceDir = GetWorkspaceDirectory();

    // Use relative path
    wxFileName projectDir = GetProjectDirectory(project);
    projectDir.MakeRelativeTo(workspaceDir.GetFullPath());

    const wxString projectDirEsc = projectDir.GetPath(wxPATH_NO_SEPARATOR, wxPATH_UNIX);

    // Build command
    wxString cmd = "$(MAKE)";

    if (!projectDirEsc.IsEmpty())
        cmd += " -C \"" + projectDirEsc + "\"";

    // Add makefile
    cmd += " -f \"" + project + ".mk\"";

    // Add optional parameters
    if (!param.IsEmpty())
        cmd += " " + param;

    // The build command is simple make call with different makefile
    event.SetCommand(cmd);
}
void CodeCompletionManager::OnBuildEnded(clBuildEvent& e)
{
    e.Skip();
    DoUpdateCompilationDatabase();
    DoProcessCompileCommands();
    m_buildInProgress = false;
}
Example #6
0
void LLDBPlugin::OnBuildStarting(clBuildEvent& event)
{
    if(m_connector.IsRunning()) {
        // lldb session is active, prompt the user
        if(::wxMessageBox(_("A debug session is running\nCancel debug session and continue building?"), "CodeLite",
                          wxICON_QUESTION | wxYES_NO | wxYES_DEFAULT | wxCENTER) == wxYES) {
            clDebugEvent dummy;
            OnDebugStop(dummy);
            event.Skip();
        } else {
            // do nothing - this will cancel the build
        }

    } else {
        event.Skip();
    }
}
Example #7
0
void CMakePlugin::OnGetIsPluginMakefile(clBuildEvent& event)
{
    wxString project = event.GetProjectName();
    const wxString config = event.GetConfigurationName();

    // Get settings
    const CMakeProjectSettings* settings = GetSettingsManager()->GetProjectSettings(project, config);

    // Doesn't exists or not enabled
    if(!settings || !settings->enabled) {
        // Cannot provide custom makefile
        event.Skip();
        return;
    }

    // Custom makefile is provided
}
Example #8
0
void QMakePlugin::OnGetIsPluginMakefile(clBuildEvent& event)
{
    QmakePluginData::BuildConfPluginData bcpd;

    wxString project = event.GetProjectName();
    wxString config  = event.GetConfigurationName();

    if ( !DoGetData(project, config, bcpd) ) {
        event.Skip();
        return;
    }

    if ( bcpd.m_enabled ) {
        // return without calling event.Skip()
        return;
    }
    event.Skip();
}
void ClangCodeCompletion::OnBuildEnded(clBuildEvent& e)
{
    e.Skip();
    CHECK_CLANG_ENABLED_RET();

    // Clear environment variables previously set by this class
    ::wxUnsetEnv("CL_COMPILATION_DB");
    ::wxUnsetEnv("CXX");
    ::wxUnsetEnv("CC");

    // Clear the TU cache
    ClearCache();
}
Example #10
0
void ClangCodeCompletion::OnBuildEnded(clBuildEvent& e)
{
    e.Skip();
    CHECK_CLANG_ENABLED_RET();

    // Clear environment variables previously set by this class
    ::wxUnsetEnv(wxT("CL_COMPILATION_DB"));
    ::wxUnsetEnv(wxT("CXX"));
    ::wxUnsetEnv(wxT("CC"));
    
    // Create a worker thread (detached thread) that 
    // will initialize the database now that the compilation is ended
    CompilationDatabase db;
    ClangCompilationDbThread* thr = new ClangCompilationDbThread( db.GetFileName().GetFullPath() );
    thr->Start();
    
    // Clear the TU cache
    ClearCache();
}
Example #11
0
void QMakePlugin::OnGetCleanCommand(clBuildEvent& event)
{
    QmakePluginData::BuildConfPluginData bcpd;

    wxString  project = event.GetProjectName();
    wxString  config  = event.GetConfigurationName();

    if ( !DoGetData(project, config, bcpd) ) {
        event.Skip();
        return;
    }

    if ( !bcpd.m_enabled ) {
        event.Skip();
        return;
    }

    event.SetCommand( DoGetBuildCommand(project, config, event.IsProjectOnly()) + wxT(" clean") );
}
Example #12
0
void QMakePlugin::OnGetBuildCommand(clBuildEvent& event)
{
    QmakePluginData::BuildConfPluginData bcpd;

    wxString  project = event.GetProjectName();
    wxString  config  = event.GetConfigurationName();

    if ( !DoGetData(project, config, bcpd) ) {
        event.Skip();
        return;
    }

    if ( !bcpd.m_enabled ) {
        event.Skip();
        return;
    }

    // we avoid calling event.Skip() to override the default build system by this one
    event.SetCommand( DoGetBuildCommand(project, config, event.IsProjectOnly()) );
}
Example #13
0
void OutputPane::OnBuildEnded(clBuildEvent& e)
{
    e.Skip();
    m_buildInProgress = false;
}
Example #14
0
void
CMakePlugin::OnExportMakefile(clBuildEvent& event)
{
    const wxString project = event.GetProjectName();
    const wxString config  = event.GetConfigurationName();

    // Get settings
    const CMakeProjectSettings* settings = GetSettingsManager()->GetProjectSettings(project, config);

    // Doesn't exists or not enabled
    if (!settings || !settings->enabled) {
        // Unable to export makefile
        event.Skip();
        return;
    }

    // Get project directory - this is directory where the makefile is stored
    const wxFileName projectDir = GetProjectDirectory(project);

    // Targets forward inspired by
    // https://gist.github.com/doitian/4978329

    // Content of the generated makefile
    wxString content = wxString() <<
        "# Generated by CMakePlugin\n"
        ".PHONY: all clean $(MAKECMDGOALS)\n"
        "\n"
    ;

    // Parent project is set
    if (!settings->parentProject.IsEmpty()) {
        // Configure parent project instead
        const wxString& parentProject = settings->parentProject;
        settings = GetSettingsManager()->GetProjectSettings(parentProject, config);

        // Parent project not found
        if (!settings || !settings->enabled) {
            CL_ERROR("Unable to find or not enabled parent project "
                "'" + parentProject + "' for project '" + project + "'");
            return;
        }

        // Get parent project directory
        wxFileName parentProjectDir = GetProjectDirectory(parentProject);
        parentProjectDir.MakeRelativeTo(projectDir.GetFullPath());

        // Path is relative so UNIX path system can be used
        const wxString parentProjectDirEsc = parentProjectDir.GetPath(wxPATH_NO_SEPARATOR, wxPATH_UNIX);

        // Redirect make to the parent project
        content <<
            "# Parent project\n"
            "PARENT          := " << parentProjectDirEsc << "\n"
            "PARENT_MAKEFILE := " << parentProject << ".mk\n"
            "\n"
            "all:\n"
            "\t$(MAKE) -C \"$(PARENT)\" -f \"$(PARENT_MAKEFILE)\" " << project << "\n"
            "\n"
            "clean:\n"
            "\t$(MAKE) -C \"$(PARENT)\" -f \"$(PARENT_MAKEFILE)\" " << project << " clean\n"
            "\n"
        ;

    } else {

        // Macro expander
        // FIXME use IMacroManager (unable to find it yet)
        MacroManager* macro = MacroManager::Instance();
        wxASSERT(macro);

        // Get variables
        // Expand variables for final project
        const wxString cmake = GetConfiguration()->GetProgramPath();
        wxFileName sourceDir = wxFileName::DirName(macro->Expand(settings->sourceDirectory, GetManager(), project, config));
        wxFileName buildDir = wxFileName::DirName(macro->Expand(settings->buildDirectory, GetManager(), project, config));

        // Source dir must be relative to build directory (here is cmake called)
        sourceDir.MakeRelativeTo(buildDir.GetFullPath());
        // Build dir must be relative to project directory
        buildDir.MakeRelativeTo(projectDir.GetFullPath());

        // Relative paths
        const wxString sourceDirEsc = sourceDir.GetPath(wxPATH_NO_SEPARATOR, wxPATH_UNIX);
        const wxString buildDirEsc = buildDir.GetPath(wxPATH_NO_SEPARATOR, wxPATH_UNIX);

        // Generated makefile
        content <<
            "CMAKE      := \"" << cmake << "\"\n"
            "BUILD_DIR  := " << buildDirEsc << "\n"
            "SOURCE_DIR := " << sourceDirEsc << "\n"
            "CMAKE_ARGS := " << CreateArguments(*settings, *m_configuration.get()) << "\n"
            "\n"
            "# Building project(s)\n"
            "$(or $(lastword $(MAKECMDGOALS)), all): $(BUILD_DIR)/Makefile\n"
            "\t$(MAKE) -C \"$(BUILD_DIR)\" $(MAKECMDGOALS)\n"
            "\n"
            "# Building directory\n"
            "$(BUILD_DIR):\n"
            "\t$(CMAKE) -E make_directory \"$(BUILD_DIR)\"\n"
            "\n"
            "# Rule that detects if cmake is called\n"
            "$(BUILD_DIR)/Makefile: .cmake_dirty | $(BUILD_DIR)\n"
            "\tcd \"$(BUILD_DIR)\" && $(CMAKE) $(CMAKE_ARGS) \"$(SOURCE_DIR)\"\n"
            "\n"
            "# This rule / file allows force cmake run\n"
            ".cmake_dirty:\n"
            "\t@echo '' > .cmake_dirty\n"
            "\n"
        ;

    }

    // Path to makefile - called project directory required
    wxFileName makefile = projectDir;
    makefile.SetName(project);
    makefile.SetExt("mk");

    // Read old content from disk
    wxString oldContent;
    bool ok = ReadFileWithConversion(makefile.GetFullPath(), oldContent);

    // Write only if there are some changes
    if (!ok || content != oldContent) {
        // Write make file content
        wxFile file(makefile.GetFullPath(), wxFile::write);

        if (!file.Write(content)) {
            CL_ERROR("Unable to write custom makefile (CMakePlugin): " + makefile.GetFullPath());
        }
    }
}
void CodeCompletionManager::OnBuildStarted(clBuildEvent& e)
{
    e.Skip();
    m_buildInProgress = true;
}
void CodeCompletionManager::OnBuildEnded(clBuildEvent& e)
{
    e.Skip();
    DoUpdateCompilationDatabase();
}
Example #17
0
void OutputPane::OnBuildStarted(clBuildEvent& e)
{
    e.Skip();
    m_buildInProgress = true;
}