Esempio n. 1
0
void attemptMigrate( KDevelop::IProject* project )
{
    if ( !baseGroup(project).hasKey( Config::Old::projectBuildDirs ) )
    {
        qCDebug(CMAKE) << "CMake settings migration: already done, exiting";
        return;
    }

    KConfigGroup baseGrp = baseGroup(project);

    KDevelop::Path buildDir( baseGrp.readEntry( Config::Old::currentBuildDirKey, QString() ) );
    int buildDirIndex = -1;
    const QStringList existingBuildDirs = baseGrp.readEntry( Config::Old::projectBuildDirs, QStringList() );
    {
        // also, find current build directory in this list (we need an index, not path)
        QString currentBuildDirCanonicalPath = QDir( buildDir.toLocalFile() ).canonicalPath();

        for( int i = 0; i < existingBuildDirs.count(); ++i )
        {
            const QString& nextBuildDir = existingBuildDirs.at(i);
            if( QDir(nextBuildDir).canonicalPath() == currentBuildDirCanonicalPath )
            {
                buildDirIndex = i;
            }
        }
    }
    int buildDirsCount = existingBuildDirs.count();

    qCDebug(CMAKE) << "CMake settings migration: existing build directories" << existingBuildDirs;
    qCDebug(CMAKE) << "CMake settings migration: build directory count" << buildDirsCount;
    qCDebug(CMAKE) << "CMake settings migration: current build directory" << buildDir << "(index" << buildDirIndex << ")";

    baseGrp.writeEntry( Config::buildDirCountKey, buildDirsCount );
    baseGrp.writeEntry( Config::buildDirIndexKey, buildDirIndex );

    for (int i = 0; i < buildDirsCount; ++i)
    {
        qCDebug(CMAKE) << "CMake settings migration: writing group" << i << ": path" << existingBuildDirs.at(i);

        KConfigGroup buildDirGrp = buildDirGroup( project, i );
        buildDirGrp.writeEntry( Config::Specific::buildDirPathKey, existingBuildDirs.at(i) );
    }

    baseGrp.deleteEntry( Config::Old::currentBuildDirKey );
    baseGrp.deleteEntry( Config::Old::currentCMakeBinaryKey );
    baseGrp.deleteEntry( Config::Old::currentBuildTypeKey );
    baseGrp.deleteEntry( Config::Old::currentInstallDirKey );
    baseGrp.deleteEntry( Config::Old::currentEnvironmentKey );
    baseGrp.deleteEntry( Config::Old::currentExtraArgumentsKey );
    baseGrp.deleteEntry( Config::Old::projectBuildDirs );
}
Esempio n. 2
0
void QMakeBuilderPreferences::addBuildConfig()
{
    if (!verifyChanges()) {
        return;
    }
    qCDebug(KDEV_QMAKEBUILDER) << "Adding a new config.";
    // for more simpicity, just launch regular dialog
    auto dlg = new QMakeBuildDirChooserDialog(m_project);
    if (dlg->exec() == QDialog::Accepted) {
        m_prefsUi->buildDirCombo->setCurrentItem(dlg->buildDir(), true);
        m_prefsUi->removeButton->setEnabled(m_prefsUi->buildDirCombo->count() > 1);
        // TODO run qmake
    }
}
Esempio n. 3
0
static QScriptValue js_baseDir(QScriptContext *ctx, QScriptEngine *engine,
                               const Artifact *artifact)
{
    Q_UNUSED(ctx);
    Q_UNUSED(engine);
    QString basedir;
    if (artifact->artifactType == Artifact::SourceFile) {
        QDir sourceDir(artifact->product->sourceDirectory);
        basedir = FileInfo::path(sourceDir.relativeFilePath(artifact->filePath()));
    } else {
        QDir buildDir(artifact->product->buildDirectory());
        basedir = FileInfo::path(buildDir.relativeFilePath(artifact->filePath()));
    }
    return basedir;
}
Esempio n. 4
0
QString FilePath::pluginPath(const QString& name)
{
    QStringList pluginPaths;

    QDir buildDir(QCoreApplication::applicationDirPath() + "/autotype");
    Q_FOREACH (const QString& dir, buildDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
        pluginPaths << QCoreApplication::applicationDirPath() + "/autotype/" + dir;
    }

    // for TestAutoType
    pluginPaths << QCoreApplication::applicationDirPath() + "/../src/autotype/test";

    pluginPaths << QCoreApplication::applicationDirPath();

    QString configuredPluginDir = KEEPASSX_PLUGIN_DIR;
    if (configuredPluginDir != ".") {
        if (QDir(configuredPluginDir).isAbsolute()) {
            pluginPaths << configuredPluginDir;
        }
        else {
            QString relativePluginDir = QString("%1/../%2")
                    .arg(QCoreApplication::applicationDirPath(), configuredPluginDir);
            pluginPaths << QDir(relativePluginDir).canonicalPath();

            QString absolutePluginDir = QString("%1/%2")
                    .arg(KEEPASSX_PREFIX_DIR, configuredPluginDir);
            pluginPaths << QDir(absolutePluginDir).canonicalPath();
        }
    }

    QStringList dirFilter;
    dirFilter << QString("*%1*").arg(name);

    Q_FOREACH (const QString& path, pluginPaths) {
        QStringList fileCandidates = QDir(path).entryList(dirFilter, QDir::Files);

        Q_FOREACH (const QString& file, fileCandidates) {
            QString filePath = path + "/" + file;

            if (QLibrary::isLibrary(filePath)) {
                return filePath;
            }
        }
Esempio n. 5
0
bool ROSUtils::hasBuildDirectory(const Utils::FileName &workspaceDir)
{
  Utils::FileName buildDir(workspaceDir);
  buildDir.appendPath(QLatin1String("build"));
  return buildDir.exists();
}
Esempio n. 6
0
bool TargetRunner::Load()
{
    LOG (INFO) << "Reading config file...";
    TiXmlDocument doc( VFS->GetRelativePath(this->configPath).c_str());
    bool status = doc.LoadFile();
    if (!status)
    {
        LOG (LERROR) << "LERROR on loading xml document!";
        return false;
    }

    TiXmlElement *target = doc
                    .FirstChildElement(Constants::XML_TAG_BUILD_CONFIG)
                    ->FirstChildElement(Constants::XML_TAG_BUILD_TARGET);
    TiXmlElement *opt;
    while (target)
    {
        const char* value = target->Attribute(Constants::XML_ATTR_TARGET_NAME);
        if (!value)
        {
            LOG(LERROR) << "Every target must have a name!";
            return false;
        }
        cpp0x::shared_ptr<Target> buildTarget (new Target());
        cpp0x::shared_ptr<std::string> name(new std::string(value));
        buildTarget->SetTargetName(name);

        if (std::string(value).compare(Constants::DEFAULT_TARGET_NAME) == 0)
        {
            value = target->Attribute(Constants::XML_ATTR_TO_BE_BUILT);
            if (value)
            {
                defaultTargetName = std::string(value);
            }
        }

        if (opt = target->FirstChildElement(Constants::XML_TAG_PLATFORM))
        {
            cpp0x::shared_ptr<std::string> platform(new std::string(opt->GetText()));
            buildTarget->SetPlatform(platform);
        }

        if (opt = target->FirstChildElement(Constants::XML_TAG_PROJECT_DIR))
        {
            cpp0x::shared_ptr<std::string> projectDir(new std::string(opt->GetText()));
            buildTarget->SetProjectDir(projectDir);
        }

        if (opt = target->FirstChildElement(Constants::XML_TAG_BUILD_DIR))
        {
            cpp0x::shared_ptr<std::string> buildDir(new std::string(opt->GetText()));
            buildTarget->SetBuildDir(buildDir);
        }

        if (opt = target->FirstChildElement(Constants::XML_TAG_CMAKE_PROJECT_TYPE))
        {
            cpp0x::shared_ptr<std::string> cmakeProjectType(new std::string(opt->GetText()));
            buildTarget->SetCmakeProjectType(cmakeProjectType);
        }

        if (opt = target->FirstChildElement(Constants::XML_TAG_CUSTOM_ARGS))
        {
            cpp0x::shared_ptr<std::string> customArgs(new std::string(opt->GetText()));
            buildTarget->SetCustomArgs(customArgs);
        }

        if (opt = target->FirstChildElement(Constants::XML_TAG_PROJECTS_ROOT_DIR))
        {
            cpp0x::shared_ptr<std::string> projectsRootDir(new std::string(opt->GetText()));
            buildTarget->SetProjectsRootDir(projectsRootDir);
        }

        if (opt = target->FirstChildElement(Constants::XML_TAG_KRAL_PATH))
        {
            cpp0x::shared_ptr<std::string> kralPath(new std::string(opt->GetText()));
            buildTarget->SetKralPath(kralPath);
        }

        if (opt = target->FirstChildElement(Constants::XML_TAG_CMAKE))
        {
            cpp0x::shared_ptr<std::string> cmake(new std::string(opt->GetText()));
            buildTarget->SetCmake(cmake);
        }

        if (opt = target->FirstChildElement(Constants::XML_TAG_ANDROID_API_LEVEL))
        {
            cpp0x::shared_ptr<std::string> androidApiLevel(new std::string(opt->GetText()));
            buildTarget->SetAndroidApiLevel(androidApiLevel);
        }

        if (opt = target->FirstChildElement(Constants::XML_TAG_ANDROID_ARM_TARGET))
        {
            cpp0x::shared_ptr<std::string> value(new std::string(opt->GetText()));
            buildTarget->SetAndroidArmTarget(value);
        }

           if (opt = target->FirstChildElement(Constants::XML_TAG_BUILD_TYPE))
        {
            cpp0x::shared_ptr<std::string> value(new std::string(opt->GetText()));
            buildTarget->SetBuildType(value);
        } else {
            cpp0x::shared_ptr<std::string> value(new std::string("Debug"));
            buildTarget->SetBuildType(value);
        }

           if (opt = target->FirstChildElement(Constants::XML_TAG_ANDROID_ASSETS))
        {
            cpp0x::shared_ptr<std::string> value(new std::string(opt->GetText()));
            buildTarget->SetAssets(value);
        }
   
        if (opt = target->FirstChildElement(Constants::XML_TAG_COMPILER_CUSTOM_OPTS))
        {
            cpp0x::shared_ptr<std::string> value(new std::string(opt->GetText()));
            buildTarget->SetCompilerCustomOptions(value);
        }
        
        if (opt = target->FirstChildElement(Constants::XML_TAG_PACKAGE_DIRS))
        {
            cpp0x::shared_ptr<std::string> value(new std::string(opt->GetText()));
            buildTarget->SetPackageDirs(value);
        }

        if (buildTarget->GetTargetName()->compare(Constants::DEFAULT_TARGET_NAME) == 0)
        {
            this->defaultTarget = buildTarget;
        } else {
            this->targets.push_back(buildTarget);
        }
        target = target->NextSiblingElement();
    }
    return true;
}