Esempio n. 1
0
void MSBuildQbsProductProject::addFiles(const GeneratableProject &project,
                                        const GeneratableProductData &product)
{
    auto itemGroup = new MSBuildItemGroup(this);

    std::map<QString, MSBuildFileItem *> sourceFileNodes;
    std::map<QString, QStringList> sourceFileEnabledConfigurations;

    // Create a ClCompile item for each source file, keeping track of which configurations that
    // file's containing group is enabled in
    QMapIterator<QString, qbs::ProductData> productDataIt(product.data);
    while (productDataIt.hasNext()) {
        productDataIt.next();
        for (const auto &group : productDataIt.value().groups()) {
            for (const auto &sourceArtifact : group.allSourceArtifacts()) {
                const auto filePath = sourceArtifact.filePath();
                if (sourceFileNodes.find(filePath) == sourceFileNodes.end()) {
                    sourceFileNodes.insert({
                        filePath,
                        fileItemForFileTags(sourceArtifact.fileTags(), itemGroup)
                    });
                }
                auto fileItem = sourceFileNodes[filePath];
                QString path = project.baseBuildDirectory().relativeFilePath(filePath);
                // The path still might not be relative (for example if the file item is
                // located on a different drive)
                if (QFileInfo(path).isRelative())
                    path = QStringLiteral("$(ProjectDir)") + path;
                fileItem->setFilePath(path);
                if (group.isEnabled())
                    sourceFileEnabledConfigurations[filePath] << productDataIt.key();
            }
        }
    }

    // Add ExcludedFromBuild item metadata to each file for each configuration
    // where that file's containing group is disabled
    for (const auto &sourceFileNode : sourceFileNodes) {
        QMapIterator<QString, qbs::Project> projIt(project.projects);
        while (projIt.hasNext()) {
            projIt.next();
            if (!sourceFileEnabledConfigurations[sourceFileNode.first].contains(projIt.key())) {
                auto metadata = new MSBuildItemMetadata(
                            QStringLiteral("ExcludedFromBuild"),
                            QStringLiteral("true"),
                            sourceFileNode.second);
                metadata->setCondition(QStringLiteral("'$(Configuration)|$(Platform)'=='")
                    + MSBuildUtils::fullName(projIt.value())
                    + QStringLiteral("'"));
            }
        }
    }

    auto import = new MSBuildImport(this);
    import->setProject(QStringLiteral("$(VCTargetsPath)\\Microsoft.Cpp.targets"));
}
Esempio n. 2
0
    Status LiteParsedQuery::init(const string& ns, int ntoskip, int ntoreturn, int queryOptions,
                                 const BSONObj& queryObj, const BSONObj& proj,
                                 bool fromQueryMessage) {
        _ns = ns;
        _ntoskip = ntoskip;
        _ntoreturn = ntoreturn;
        _options = queryOptions;
        _proj = proj.getOwned();

        if (_ntoskip < 0) {
            return Status(ErrorCodes::BadValue, "bad skip value in query");
        }

        if (_ntoreturn == std::numeric_limits<int>::min()) {
            // _ntoreturn is negative but can't be negated.
            return Status(ErrorCodes::BadValue, "bad limit value in query");
        }

        if (_ntoreturn < 0) {
            // _ntoreturn greater than zero is simply a hint on how many objects to send back per
            // "cursor batch".  A negative number indicates a hard limit.
            _wantMore = false;
            _ntoreturn = -_ntoreturn;
        }

        if (fromQueryMessage) {
            BSONElement queryField = queryObj["query"];
            if (!queryField.isABSONObj()) { queryField = queryObj["$query"]; }
            if (queryField.isABSONObj()) {
                _filter = queryField.embeddedObject().getOwned();
                Status status = initFullQuery(queryObj);
                if (!status.isOK()) { return status; }
            }
            else {
                // TODO: Does this ever happen?
                _filter = queryObj.getOwned();
            }
        }
        else {
            // This is the debugging code path.
            _filter = queryObj.getOwned();
        }

        _hasReadPref = queryObj.hasField("$readPreference");

        if (!_sort.isEmpty()) {
            if (!isValidSortOrder(_sort)) {
                return Status(ErrorCodes::BadValue, "bad sort specification");
            }
            _sort = normalizeSortOrder(_sort);
        }

        // Min and Max objects must have the same fields.
        if (!_min.isEmpty() && !_max.isEmpty()) {
            if (!_min.isFieldNamePrefixOf(_max) || (_min.nFields() != _max.nFields())) {
                return Status(ErrorCodes::BadValue, "min and max must have the same field names");
            }
        }

        // Can't combine a normal sort and a $meta projection on the same field.
        BSONObjIterator projIt(_proj);
        while (projIt.more()) {
            BSONElement projElt = projIt.next();
            if (isTextScoreMeta(projElt)) {
                BSONElement sortElt = _sort[projElt.fieldName()];
                if (!sortElt.eoo() && !isTextScoreMeta(sortElt)) {
                    return Status(ErrorCodes::BadValue,
                                  "can't have a non-$meta sort on a $meta projection");
                }
            }
        }

        // All fields with a $meta sort must have a corresponding $meta projection.
        BSONObjIterator sortIt(_sort);
        while (sortIt.more()) {
            BSONElement sortElt = sortIt.next();
            if (isTextScoreMeta(sortElt)) {
                BSONElement projElt = _proj[sortElt.fieldName()];
                if (projElt.eoo() || !isTextScoreMeta(projElt)) {
                    return Status(ErrorCodes::BadValue,
                                  "must have $meta projection for all $meta sort keys");
                }
            }
        }

        return Status::OK();
    }