//--------------------------------------------------------------------------------------------------
static void BuildAndBundleComponent
(
    legato::Component& component,
    ComponentBuilder_t componentBuilder,
    const std::string& appWorkingDir
)
//--------------------------------------------------------------------------------------------------
{
    if (component.IsBuilt() == false)
    {
        // Do sub-components first.
        for (auto& mapEntry : component.SubComponents())
        {
            auto subComponentPtr = mapEntry.second;

            BuildAndBundleComponent(*subComponentPtr, componentBuilder, appWorkingDir);
        }

        // Each component gets its own object file dir.
        std::string objOutputDir = legato::CombinePath(appWorkingDir,
                                                       "component/" + component.Name());

        // Build the component.
        // NOTE: This will detect if the component doesn't actually need to be built, either because
        //       it doesn't have any source files that need to be compiled, or because they have
        //       already been compiled.
        componentBuilder.Build(component, objOutputDir);

        // Copy all the bundled files and directories from the component into the staging area.
        componentBuilder.Bundle(component);
    }
}
Beispiel #2
0
//--------------------------------------------------------------------------------------------------
void GetComponentLibLinkDirectives
(
    std::ostream& outputStream,
    const legato::Component& component
)
//--------------------------------------------------------------------------------------------------
{
    // Link with required libraries.
    for (auto lib : component.RequiredLibs())
    {
        outputStream << " -l" << lib;
    }

    // Link with bundled libraries.
    for (auto lib : component.BundledLibs())
    {
        mk::GetLinkDirectiveForLibrary(outputStream, lib);
    }

    // For each sub-component,
    for (const auto& mapEntry : component.SubComponents())
    {
        auto componentPtr = mapEntry.second;

        // If the component has itself been built into a library, link with that.
        if (componentPtr->Lib().Exists())
        {
            outputStream << " -l" << componentPtr->Lib().ShortName();
        }

        // Link with whatever this component depends on, bundles, or requires.
        GetComponentLibLinkDirectives(outputStream, *componentPtr);
    }
}