Esempio n. 1
0
static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
                              void *MainAddr) {
    // Allow users to override the resource dir.
    for (StringRef Arg : Args)
        if (Arg.startswith("-resource-dir"))
            return;

    // If there's no override in place add our resource dir.
    Args.push_back("-resource-dir=" +
                   CompilerInvocation::GetResourcesPath(Argv0, MainAddr));
}
Esempio n. 2
0
 virtual CommandLineArguments
 Adjust(const CommandLineArguments &Args) override {
   Ran = true;
   for (unsigned I = 0, E = Args.size(); I != E; ++I) {
     if (Args[I] == "-fsyntax-only") {
       Found = true;
       break;
     }
   }
   return Args;
 }
Esempio n. 3
0
Config::Config(const CommandLineArguments &commandLineArguments)
    : m_GeneralSetting(NULL),
      m_CommandSettings()
{
    LoadFile(commandLineArguments.GetConfigFilename());
    assert(m_GeneralSetting != NULL);

    if (!commandLineArguments.GetComPort().empty())
    {
        // Overwrite the COM port setting defined in the config file
        m_GeneralSetting->SetComPort(commandLineArguments.GetComPort());
    }

    if (!commandLineArguments.GetDownloadAgentFilename().empty())
    {
        // Overwrite the download agent setting defined in the config file
        m_GeneralSetting->SetDownloadAgentFilePath(
                commandLineArguments.GetDownloadAgentFilename());
    }

    if (!commandLineArguments.GetScatterFilename().empty())
    {
        // Overwrite the scatter file setting defined in the config file
        for (CommandSettings::iterator it = m_CommandSettings.begin();
             it != m_CommandSettings.end();
             ++it)
        {
            DownloadSetting *downloadSetting =
                    dynamic_cast<DownloadSetting *>(it->Get());

            if (downloadSetting != NULL)
            {
                downloadSetting->SetScatterFilePath(
                        commandLineArguments.GetScatterFilename());
            }
        }
    }
}
Esempio n. 4
0
int
Main::run(int argc, char** argv)
{
  int result = 0;

  try
  {
    CommandLineArguments args;

    try
    {
      args.parse_args(argc, argv);
      g_log_level = args.get_log_level();
    }
    catch(const std::exception& err)
    {
      std::cout << "Error: " << err.what() << std::endl;
      return EXIT_FAILURE;
    }

    PhysfsSubsystem physfs_subsystem(argv[0], args.datadir, args.userdir);
    physfs_subsystem.print_search_path();

    timelog("config");
    ConfigSubsystem config_subsystem;
    args.merge_into(*g_config);

    timelog("tinygettext");
    init_tinygettext();

    switch (args.get_action())
    {
      case CommandLineArguments::PRINT_VERSION:
        args.print_version();
        return 0;

      case CommandLineArguments::PRINT_HELP:
        args.print_help(argv[0]);
        return 0;

      case CommandLineArguments::PRINT_DATADIR:
        args.print_datadir();
        return 0;

      default:
        launch_game();
        break;
    }
  }
  catch(const std::exception& e)
  {
    log_fatal << "Unexpected exception: " << e.what() << std::endl;
    result = 1;
  }
  catch(...)
  {
    log_fatal << "Unexpected exception" << std::endl;
    result = 1;
  }

  g_dictionary_manager.reset();

  return result;
}
Esempio n. 5
0
 CommandLineArguments Adjust(const CommandLineArguments &Args) {
   CommandLineArguments AdjustedArgs = Args;
   AdjustedArgs.push_back("-fsyntax-only");
   AdjustedArgs.push_back("-std=c++11");
   return AdjustedArgs;
 }
Esempio n. 6
0
int
Main::run(int argc, char** argv)
{
#ifdef WIN32
	//SDL is used instead of PHYSFS because both create the same path in app data
	//However, PHYSFS is not yet initizlized, and this should be run before anything is initialized
	std::string prefpath = SDL_GetPrefPath("SuperTux", "supertux2");

	std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;

	//All this conversion stuff is necessary to make this work for internationalized usernames
	std::string outpath = prefpath + u8"/console.out";
	std::wstring w_outpath = converter.from_bytes(outpath);
	_wfreopen(w_outpath.c_str(), L"a", stdout);

	std::string errpath = prefpath + u8"/console.err";
	std::wstring w_errpath = converter.from_bytes(errpath);
	_wfreopen(w_errpath.c_str(), L"a", stderr);
#endif

  // Create and install global locale
  std::locale::global(boost::locale::generator().generate(""));
  // Make boost.filesystem use it
  boost::filesystem::path::imbue(std::locale());

  int result = 0;

  try
  {
    CommandLineArguments args;

    try
    {
      args.parse_args(argc, argv);
      g_log_level = args.get_log_level();
    }
    catch(const std::exception& err)
    {
      std::cout << "Error: " << err.what() << std::endl;
      return EXIT_FAILURE;
    }

    PhysfsSubsystem physfs_subsystem(argv[0], args.datadir, args.userdir);
    physfs_subsystem.print_search_path();

    timelog("config");
    ConfigSubsystem config_subsystem;
    args.merge_into(*g_config);

    timelog("tinygettext");
    init_tinygettext();

    switch (args.get_action())
    {
      case CommandLineArguments::PRINT_VERSION:
        args.print_version();
        return 0;

      case CommandLineArguments::PRINT_HELP:
        args.print_help(argv[0]);
        return 0;

      case CommandLineArguments::PRINT_DATADIR:
        args.print_datadir();
        return 0;

      default:
        launch_game();
        break;
    }
  }
  catch(const std::exception& e)
  {
    log_fatal << "Unexpected exception: " << e.what() << std::endl;
    result = 1;
  }
  catch(...)
  {
    log_fatal << "Unexpected exception" << std::endl;
    result = 1;
  }

  g_dictionary_manager.reset();

  return result;
}
Esempio n. 7
0
int
Main::run(int argc, char** argv)
{
#ifdef WIN32
	//SDL is used instead of PHYSFS because both create the same path in app data
	//However, PHYSFS is not yet initizlized, and this should be run before anything is initialized
	std::string prefpath = SDL_GetPrefPath("SuperTux", "supertux2");
	freopen((prefpath + "/console.out").c_str(), "a", stdout);
	freopen((prefpath + "/console.err").c_str(), "a", stderr);
#endif
 
  int result = 0;

  try
  {
    CommandLineArguments args;

    try
    {
      args.parse_args(argc, argv);
      g_log_level = args.get_log_level();
    }
    catch(const std::exception& err)
    {
      std::cout << "Error: " << err.what() << std::endl;
      return EXIT_FAILURE;
    }

    PhysfsSubsystem physfs_subsystem(argv[0], args.datadir, args.userdir);
    physfs_subsystem.print_search_path();

    timelog("config");
    ConfigSubsystem config_subsystem;
    args.merge_into(*g_config);

    timelog("tinygettext");
    init_tinygettext();

    switch (args.get_action())
    {
      case CommandLineArguments::PRINT_VERSION:
        args.print_version();
        return 0;

      case CommandLineArguments::PRINT_HELP:
        args.print_help(argv[0]);
        return 0;

      case CommandLineArguments::PRINT_DATADIR:
        args.print_datadir();
        return 0;

      default:
        launch_game();
        break;
    }
  }
  catch(const std::exception& e)
  {
    log_fatal << "Unexpected exception: " << e.what() << std::endl;
    result = 1;
  }
  catch(...)
  {
    log_fatal << "Unexpected exception" << std::endl;
    result = 1;
  }

  g_dictionary_manager.reset();

  return result;
}
Esempio n. 8
0
    bool Parser::ParseProject(const Project* project)
    {
        if (project == nullptr)
        {
            std::cout << "invalid project" << std::endl;
            return false;
        }

        std::cout << ">> project  : " << project->GetName() << std::endl;

        const Configuration* config = nullptr;

        if (!project->GetConfigurations().empty())
        {
            config = project->GetConfigurations()[0].get();
        }

        if (config == nullptr)
        {
            std::cout << "invalid config" << std::endl;
            return false;
        }

        CommandLineArguments arguments;
        arguments.ImportConfig(config);
        arguments.Add("-std=c++14"); // Language standard to compile for
        arguments.Add("-w");         // Suppress all warnings

    #if defined(_MSC_VER)
        arguments.Add("-fms-compatibility-version=19");
    #endif

        if (verbose_)
        {
            arguments.Add("-v"); // Show commands to run and use verbose output
        }

        {
            ScopeTimer timer([](double time) {
                std::cout << ">> " << time << "s" << std::endl;
            });

            if (config->HasPrecompiledHeader())
            {
                FileContext context;

                context.config = config;
                context.arguments = arguments;
                context.filePath = config->GetPrecompiledSource();
                context.save = true;

                if (!ParseSourceFile(context))
                {
                    return false;
                }
            }

            for (auto& file : project->GetFiles())
            {
                if (file.get() && file->IsHeader())
                {
                    if (config->HasPrecompiledHeader() && config->GetPrecompiledSource() == file->GetFile().str())
                    {
                        continue;
                    }

                    FileContext context;

                    context.config = config;
                    context.arguments = arguments;
                    context.filePath = file->GetFile();
                    context.isSource = file->IsSource();
                    context.isHeader = file->IsHeader();
                    context.includePrecompiled = true;

                    if (!ParseSourceFile(context))
                    {
                        return false;
                    }
                }
            }
        }

        return true;
    }