Ejemplo n.º 1
0
boost::filesystem::path path_derivatives_factory::
make_inclusion_path(const settings::path_settings& ps,
    const yarn::name& n) const {
    BOOST_LOG_SEV(lg, debug) << "Making inclusion path for: " << n.qualified();

    boost::filesystem::path r;

    /* Header files require both the external module path and the
     * model module path in the file name path.
     */
    if (ps.file_type() == formatters::file_types::cpp_header) {
        for (const auto& m : n.location().external_modules())
            r /= m;

        const auto& mmp(n.location().model_modules());
        r /= boost::algorithm::join(mmp, dot);
    }

    /* If there is a facet directory, and it is configured to
     * contribute to the file name path, add it.
     */
    if (!ps.facet_directory().empty() && !ps.disable_facet_directories())
        r /= ps.facet_directory();

    // Add the module path of the modules internal to this model.
    for (const auto& m : n.location().internal_modules())
        r /= m;

    /* Modules other than the model module contribute their simple
     * names to the directories.
     */
    if (n != model_.name()) {
        const auto i(model_.elements().find(n.qualified()));
        if (i != model_.elements().end() && is<yarn::module>(i->second))
            r /= n.simple();
    }

    // handle the file name.
    std::ostringstream stream;
    stream << n.simple();

    if (!ps.formatter_postfix().empty())
        stream << underscore << ps.formatter_postfix();

    if (!ps.facet_postfix().empty())
        stream << underscore << ps.facet_postfix();

    if (ps.file_type() == formatters::file_types::cpp_header)
        stream << dot << ps.header_file_extension();
    else if (ps.file_type() == formatters::file_types::cpp_implementation)
        stream << dot << ps.implementation_file_extension();

    r /= stream.str();

    BOOST_LOG_SEV(lg, debug) << "Done making the inclusion path. Result: " << r;
    return r;
}
Ejemplo n.º 2
0
boost::filesystem::path path_derivatives_factory::
make_file_path(const settings::path_settings& ps,
    const boost::filesystem::path& inclusion_path,
    const yarn::name& n) const {
    BOOST_LOG_SEV(lg, debug) << "Creating file path for: " << n.qualified();

    boost::filesystem::path r;

    const auto ft(ps.file_type());
    const auto& mmp(n.location().model_modules());
    switch (ft) {
    case formatters::file_types::cpp_header:
        r = options_.project_directory_path();
        r /= boost::algorithm::join(mmp, dot);
        r /= ps.include_directory_name();
        break;

    case formatters::file_types::cpp_implementation:
        r = options_.project_directory_path();
        r /= boost::algorithm::join(mmp, dot);
        r /= ps.source_directory_name();
        break;

    default:
        BOOST_LOG_SEV(lg, error) << unsupported_file_type << ft;
        BOOST_THROW_EXCEPTION(building_error(unsupported_file_type +
                boost::lexical_cast<std::string>(ft)));
    }

    r /= inclusion_path;

    BOOST_LOG_SEV(lg, debug) << "Done creating file path. Result: " << r;
    return r;
}