当前位置: 首页>>代码示例>>C++>>正文


C++ Options::additionalContentFiles方法代码示例

本文整理汇总了C++中Options::additionalContentFiles方法的典型用法代码示例。如果您正苦于以下问题:C++ Options::additionalContentFiles方法的具体用法?C++ Options::additionalContentFiles怎么用?C++ Options::additionalContentFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Options的用法示例。


在下文中一共展示了Options::additionalContentFiles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fprintf

int Driver::
run(std::vector<std::string> const &args, std::unordered_map<std::string, std::string> const &environment, Filesystem *filesystem, std::string const &workingDirectory)
{
    Options options;
    std::pair<bool, std::string> result = libutil::Options::Parse<Options>(&options, args);
    if (!result.first) {
        fprintf(stderr, "error: %s\n", result.second.c_str());
        return 1;
    }

    /* Validate options. */
    if (!options.input()) {
        fprintf(stderr, "error: no input file specified\n");
        return 1;
    }

    if (!options.output()) {
        fprintf(stderr, "error: no output file specified\n");
        return 1;
    }

    pbxsetting::Environment settingsEnvironment = CreateBuildEnvironment(environment);

    /* Read in the input. */
    std::vector<uint8_t> inputContents;
    if (!filesystem->read(&inputContents, FSUtil::ResolveRelativePath(*options.input(), workingDirectory))) {
        fprintf(stderr, "error: unable to read input %s\n", options.input()->c_str());
        return 1;
    }

    /* Determine the input format. */
    std::unique_ptr<plist::Format::Any> inputFormat = plist::Format::Any::Identify(inputContents);
    if (inputFormat == nullptr) {
        fprintf(stderr, "error: input %s is not a plist\n", options.input()->c_str());
        return 1;
    }

    /* Deserialize the input. */
    auto deserialize = plist::Format::Any::Deserialize(inputContents, *inputFormat);
    if (!deserialize.first) {
        fprintf(stderr, "error: %s: %s\n", options.input()->c_str(), deserialize.second.c_str());
        return 1;
    }

    plist::Dictionary *root = plist::CastTo<plist::Dictionary>(deserialize.first.get());
    if (root == nullptr) {
        fprintf(stderr, "error: info plist root is not a dictionary\n");
        return 1;
    }

    /*
     * Expand all build settings in the plist. Build settings can be in dictionary keys
     * and strings. The resolved build setting values are passed through the environment.
     */
    if (options.expandBuildSettings()) {
        ExpandBuildSettings(root, settingsEnvironment);
    }

    /*
     * Process additional content files. These are plists that get merged with the
     * main Info.plist at the top level.
     */
    for (std::string const &additionalContentFile : options.additionalContentFiles()) {
        std::vector<uint8_t> contents;
        if (!filesystem->read(&contents, FSUtil::ResolveRelativePath(additionalContentFile, workingDirectory))) {
            fprintf(stderr, "error: unable to read additional content file: %s\n", additionalContentFile.c_str());
            return 1;
        }

        auto additionalContent = plist::Format::Any::Deserialize(contents);
        if (additionalContent.first == nullptr) {
            fprintf(stderr, "error: unable to parse additional content file %s: %s\n", additionalContentFile.c_str(), additionalContent.second.c_str());
            return 1;
        }

        if (plist::Dictionary *dictionary = plist::CastTo<plist::Dictionary>(additionalContent.first.get())) {
            /* Pass true to replace existing entries. */
            root->merge(dictionary, true);
        }
    }

    /*
     * Info file keys/values: it's unknown what these are used for. Just warn.
     */
    if (options.infoFileKeys() || options.infoFileValues()) {
        // TODO(grp): Handle info file keys and values.
        fprintf(stderr, "warning: info file keys and values are not yet implemented\n");
    }

    /*
     * Platform and required architectures: it's unknown what these are used for. Just warn.
     */
    if (options.platform() || !options.requiredArchitectures().empty()) {
        // TODO(grp): Handle platform and required architectures.
#if 0
        fprintf(stderr, "warning: platform and required architectures are not yet implemented\n");
#endif
    }

    /*
//.........这里部分代码省略.........
开发者ID:stlwtr,项目名称:xcbuild,代码行数:101,代码来源:Driver.cpp


注:本文中的Options::additionalContentFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。