Merge branch 'Laupetin:main' into main

This commit is contained in:
Alex
2024-01-26 12:15:26 -05:00
committed by GitHub
52 changed files with 1838 additions and 359 deletions

View File

@ -616,9 +616,13 @@ public:
bool Start(const int argc, const char** argv) override
{
if (!m_args.ParseArgs(argc, argv))
auto shouldContinue = true;
if (!m_args.ParseArgs(argc, argv, shouldContinue))
return false;
if (!shouldContinue)
return true;
if (!m_search_paths.BuildProjectIndependentSearchPaths())
return false;

View File

@ -1,11 +1,13 @@
#include "LinkerArgs.h"
#include "GitVersion.h"
#include "ObjLoading.h"
#include "ObjWriting.h"
#include "Utils/Arguments/UsageInformation.h"
#include "Utils/FileUtils.h"
#include <filesystem>
#include <iostream>
#include <regex>
#include <type_traits>
@ -19,6 +21,12 @@ const CommandLineOption* const OPTION_HELP =
.WithDescription("Displays usage information.")
.Build();
const CommandLineOption* const OPTION_VERSION =
CommandLineOption::Builder::Create()
.WithLongName("version")
.WithDescription("Prints the application version.")
.Build();
const CommandLineOption* const OPTION_VERBOSE =
CommandLineOption::Builder::Create()
.WithShortName("v")
@ -88,6 +96,7 @@ const CommandLineOption* const OPTION_MENU_NO_OPTIMIZATION =
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
OPTION_HELP,
OPTION_VERSION,
OPTION_VERBOSE,
OPTION_BASE_FOLDER,
OPTION_OUTPUT_FOLDER,
@ -100,7 +109,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
};
LinkerArgs::LinkerArgs()
: m_argument_parser(COMMAND_LINE_OPTIONS, std::extent<decltype(COMMAND_LINE_OPTIONS)>::value),
: m_argument_parser(COMMAND_LINE_OPTIONS, std::extent_v<decltype(COMMAND_LINE_OPTIONS)>),
m_base_pattern(R"(\?base\?)"),
m_game_pattern(R"(\?game\?)"),
m_project_pattern(R"(\?project\?)"),
@ -125,6 +134,11 @@ void LinkerArgs::PrintUsage()
usage.Print();
}
void LinkerArgs::PrintVersion()
{
std::cout << "OpenAssetTools Linker " << std::string(GIT_VERSION) << "\n";
}
void LinkerArgs::SetVerbose(const bool isVerbose)
{
m_verbose = isVerbose;
@ -198,8 +212,9 @@ std::set<std::string> LinkerArgs::GetSearchPathsForProject(const std::set<std::s
return out;
}
bool LinkerArgs::ParseArgs(const int argc, const char** argv)
bool LinkerArgs::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
{
shouldContinue = true;
if (!m_argument_parser.ParseArguments(argc - 1, &argv[1]))
{
PrintUsage();
@ -210,7 +225,16 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv)
if (m_argument_parser.IsOptionSpecified(OPTION_HELP))
{
PrintUsage();
return false;
shouldContinue = false;
return true;
}
// Check if the user wants to see the version
if (m_argument_parser.IsOptionSpecified(OPTION_VERSION))
{
PrintVersion();
shouldContinue = false;
return true;
}
m_project_specifiers_to_build = m_argument_parser.GetArguments();

View File

@ -31,6 +31,7 @@ private:
* \brief Prints a command line usage help text for the Linker tool to stdout.
*/
static void PrintUsage();
static void PrintVersion();
void SetVerbose(bool isVerbose);
@ -56,7 +57,7 @@ public:
bool m_verbose;
LinkerArgs();
bool ParseArgs(int argc, const char** argv);
bool ParseArgs(int argc, const char** argv, bool& shouldContinue);
/**
* \brief Converts the output path specified by command line arguments to a path applies for the specified project.