예제 #1
0
파일: mksys.cpp 프로젝트: H-H-bin/legato-af
//--------------------------------------------------------------------------------------------------
void MakeSystem
(
    int argc,           ///< Count of the number of command line parameters.
    const char** argv   ///< Pointer to an array of pointers to command line argument strings.
)
//--------------------------------------------------------------------------------------------------
{
    GetCommandLineArgs(argc, argv);

    // Set the target-specific environment variables (e.g., LEGATO_TARGET).
    envVars::SetTargetSpecific(BuildParams.target);

    // Compute the staging directory path.
    auto stagingDir = path::Combine(BuildParams.workingDir, "staging");

    // If we have been asked not to run Ninja, then delete the staging area because it probably
    // will contain some of the wrong files now that .Xdef file have changed.
    if (DontRunNinja)
    {
        file::DeleteDir(stagingDir);
    }
    // If we have not been asked to ignore any already existing build.ninja, and the command-line
    // arguments and environment variables we were given are the same as last time, just run ninja.
    else if (args::MatchesSaved(BuildParams, argc, argv) && envVars::MatchesSaved(BuildParams))
    {
        RunNinja(BuildParams);
        // NOTE: If build.ninja exists, RunNinja() will not return.  If it doesn't it will.
    }

    // Construct a model of the system.
    model::System_t* systemPtr = modeller::GetSystem(SdefFilePath, BuildParams);

    // If verbose mode is on, print a summary of the system model.
    if (BuildParams.beVerbose)
    {
//        modeller::PrintSummary(systemPtr);
    }

    // Create the working directory and the staging directory, if they don't already exist.
    file::MakeDir(stagingDir);

    // Generate code for all the components in the system.
    GenerateCode(model::Component_t::GetComponentMap(), BuildParams);

    // Generate code and configuration files for all the apps in the system.
    for (auto appMapEntry : systemPtr->apps)
    {
        GenerateCode(appMapEntry.second, BuildParams);
    }

    // Generate the configuration files for the system.
    config::Generate(systemPtr, BuildParams);

    // Generate the build script for the system.
    ninja::Generate(systemPtr, BuildParams, OutputDir, argc, argv);

    // If we haven't been asked not to run ninja,
    if (!DontRunNinja)
    {
        // Save the command-line arguments and environment variables for future comparison.
        // Note: we don't need to do this if we have been asked not to run ninja, because
        // that only happens when ninja is already running and asking us to regenerate its
        // script for us, and that only happens if we just saved the args and env vars and
        // ran ninja.
        args::Save(BuildParams, argc, argv);
        envVars::Save(BuildParams);

        RunNinja(BuildParams);
    }
}
예제 #2
0
파일: mkapp.cpp 프로젝트: tegoo/legato-af
//--------------------------------------------------------------------------------------------------
void MakeApp
(
    int argc,           ///< Count of the number of command line parameters.
    const char** argv   ///< Pointer to an array of pointers to command line argument strings.
)
//--------------------------------------------------------------------------------------------------
{
    GetCommandLineArgs(argc, argv);

    // Set the target-specific environment variables (e.g., LEGATO_TARGET).
    envVars::SetTargetSpecific(BuildParams.target);

    // If we have been asked not to run Ninja, then delete the staging area because it probably
    // will contain some of the wrong files now that .Xdef file have changed.
    if (DontRunNinja)
    {
        file::DeleteDir(path::Combine(BuildParams.workingDir, "staging"));
    }
    // If we have not been asked to ignore any already existing build.ninja, and the command-line
    // arguments and environment variables we were given are the same as last time, just run ninja.
    else if (args::MatchesSaved(BuildParams, argc, argv) && envVars::MatchesSaved(BuildParams))
    {
        RunNinja(BuildParams);
        // NOTE: If build.ninja exists, RunNinja() will not return.  If it doesn't it will.
    }

    // Construct a model of the application.
    AppPtr = modeller::GetApp(AdefFilePath, BuildParams);
    if (AppPtr->version.empty())
    {
        AppPtr->version = VersionSuffix;
    }

    // Append a "." and the VersionSuffix if the user provides a
    // "--append or -a" argument in the command line
    else if (VersionSuffix.empty() == false)
    {
        AppPtr->version += '.' + VersionSuffix;
    }

    // Ensure that all client-side interfaces have either been bound to something or declared
    // external.
    modeller::EnsureClientInterfacesSatisfied(AppPtr);

    if (BuildParams.beVerbose)
    {
        modeller::PrintSummary(AppPtr);
    }

    // Since this app is the only app, it won't be under the "apps" subdirectory,
    // reset the application's relative working directory path.
    AppPtr->workingDir = "";

    // Create the working directory, if it doesn't already exist.
    file::MakeDir(BuildParams.workingDir);

    // Generate the configuration data file.
    config::Generate(AppPtr, BuildParams);

    // Generate the build script for the application.
    ninja::Generate(AppPtr, BuildParams, OutputDir, argc, argv);

    // For each executable in the application,
    for (auto exePtr : AppPtr->executables)
    {
        // Generate _main.c.
        code::GenerateExeMain(exePtr, BuildParams);
    }

    // For each component in the application,
    for (auto componentPtr : AppPtr->components)
    {
        // Create a working directory to build the component in.
        file::MakeDir(path::Combine(BuildParams.workingDir, componentPtr->workingDir));

        // Generate a custom "interfaces.h" file for this component.
        code::GenerateInterfacesHeader(componentPtr, BuildParams);

        // Generate a custom "_componentMain.c" file for this component.
        code::GenerateComponentMainFile(componentPtr, BuildParams, false);
    }

    // Generate the manifest.app file for Air Vantage.
    airVantage::GenerateManifest(AppPtr, BuildParams);

    // If we haven't been asked not to run ninja,
    if (!DontRunNinja)
    {
        // Save the command-line arguments and environment variables for future comparison.
        // Note: we don't need to do this if we have been asked not to run ninja, because
        // that only happens when ninja is already running and asking us to regenerate its
        // script for us, and that only happens if we just saved the args and env vars and
        // ran ninja.
        args::Save(BuildParams, argc, argv);
        envVars::Save(BuildParams);

        RunNinja(BuildParams);
    }
}
예제 #3
0
파일: mkapp.cpp 프로젝트: ekral85/legato-af
//--------------------------------------------------------------------------------------------------
void MakeApp
(
    int argc,           ///< Count of the number of command line parameters.
    const char** argv   ///< Pointer to an array of pointers to command line argument strings.
)
//--------------------------------------------------------------------------------------------------
{
    GetCommandLineArgs(argc, argv);

    // Set the target-specific environment variables (e.g., LEGATO_TARGET).
    envVars::SetTargetSpecific(BuildParams.target);

    // If we have been asked not to run Ninja, then delete the staging area because it probably
    // will contain some of the wrong files now that .Xdef file have changed.
    if (DontRunNinja)
    {
        file::DeleteDir(path::Combine(BuildParams.workingDir, "staging"));
    }
    // If we have not been asked to ignore any already existing build.ninja, and the command-line
    // arguments and environment variables we were given are the same as last time, just run ninja.
    else if (args::MatchesSaved(BuildParams, argc, argv) && envVars::MatchesSaved(BuildParams))
    {
        RunNinja(BuildParams);
        // NOTE: If build.ninja exists, RunNinja() will not return.  If it doesn't it will.
    }
    // If we have not been asked to ignore any already existing build.ninja and there has
    // been a change in either the argument list or the environment variables,
    // save the command-line arguments and environment variables for future comparison.
    // Note: we don't need to do this if we have been asked not to run ninja, because
    // that only happens when ninja is already running and asking us to regenerate its
    // script for us, and that only happens if the args and env vars have already been saved.
    else
    {
        // Save the command line arguments.
        args::Save(BuildParams, argc, argv);

        // Save the environment variables.
        // Note: we must do this before we parse the definition file, because parsing the file
        // will result in the CURDIR environment variable being set.
        envVars::Save(BuildParams);
    }

    // Construct a model of the application.
    model::App_t* appPtr = modeller::GetApp(AdefFilePath, BuildParams);

    // Append a "." and the VersionSuffix if the user provides a
    // "--append or -a" argument in the command line.
    if (appPtr->version.empty())
    {
        appPtr->version = VersionSuffix;
    }
    else if (VersionSuffix.empty() == false)
    {
        appPtr->version += '.' + VersionSuffix;
    }

    // Ensure that all client-side interfaces have either been bound to something or declared
    // external.
    modeller::EnsureClientInterfacesSatisfied(appPtr);

    // If verbose mode is on, print a summary of the application model.
    if (BuildParams.beVerbose)
    {
        modeller::PrintSummary(appPtr);
    }

    // Generate app-specific code and configuration files.
    GenerateCode(appPtr, BuildParams);

    // Generate code for all the components in the app.
    GenerateCode(appPtr->components, BuildParams);

    // Generate the build script for the application.
    ninja::Generate(appPtr, BuildParams, OutputDir, argc, argv);

    // If we haven't been asked not to, run ninja.
    if (!DontRunNinja)
    {
        RunNinja(BuildParams);
    }
}