| 90 | } |
| 91 | |
| 92 | KJob* CMakeBuilder::build(KDevelop::ProjectBaseItem *dom) |
| 93 | { |
| 94 | KDevelop::IProject* p = dom->project(); |
| 95 | IProjectBuilder* builder = builderForProject(p); |
| 96 | if( builder ) |
| 97 | { |
| 98 | bool valid; |
| 99 | KJob* configure = checkConfigureJob(dom->project(), valid); |
| 100 | |
| 101 | KJob* build = nullptr; |
| 102 | if(dom->file()) |
| 103 | { |
| 104 | auto* makeBuilder = dynamic_cast<IMakeBuilder*>(builder); |
| 105 | if (!makeBuilder) { |
| 106 | return new ErrorJob(this, i18n("Could not find the make builder. Check your installation")); |
| 107 | } |
| 108 | |
| 109 | KDevelop::ProjectFileItem* file = dom->file(); |
| 110 | const auto projectFileName = file->text(); |
| 111 | const auto projectFileBaseName = KDevelop::leftOfLastNeedleOrEntireView(projectFileName, QLatin1Char{'.'}); |
| 112 | |
| 113 | const QString target = projectFileBaseName + QLatin1String(".o"); |
| 114 | build = makeBuilder->executeMakeTarget(dom->parent(), target); |
| 115 | qCDebug(KDEV_CMAKEBUILDER) << "create build job for target" << build << dom << target; |
| 116 | } |
| 117 | qCDebug(KDEV_CMAKEBUILDER) << "Building with" << builder; |
| 118 | if (!build) |
| 119 | { |
| 120 | build = builder->build(dom); |
| 121 | } |
| 122 | if( configure ) |
| 123 | { |
| 124 | qCDebug(KDEV_CMAKEBUILDER) << "creating composite job"; |
| 125 | auto* builderJob = new KDevelop::BuilderJob; |
| 126 | builderJob->addCustomJob( KDevelop::BuilderJob::Configure, configure, dom ); |
| 127 | builderJob->addCustomJob( KDevelop::BuilderJob::Build, build, dom ); |
| 128 | builderJob->updateJobName(); |
| 129 | build = builderJob; |
| 130 | } |
| 131 | return build; |
| 132 | } |
| 133 | return new ErrorJob(this, i18n("Could not find a builder for %1", p->name())); |
| 134 | } |
| 135 | |
| 136 | KJob* CMakeBuilder::clean(KDevelop::ProjectBaseItem *dom) |
| 137 | { |
no test coverage detected