예제 #1
0
static bool addFilesToResource(const Utils::FileName &resourceFile,
                               const QStringList &filePaths,
                               QStringList *notAdded,
                               const QString &prefix,
                               const QString &lang)
{
    if (notAdded)
        *notAdded = filePaths;

    ResourceFile file(resourceFile.toString());
    if (file.load() != Core::IDocument::OpenResult::Success)
        return false;

    int index = file.indexOfPrefix(prefix, lang);
    if (index == -1)
        index = file.addPrefix(prefix, lang);

    if (notAdded)
        notAdded->clear();
    foreach (const QString &path, filePaths) {
        if (file.contains(index, path)) {
            if (notAdded)
                *notAdded << path;
        } else {
            file.addFile(index, path);
        }
    }

    Core::DocumentManager::expectFileChange(resourceFile.toString());
    file.save();
    Core::DocumentManager::unexpectFileChange(resourceFile.toString());

    return true;
}
예제 #2
0
void GccToolChain::addToEnvironment(Utils::Environment &env) const
{
    if (!m_compilerCommand.isEmpty()) {
        Utils::FileName path = m_compilerCommand.parentDir();
        env.prependOrSetPath(path.toString());
    }
}
예제 #3
0
bool QMakeStep::init()
{
    Qt4BuildConfiguration *qt4bc = qt4BuildConfiguration();
    const QtSupport::BaseQtVersion *qtVersion = QtSupport::QtProfileInformation::qtVersion(target()->profile());

    if (!qtVersion)
        return false;

    QString args = allArguments();
    QString workingDirectory;

    if (qt4bc->subNodeBuild())
        workingDirectory = qt4bc->subNodeBuild()->buildDir();
    else
        workingDirectory = qt4bc->buildDirectory();

    Utils::FileName program = qtVersion->qmakeCommand();

    QString makefile = workingDirectory;

    if (qt4bc->subNodeBuild()) {
        if (!qt4bc->subNodeBuild()->makefile().isEmpty())
            makefile.append(qt4bc->subNodeBuild()->makefile());
        else
            makefile.append(QLatin1String("/Makefile"));
    } else if (!qt4bc->makefile().isEmpty()) {
        makefile.append(QLatin1Char('/'));
        makefile.append(qt4bc->makefile());
    } else {
        makefile.append(QLatin1String("/Makefile"));
    }

    // Check whether we need to run qmake
    bool makefileOutDated = (qt4bc->compareToImportFrom(makefile) != Qt4BuildConfiguration::MakefileMatches);
    if (m_forced || makefileOutDated)
        m_needToRunQMake = true;
    m_forced = false;

    ProcessParameters *pp = processParameters();
    pp->setMacroExpander(qt4bc->macroExpander());
    pp->setWorkingDirectory(workingDirectory);
    pp->setCommand(program.toString());
    pp->setArguments(args);
    pp->setEnvironment(qt4bc->environment());

    setOutputParser(new QMakeParser);

    Qt4ProFileNode *node = static_cast<Qt4Project *>(qt4bc->target()->project())->rootQt4ProjectNode();
    if (qt4bc->subNodeBuild())
        node = qt4bc->subNodeBuild();
    QString proFile = node->path();

    m_tasks = qtVersion->reportIssues(proFile, workingDirectory);
    qSort(m_tasks);

    m_scriptTemplate = node->projectType() == ScriptTemplate;

    return AbstractProcessStep::init();
}
void AndroidSettingsWidget::browseNDKLocation()
{
    Utils::FileName dir = Utils::FileName::fromString(QFileDialog::getExistingDirectory(this, tr("Select Android NDK folder")));
    if (!checkNDK(dir))
        return;
    m_ui->NDKLocationLineEdit->setText(dir.toUserOutput());
    ndkLocationEditingFinished();
}
예제 #5
0
bool BazaarControl::isConfigured() const
{
    const Utils::FileName binary = m_bazaarClient->vcsBinary();
    if (binary.isEmpty())
        return false;
    QFileInfo fi = binary.toFileInfo();
    return fi.exists() && fi.isFile() && fi.isExecutable();
}
void AndroidBuildApkWidget::updateKeyStorePath(const QString &path)
{
    Utils::FileName file = Utils::FileName::fromString(path);
    m_step->setKeystorePath(file);
    m_ui->signPackageCheckBox->setChecked(!file.isEmpty());
    if (!file.isEmpty())
        setCertificates();
}
void AndroidSettingsWidget::browseGdbserverLocationX86()
{
    Utils::FileName gdbserverPath = AndroidConfigurations::instance().gdbServerPath(ProjectExplorer::Abi::X86Architecture);
    Utils::FileName file = Utils::FileName::fromString(QFileDialog::getOpenFileName(this, tr("Select gdbserver android executable"), gdbserverPath.toString()));
    if (file.isEmpty())
        return;
    m_ui->GdbserverLocationLineEditx86->setText(file.toUserOutput());
    gdbserverLocationX86EditingFinished();
}
void AndroidSettingsWidget::browseOpenJDKLocation()
{
    Utils::FileName openJDKPath = AndroidConfigurations::instance().openJDKPath();
    Utils::FileName file = Utils::FileName::fromString(QFileDialog::getExistingDirectory(this, tr("Select OpenJDK Path"), openJDKPath.toString()));
    if (file.isEmpty())
        return;
    m_ui->OpenJDKLocationLineEdit->setText(file.toUserOutput());
    openJDKLocationEditingFinished();
}
void AndroidSettingsWidget::ndkLocationEditingFinished()
{
    Utils::FileName location = Utils::FileName::fromUserInput(m_ui->NDKLocationLineEdit->text());
    m_androidConfig.toolchainHost.clear(); // force toolchain host detection
    if (!checkNDK(location))
        return;
    searchForAnt(location.toString());
    saveSettings(true);
}
bool BlackBerryDeviceConfigurationWizardConfigPage::isComplete() const
{
    bool configurationNameComplete = !m_ui->configurationNameField->text().isEmpty();
    Utils::FileName fileName = Utils::FileName::fromString(m_ui->debugTokenCombo->currentText());
    bool debugTokenComplete = m_holder.isSimulator || !m_holder.isProductionDevice
            || (!fileName.isEmpty() && fileName.toFileInfo().exists());

    return configurationNameComplete  &&  debugTokenComplete;
}
예제 #11
0
Utils::FileName AndroidManager::manifestSourcePath(ProjectExplorer::Target *target)
{
    if (AndroidQtSupport *androidQtSupport = AndroidManager::androidQtSupport(target)) {
        Utils::FileName source = androidQtSupport->manifestSourcePath(target);
        if (!source.isEmpty())
            return source;
    }
    return manifestPath(target);
}
void NimRunConfiguration::updateConfiguration()
{
    auto buildConfiguration = qobject_cast<NimBuildConfiguration*>(activeBuildConfiguration());
    Q_ASSERT(buildConfiguration);
    Utils::FileName outFile = buildConfiguration->outFilePath();
    QFileInfo outFileInfo = outFile.toFileInfo();
    setExecutable(outFileInfo.absoluteFilePath());
    setWorkingDirectory(outFileInfo.absoluteDir().absolutePath());
}
예제 #13
0
Utils::FileName CMakeTool::cmakeExecutable() const
{
    if (Utils::HostOsInfo::isMacHost() && m_executable.endsWith(".app")) {
        Utils::FileName toTest = m_executable;
        toTest = toTest.appendPath("Contents/bin/cmake");
        if (toTest.exists())
            return toTest;
    }
    return m_executable;
}
예제 #14
0
QList<Task> SysRootKitInformation::validate(Kit *k) const
{
    QList<Task> result;
    const Utils::FileName dir = SysRootKitInformation::sysRoot(k);
    if (!dir.toFileInfo().isDir() && SysRootKitInformation::hasSysRoot(k)) {
        result << Task(Task::Error, tr("Sys Root \"%1\" is not a directory.").arg(dir.toUserOutput()),
                       Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
    }
    return result;
}
예제 #15
0
bool TreeScanner::isWellKnownBinary(const Utils::MimeType & /*mdb*/, const Utils::FileName &fn)
{
    return fn.endsWith(QLatin1String(".a")) ||
            fn.endsWith(QLatin1String(".o")) ||
            fn.endsWith(QLatin1String(".d")) ||
            fn.endsWith(QLatin1String(".exe")) ||
            fn.endsWith(QLatin1String(".dll")) ||
            fn.endsWith(QLatin1String(".obj")) ||
            fn.endsWith(QLatin1String(".elf"));
}
예제 #16
0
QStringList QmlProject::makeAbsolute(const Utils::FileName &path, const QStringList &relativePaths)
{
    if (path.isEmpty())
        return relativePaths;

    const QDir baseDir(path.toString());
    return Utils::transform(relativePaths, [&baseDir](const QString &path) {
        return QDir::cleanPath(baseDir.absoluteFilePath(path));
    });
}
예제 #17
0
bool AndroidManager::checkForQt51Files(Utils::FileName fileName)
{
    fileName.appendPath(QLatin1String("android")).appendPath(QLatin1String("version.xml"));
    if (!fileName.exists())
        return false;
    QDomDocument dstVersionDoc;
    if (!openXmlFile(dstVersionDoc, fileName))
        return false;
    return dstVersionDoc.documentElement().attribute(QLatin1String("value")).toDouble() < 5.2;
}
bool AndroidSettingsWidget::checkSDK(const Utils::FileName &location)
{
    if (location.isEmpty()) {
        m_ui->sdkWarningIconLabel->setVisible(false);
        m_ui->sdkWarningLabel->setVisible(false);
        return false;
    }
    Utils::FileName adb = location;
    Utils::FileName androidExe = location;
    Utils::FileName androidBat = location;
    Utils::FileName emulator = location;
    if (!adb.appendPath(QLatin1String("platform-tools/adb" QTC_HOST_EXE_SUFFIX)).toFileInfo().exists()
            || (!androidExe.appendPath(QLatin1String("/tools/android" QTC_HOST_EXE_SUFFIX)).toFileInfo().exists()
                && !androidBat.appendPath(QLatin1String("/tools/android" ANDROID_BAT_SUFFIX)).toFileInfo().exists())
            || !emulator.appendPath(QLatin1String("/tools/emulator" QTC_HOST_EXE_SUFFIX)).toFileInfo().exists()) {
        m_ui->sdkWarningIconLabel->setVisible(true);
        m_ui->sdkWarningLabel->setVisible(true);
        m_ui->sdkWarningLabel->setText(tr("\"%1\" does not seem to be an Android SDK top folder.").arg(location.toUserOutput()));
        return false;
    } else {
        m_ui->sdkWarningIconLabel->setVisible(false);
        m_ui->sdkWarningLabel->setVisible(false);
    }
    return true;
}
QString CreateAndroidManifestWizard::sourceFileName() const
{
    QString result;
    QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(m_target->kit());
    if (!version)
        return result;
    Utils::FileName srcPath
            = Utils::FileName::fromString(version->qmakeProperty("QT_INSTALL_PREFIX"))
            .appendPath(QLatin1String("src/android/java"));
    srcPath.appendPath(QLatin1String("AndroidManifest.xml"));
    return srcPath.toString();
}
ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName, QString *errorString)
{
    Utils::FileName file = Utils::FileName::fromString(fileName);
    if (!file.toFileInfo().isFile()) {
        if (errorString)
            *errorString = tr("Failed opening project \"%1\": Project is not a file")
                .arg(file.toUserOutput());
        return 0;
    }

    return new CMakeProject(this, file);
}
QmakeBuildInfo *QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k,
                                                              const QString &projectPath,
                                                              BuildConfiguration::BuildType type) const
{
    QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
    QmakeBuildInfo *info = new QmakeBuildInfo(this);
    QString suffix;
    if (type == BuildConfiguration::Release) {
        //: The name of the release build configuration created by default for a qmake project.
        info->displayName = tr("Release");
        //: Non-ASCII characters in directory suffix may cause build issues.
        suffix = tr("Release", "Shadow build directory suffix");
        if (version && version->isQtQuickCompilerSupported())
            info->config.useQtQuickCompiler = true;
    } else {
        if (type == BuildConfiguration::Debug) {
            //: The name of the debug build configuration created by default for a qmake project.
            info->displayName = tr("Debug");
            //: Non-ASCII characters in directory suffix may cause build issues.
            suffix = tr("Debug", "Shadow build directory suffix");
        } else if (type == BuildConfiguration::Profile) {
            //: The name of the profile build configuration created by default for a qmake project.
            info->displayName = tr("Profile");
            //: Non-ASCII characters in directory suffix may cause build issues.
            suffix = tr("Profile", "Shadow build directory suffix");
            info->config.separateDebugInfo = true;
            if (version && version->isQtQuickCompilerSupported())
                info->config.useQtQuickCompiler = true;
        }
        if (version && version->isQmlDebuggingSupported())
            info->config.linkQmlDebuggingQQ2 = true;
    }
    info->typeName = info->displayName;
    // Leave info->buildDirectory unset;
    info->kitId = k->id();

    // check if this project is in the source directory:
    Utils::FileName projectFilePath = Utils::FileName::fromString(projectPath);
    if (version && version->isInSourceDirectory(projectFilePath)) {
        // assemble build directory
        QString projectDirectory = projectFilePath.toFileInfo().absolutePath();
        QDir qtSourceDir = QDir(version->sourcePath().toString());
        QString relativeProjectPath = qtSourceDir.relativeFilePath(projectDirectory);
        QString qtBuildDir = version->versionInfo().value(QStringLiteral("QT_INSTALL_PREFIX"));
        QString absoluteBuildPath = QDir::cleanPath(qtBuildDir + QLatin1Char('/') + relativeProjectPath);

        info->buildDirectory = Utils::FileName::fromString(absoluteBuildPath);
    } else {
        info->buildDirectory = defaultBuildDirectory(projectPath, k, suffix, type);
    }
    info->buildType = type;
    return info;
}
void AndroidPackageCreationWidget::on_KeystoreLocationPushButton_clicked()
{
    Utils::FileName keystorePath = m_step->keystorePath();
    if (keystorePath.isEmpty())
        keystorePath = Utils::FileName::fromString(QDir::homePath());
    Utils::FileName file = Utils::FileName::fromString(QFileDialog::getOpenFileName(this, tr("Select keystore file"), keystorePath.toString(), tr("Keystore files (*.keystore *.jks)")));
    if (file.isEmpty())
        return;
    m_ui->KeystoreLocationLineEdit->setText(file.toUserOutput());
    m_step->setKeystorePath(file);
    m_ui->signPackageCheckBox->setChecked(false);
}
예제 #23
0
void BuildConfiguration::prependCompilerPathToEnvironment(Kit *k, Utils::Environment &env)
{
    const ToolChain *tc
            = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);

    if (!tc)
        return;

    const Utils::FileName compilerDir = tc->compilerCommand().parentDir();
    if (!compilerDir.isEmpty())
        env.prependOrSetPath(compilerDir.toString());
}
예제 #24
0
static bool openXmlFile(QDomDocument &doc, const Utils::FileName &fileName)
{
    QFile f(fileName.toString());
    if (!f.open(QIODevice::ReadOnly))
        return false;

    if (!doc.setContent(f.readAll())) {
        raiseError(AndroidManager::tr("Cannot parse \"%1\".").arg(fileName.toUserOutput()));
        return false;
    }
    return true;
}
예제 #25
0
void IosDeployStep::checkProvisioningProfile()
{
    IosDevice::ConstPtr device = iosdevice();
    if (device.isNull())
        return;

    Utils::FileName provisioningFilePath = Utils::FileName::fromString(appBundle());
    provisioningFilePath.appendPath(QLatin1String("embedded.mobileprovision"));

    // the file is a signed plist stored in DER format
    // we simply search for start and end of the plist instead of decoding the DER payload
    if (!provisioningFilePath.exists())
        return;
    QFile provisionFile(provisioningFilePath.toString());
    if (!provisionFile.open(QIODevice::ReadOnly))
        return;
    QByteArray provisionData = provisionFile.readAll();
    int start = provisionData.indexOf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    int end = provisionData.indexOf("</plist>");
    if (start == -1 || end == -1)
        return;
    end += 8;

    QTemporaryFile f;
    if (!f.open())
        return;
    f.write(provisionData.mid(start, end - start));
    f.flush();
    QSettings provisionPlist(f.fileName(), QSettings::NativeFormat);

    if (!provisionPlist.contains(QLatin1String("ProvisionedDevices")))
        return;
    QStringList deviceIds = provisionPlist.value(QLatin1String("ProvisionedDevices")).toStringList();
    QString targetId = device->uniqueDeviceID();
    foreach (const QString &deviceId, deviceIds) {
        if (deviceId == targetId)
            return;
    }

    m_expectFail = true;
    QString provisioningProfile = provisionPlist.value(QLatin1String("Name")).toString();
    QString provisioningUid = provisionPlist.value(QLatin1String("UUID")).toString();
    Task task(Task::Warning,
              tr("The provisioning profile \"%1\" (%2) used to sign the application "
                 "does not cover the device %3 (%4). Deployment to it will fail.")
              .arg(provisioningProfile, provisioningUid, device->displayName(),
                   targetId),
              Utils::FileName(), /* filename */
              -1, /* line */
              ProjectExplorer::Constants::TASK_CATEGORY_COMPILE);
    emit addTask(task);
}
void AndroidSettingsWidget::sdkLocationEditingFinished()
{
    Utils::FileName location = Utils::FileName::fromUserInput(m_ui->SDKLocationLineEdit->text());
    if (!checkSDK(location)) {
        m_ui->AVDManagerFrame->setEnabled(false);
        return;
    }
    m_androidConfig.sdkLocation = location;
    searchForAnt(location.toString());
    saveSettings(true);
    m_AVDModel.setAvdList(AndroidConfigurations::instance().androidVirtualDevices());
    m_ui->AVDManagerFrame->setEnabled(true);
}
예제 #27
0
ResourceTopLevelNode::ResourceTopLevelNode(const Utils::FileName &filePath, FolderNode *parent)
    : ProjectExplorer::FolderNode(filePath)
{
    setIcon(Core::FileIconProvider::icon(filePath.toString()));
    m_document = new ResourceFileWatcher(this);
    Core::DocumentManager::addDocument(m_document);

    Utils::FileName base = parent->filePath();
    if (filePath.isChildOf(base))
        setDisplayName(filePath.relativeChildPath(base).toUserOutput());
    else
        setDisplayName(filePath.toUserOutput());
}
void ModelManagerSupportClang::onCurrentEditorChanged(Core::IEditor *editor)
{
    m_communicator.updateTranslationUnitVisiblity();

    // Update task hub issues for current CppEditorDocument
    ClangEditorDocumentProcessor::clearTaskHubIssues();
    if (!editor || !editor->document() || !cppModelManager()->isCppEditor(editor))
        return;

    const ::Utils::FileName filePath = editor->document()->filePath();
    if (auto processor = ClangEditorDocumentProcessor::get(filePath.toString()))
        processor->generateTaskHubIssues();
}
예제 #29
0
void Project::readProjectSettings(const Utils::FileName &fileName)
{
    QString base = fileName.toFileInfo().absoluteDir().absolutePath();
    base.append("/");
    QSettings settings(fileName.toString(), QSettings::IniFormat);
    settings.beginGroup("Config");
    for (const QString &path : settings.value("Ignore").toStringList()) {
        if (path.isEmpty())
            continue;
        m_ignoredDirectories << base + path;
    }
    settings.endGroup();
}
예제 #30
0
bool ROSUtils::generateCodeBlocksProjectFile(QProcess *process, const Utils::FileName &sourceDir, const Utils::FileName &buildDir)
{
    QString cmd = QLatin1String("cmake ") + sourceDir.toString() + QLatin1String(" -G \"CodeBlocks - Unix Makefiles\"");
    bool results = false;
    process->setWorkingDirectory(buildDir.toString());
    process->start(QLatin1String("bash"), QStringList() << QLatin1String("-c") << cmd);
    process->waitForFinished();
    if (process->exitStatus() != QProcess::CrashExit)
    {
      results  = true;
    }
    return results;
}