mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 08:05:45 +00:00
Merge pull request #97 from Laupetin/feature/version-cmd-arg
feat: add version command line arg
This commit is contained in:
commit
87917caabc
@ -3,6 +3,7 @@ include "tools/scripts/including.lua"
|
|||||||
include "tools/scripts/linking.lua"
|
include "tools/scripts/linking.lua"
|
||||||
include "tools/scripts/options.lua"
|
include "tools/scripts/options.lua"
|
||||||
include "tools/scripts/platform.lua"
|
include "tools/scripts/platform.lua"
|
||||||
|
include "tools/scripts/version.lua"
|
||||||
|
|
||||||
-- ==================
|
-- ==================
|
||||||
-- Workspace
|
-- Workspace
|
||||||
@ -64,6 +65,13 @@ workspace "OpenAssetTools"
|
|||||||
"_CRT_SECURE_NO_WARNINGS"
|
"_CRT_SECURE_NO_WARNINGS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Write the current version to a header
|
||||||
|
-- This is better than adding it as macro here since changing a global macro would cause a full rebuild
|
||||||
|
WriteVersionHeader()
|
||||||
|
includedirs {
|
||||||
|
GetVersionHeaderFolder()
|
||||||
|
}
|
||||||
|
|
||||||
filter "options:debug-structureddatadef"
|
filter "options:debug-structureddatadef"
|
||||||
defines { "STRUCTUREDDATADEF_DEBUG" }
|
defines { "STRUCTUREDDATADEF_DEBUG" }
|
||||||
filter {}
|
filter {}
|
||||||
|
@ -613,9 +613,13 @@ public:
|
|||||||
|
|
||||||
bool Start(const int argc, const char** argv) override
|
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;
|
return false;
|
||||||
|
|
||||||
|
if (!shouldContinue)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (!m_search_paths.BuildProjectIndependentSearchPaths())
|
if (!m_search_paths.BuildProjectIndependentSearchPaths())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#include "LinkerArgs.h"
|
#include "LinkerArgs.h"
|
||||||
|
|
||||||
|
#include "GitVersion.h"
|
||||||
#include "ObjLoading.h"
|
#include "ObjLoading.h"
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
#include "Utils/Arguments/UsageInformation.h"
|
#include "Utils/Arguments/UsageInformation.h"
|
||||||
#include "Utils/FileUtils.h"
|
#include "Utils/FileUtils.h"
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <iostream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
@ -19,6 +21,12 @@ const CommandLineOption* const OPTION_HELP =
|
|||||||
.WithDescription("Displays usage information.")
|
.WithDescription("Displays usage information.")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
const CommandLineOption* const OPTION_VERSION =
|
||||||
|
CommandLineOption::Builder::Create()
|
||||||
|
.WithLongName("version")
|
||||||
|
.WithDescription("Prints the application version.")
|
||||||
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_VERBOSE =
|
const CommandLineOption* const OPTION_VERBOSE =
|
||||||
CommandLineOption::Builder::Create()
|
CommandLineOption::Builder::Create()
|
||||||
.WithShortName("v")
|
.WithShortName("v")
|
||||||
@ -88,6 +96,7 @@ const CommandLineOption* const OPTION_MENU_NO_OPTIMIZATION =
|
|||||||
|
|
||||||
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||||
OPTION_HELP,
|
OPTION_HELP,
|
||||||
|
OPTION_VERSION,
|
||||||
OPTION_VERBOSE,
|
OPTION_VERBOSE,
|
||||||
OPTION_BASE_FOLDER,
|
OPTION_BASE_FOLDER,
|
||||||
OPTION_OUTPUT_FOLDER,
|
OPTION_OUTPUT_FOLDER,
|
||||||
@ -100,7 +109,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
|||||||
};
|
};
|
||||||
|
|
||||||
LinkerArgs::LinkerArgs()
|
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_base_pattern(R"(\?base\?)"),
|
||||||
m_game_pattern(R"(\?game\?)"),
|
m_game_pattern(R"(\?game\?)"),
|
||||||
m_project_pattern(R"(\?project\?)"),
|
m_project_pattern(R"(\?project\?)"),
|
||||||
@ -125,6 +134,11 @@ void LinkerArgs::PrintUsage()
|
|||||||
usage.Print();
|
usage.Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinkerArgs::PrintVersion()
|
||||||
|
{
|
||||||
|
std::cout << "OpenAssetTools Linker " << std::string(GIT_VERSION) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
void LinkerArgs::SetVerbose(const bool isVerbose)
|
void LinkerArgs::SetVerbose(const bool isVerbose)
|
||||||
{
|
{
|
||||||
m_verbose = isVerbose;
|
m_verbose = isVerbose;
|
||||||
@ -198,8 +212,9 @@ std::set<std::string> LinkerArgs::GetSearchPathsForProject(const std::set<std::s
|
|||||||
return out;
|
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]))
|
if (!m_argument_parser.ParseArguments(argc - 1, &argv[1]))
|
||||||
{
|
{
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
@ -210,7 +225,16 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv)
|
|||||||
if (m_argument_parser.IsOptionSpecified(OPTION_HELP))
|
if (m_argument_parser.IsOptionSpecified(OPTION_HELP))
|
||||||
{
|
{
|
||||||
PrintUsage();
|
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();
|
m_project_specifiers_to_build = m_argument_parser.GetArguments();
|
||||||
|
@ -31,6 +31,7 @@ private:
|
|||||||
* \brief Prints a command line usage help text for the Linker tool to stdout.
|
* \brief Prints a command line usage help text for the Linker tool to stdout.
|
||||||
*/
|
*/
|
||||||
static void PrintUsage();
|
static void PrintUsage();
|
||||||
|
static void PrintVersion();
|
||||||
|
|
||||||
void SetVerbose(bool isVerbose);
|
void SetVerbose(bool isVerbose);
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ public:
|
|||||||
bool m_verbose;
|
bool m_verbose;
|
||||||
|
|
||||||
LinkerArgs();
|
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.
|
* \brief Converts the output path specified by command line arguments to a path applies for the specified project.
|
||||||
|
@ -45,9 +45,13 @@ public:
|
|||||||
|
|
||||||
int Run(const int argc, const char** argv)
|
int Run(const int argc, const char** argv)
|
||||||
{
|
{
|
||||||
if (!m_args.Parse(argc, argv))
|
auto shouldContinue = true;
|
||||||
|
if (!m_args.ParseArgs(argc, argv, shouldContinue))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (!shouldContinue)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!m_args.m_build_log_file.empty())
|
if (!m_args.m_build_log_file.empty())
|
||||||
{
|
{
|
||||||
fs::path p = fs::path(m_args.m_build_log_file).parent_path();
|
fs::path p = fs::path(m_args.m_build_log_file).parent_path();
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
#include "RawTemplaterArguments.h"
|
#include "RawTemplaterArguments.h"
|
||||||
|
|
||||||
|
#include "GitVersion.h"
|
||||||
#include "Utils/Arguments/CommandLineOption.h"
|
#include "Utils/Arguments/CommandLineOption.h"
|
||||||
#include "Utils/Arguments/UsageInformation.h"
|
#include "Utils/Arguments/UsageInformation.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_HELP =
|
const CommandLineOption* const OPTION_HELP =
|
||||||
CommandLineOption::Builder::Create().WithShortName("?").WithLongName("help").WithDescription("Displays usage information.").Build();
|
CommandLineOption::Builder::Create().WithShortName("?").WithLongName("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 =
|
const CommandLineOption* const OPTION_VERBOSE =
|
||||||
CommandLineOption::Builder::Create().WithShortName("v").WithLongName("verbose").WithDescription("Outputs a lot more and more detailed messages.").Build();
|
CommandLineOption::Builder::Create().WithShortName("v").WithLongName("verbose").WithDescription("Outputs a lot more and more detailed messages.").Build();
|
||||||
|
|
||||||
@ -30,7 +37,14 @@ const CommandLineOption* const OPTION_DEFINE = CommandLineOption::Builder::Creat
|
|||||||
.Reusable()
|
.Reusable()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{OPTION_HELP, OPTION_VERBOSE, OPTION_OUTPUT_FOLDER, OPTION_BUILD_LOG, OPTION_DEFINE};
|
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||||
|
OPTION_HELP,
|
||||||
|
OPTION_VERSION,
|
||||||
|
OPTION_VERBOSE,
|
||||||
|
OPTION_OUTPUT_FOLDER,
|
||||||
|
OPTION_BUILD_LOG,
|
||||||
|
OPTION_DEFINE,
|
||||||
|
};
|
||||||
|
|
||||||
RawTemplaterArguments::RawTemplaterArguments()
|
RawTemplaterArguments::RawTemplaterArguments()
|
||||||
: m_argument_parser(COMMAND_LINE_OPTIONS, std::extent_v<decltype(COMMAND_LINE_OPTIONS)>),
|
: m_argument_parser(COMMAND_LINE_OPTIONS, std::extent_v<decltype(COMMAND_LINE_OPTIONS)>),
|
||||||
@ -50,8 +64,14 @@ void RawTemplaterArguments::PrintUsage()
|
|||||||
usage.Print();
|
usage.Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RawTemplaterArguments::Parse(const int argc, const char** argv)
|
void RawTemplaterArguments::PrintVersion()
|
||||||
{
|
{
|
||||||
|
std::cout << "OpenAssetTools RawTemplater " << std::string(GIT_VERSION) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RawTemplaterArguments::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
|
||||||
|
{
|
||||||
|
shouldContinue = true;
|
||||||
if (!m_argument_parser.ParseArguments(argc - 1, &argv[1]))
|
if (!m_argument_parser.ParseArguments(argc - 1, &argv[1]))
|
||||||
{
|
{
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
@ -62,7 +82,16 @@ bool RawTemplaterArguments::Parse(const int argc, const char** argv)
|
|||||||
if (m_argument_parser.IsOptionSpecified(OPTION_HELP))
|
if (m_argument_parser.IsOptionSpecified(OPTION_HELP))
|
||||||
{
|
{
|
||||||
PrintUsage();
|
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_input_files = m_argument_parser.GetArguments();
|
m_input_files = m_argument_parser.GetArguments();
|
||||||
|
@ -14,6 +14,7 @@ class RawTemplaterArguments
|
|||||||
* \brief Prints a command line usage help text for the RawTemplater tool to stdout.
|
* \brief Prints a command line usage help text for the RawTemplater tool to stdout.
|
||||||
*/
|
*/
|
||||||
static void PrintUsage();
|
static void PrintUsage();
|
||||||
|
static void PrintVersion();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool m_verbose;
|
bool m_verbose;
|
||||||
@ -27,5 +28,5 @@ public:
|
|||||||
|
|
||||||
RawTemplaterArguments();
|
RawTemplaterArguments();
|
||||||
|
|
||||||
bool Parse(int argc, const char** argv);
|
bool ParseArgs(int argc, const char** argv, bool& shouldContinue);
|
||||||
};
|
};
|
||||||
|
@ -429,9 +429,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool Start(const int argc, const char** argv)
|
bool Start(const int argc, const char** argv)
|
||||||
{
|
{
|
||||||
if (!m_args.ParseArgs(argc, argv))
|
auto shouldContinue = true;
|
||||||
|
if (!m_args.ParseArgs(argc, argv, shouldContinue))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!shouldContinue)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (!BuildSearchPaths())
|
if (!BuildSearchPaths())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#include "UnlinkerArgs.h"
|
#include "UnlinkerArgs.h"
|
||||||
|
|
||||||
|
#include "GitVersion.h"
|
||||||
#include "ObjLoading.h"
|
#include "ObjLoading.h"
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
#include "Utils/Arguments/UsageInformation.h"
|
#include "Utils/Arguments/UsageInformation.h"
|
||||||
#include "Utils/FileUtils.h"
|
#include "Utils/FileUtils.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
@ -16,6 +18,12 @@ const CommandLineOption* const OPTION_HELP =
|
|||||||
.WithDescription("Displays usage information.")
|
.WithDescription("Displays usage information.")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
const CommandLineOption* const OPTION_VERSION =
|
||||||
|
CommandLineOption::Builder::Create()
|
||||||
|
.WithLongName("version")
|
||||||
|
.WithDescription("Prints the application version.")
|
||||||
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_VERBOSE =
|
const CommandLineOption* const OPTION_VERBOSE =
|
||||||
CommandLineOption::Builder::Create()
|
CommandLineOption::Builder::Create()
|
||||||
.WithShortName("v")
|
.WithShortName("v")
|
||||||
@ -113,6 +121,7 @@ const CommandLineOption* const OPTION_LEGACY_MENUS =
|
|||||||
|
|
||||||
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||||
OPTION_HELP,
|
OPTION_HELP,
|
||||||
|
OPTION_VERSION,
|
||||||
OPTION_VERBOSE,
|
OPTION_VERBOSE,
|
||||||
OPTION_MINIMAL_ZONE_FILE,
|
OPTION_MINIMAL_ZONE_FILE,
|
||||||
OPTION_LOAD,
|
OPTION_LOAD,
|
||||||
@ -155,6 +164,11 @@ void UnlinkerArgs::PrintUsage()
|
|||||||
usage.Print();
|
usage.Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnlinkerArgs::PrintVersion()
|
||||||
|
{
|
||||||
|
std::cout << "OpenAssetTools Unlinker " << std::string(GIT_VERSION) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
void UnlinkerArgs::SetVerbose(const bool isVerbose)
|
void UnlinkerArgs::SetVerbose(const bool isVerbose)
|
||||||
{
|
{
|
||||||
m_verbose = isVerbose;
|
m_verbose = isVerbose;
|
||||||
@ -237,8 +251,9 @@ void UnlinkerArgs::ParseCommaSeparatedAssetTypeString(const std::string& input)
|
|||||||
AddSpecifiedAssetType(std::string(lowerInput, currentPos, lowerInput.size() - currentPos));
|
AddSpecifiedAssetType(std::string(lowerInput, currentPos, lowerInput.size() - currentPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UnlinkerArgs::ParseArgs(const int argc, const char** argv)
|
bool UnlinkerArgs::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
|
||||||
{
|
{
|
||||||
|
shouldContinue = true;
|
||||||
if (!m_argument_parser.ParseArguments(argc - 1, &argv[1]))
|
if (!m_argument_parser.ParseArguments(argc - 1, &argv[1]))
|
||||||
{
|
{
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
@ -249,7 +264,16 @@ bool UnlinkerArgs::ParseArgs(const int argc, const char** argv)
|
|||||||
if (m_argument_parser.IsOptionSpecified(OPTION_HELP))
|
if (m_argument_parser.IsOptionSpecified(OPTION_HELP))
|
||||||
{
|
{
|
||||||
PrintUsage();
|
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_zones_to_unlink = m_argument_parser.GetArguments();
|
m_zones_to_unlink = m_argument_parser.GetArguments();
|
||||||
|
@ -21,6 +21,7 @@ private:
|
|||||||
* \brief Prints a command line usage help text for the Unlinker tool to stdout.
|
* \brief Prints a command line usage help text for the Unlinker tool to stdout.
|
||||||
*/
|
*/
|
||||||
static void PrintUsage();
|
static void PrintUsage();
|
||||||
|
static void PrintVersion();
|
||||||
|
|
||||||
void SetVerbose(bool isVerbose);
|
void SetVerbose(bool isVerbose);
|
||||||
bool SetImageDumpingMode();
|
bool SetImageDumpingMode();
|
||||||
@ -60,7 +61,7 @@ public:
|
|||||||
bool m_verbose;
|
bool m_verbose;
|
||||||
|
|
||||||
UnlinkerArgs();
|
UnlinkerArgs();
|
||||||
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 zone.
|
* \brief Converts the output path specified by command line arguments to a path applies for the specified zone.
|
||||||
|
@ -64,9 +64,13 @@ public:
|
|||||||
|
|
||||||
int Run(const int argc, const char** argv)
|
int Run(const int argc, const char** argv)
|
||||||
{
|
{
|
||||||
if (!m_args.Parse(argc, argv))
|
auto shouldContinue = true;
|
||||||
|
if (!m_args.ParseArgs(argc, argv, shouldContinue))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (!shouldContinue)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!ReadHeaderData() || !ReadCommandsData())
|
if (!ReadHeaderData() || !ReadCommandsData())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "ZoneCodeGeneratorArguments.h"
|
#include "ZoneCodeGeneratorArguments.h"
|
||||||
|
|
||||||
|
#include "GitVersion.h"
|
||||||
#include "Utils/Arguments/CommandLineOption.h"
|
#include "Utils/Arguments/CommandLineOption.h"
|
||||||
#include "Utils/Arguments/UsageInformation.h"
|
#include "Utils/Arguments/UsageInformation.h"
|
||||||
|
|
||||||
@ -9,6 +10,9 @@
|
|||||||
const CommandLineOption* const OPTION_HELP =
|
const CommandLineOption* const OPTION_HELP =
|
||||||
CommandLineOption::Builder::Create().WithShortName("?").WithLongName("help").WithDescription("Displays usage information.").Build();
|
CommandLineOption::Builder::Create().WithShortName("?").WithLongName("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 =
|
const CommandLineOption* const OPTION_VERBOSE =
|
||||||
CommandLineOption::Builder::Create().WithShortName("v").WithLongName("verbose").WithDescription("Outputs a lot more and more detailed messages.").Build();
|
CommandLineOption::Builder::Create().WithShortName("v").WithLongName("verbose").WithDescription("Outputs a lot more and more detailed messages.").Build();
|
||||||
|
|
||||||
@ -70,7 +74,15 @@ const CommandLineOption* const OPTION_GENERATE =
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||||
OPTION_HELP, OPTION_VERBOSE, OPTION_HEADER, OPTION_COMMANDS_FILE, OPTION_OUTPUT_FOLDER, OPTION_PRINT, OPTION_GENERATE};
|
OPTION_HELP,
|
||||||
|
OPTION_VERSION,
|
||||||
|
OPTION_VERBOSE,
|
||||||
|
OPTION_HEADER,
|
||||||
|
OPTION_COMMANDS_FILE,
|
||||||
|
OPTION_OUTPUT_FOLDER,
|
||||||
|
OPTION_PRINT,
|
||||||
|
OPTION_GENERATE,
|
||||||
|
};
|
||||||
|
|
||||||
ZoneCodeGeneratorArguments::GenerationTask::GenerationTask()
|
ZoneCodeGeneratorArguments::GenerationTask::GenerationTask()
|
||||||
: m_all_assets(false)
|
: m_all_assets(false)
|
||||||
@ -91,7 +103,7 @@ ZoneCodeGeneratorArguments::GenerationTask::GenerationTask(std::string assetName
|
|||||||
}
|
}
|
||||||
|
|
||||||
ZoneCodeGeneratorArguments::ZoneCodeGeneratorArguments()
|
ZoneCodeGeneratorArguments::ZoneCodeGeneratorArguments()
|
||||||
: 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_task_flags(0)
|
m_task_flags(0)
|
||||||
{
|
{
|
||||||
m_verbose = false;
|
m_verbose = false;
|
||||||
@ -109,8 +121,14 @@ void ZoneCodeGeneratorArguments::PrintUsage()
|
|||||||
usage.Print();
|
usage.Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneCodeGeneratorArguments::Parse(const int argc, const char** argv)
|
void ZoneCodeGeneratorArguments::PrintVersion()
|
||||||
{
|
{
|
||||||
|
std::cout << "OpenAssetTools ZoneCodeGenerator " << std::string(GIT_VERSION) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
|
||||||
|
{
|
||||||
|
shouldContinue = true;
|
||||||
if (!m_argument_parser.ParseArguments(argc - 1, &argv[1]))
|
if (!m_argument_parser.ParseArguments(argc - 1, &argv[1]))
|
||||||
{
|
{
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
@ -121,7 +139,16 @@ bool ZoneCodeGeneratorArguments::Parse(const int argc, const char** argv)
|
|||||||
if (m_argument_parser.IsOptionSpecified(OPTION_HELP))
|
if (m_argument_parser.IsOptionSpecified(OPTION_HELP))
|
||||||
{
|
{
|
||||||
PrintUsage();
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -v; --verbose
|
// -v; --verbose
|
||||||
|
@ -13,6 +13,7 @@ class ZoneCodeGeneratorArguments
|
|||||||
* \brief Prints a command line usage help text for the Unlinker tool to stdout.
|
* \brief Prints a command line usage help text for the Unlinker tool to stdout.
|
||||||
*/
|
*/
|
||||||
static void PrintUsage();
|
static void PrintUsage();
|
||||||
|
static void PrintVersion();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr unsigned FLAG_TASK_GENERATE = 1 << 0;
|
static constexpr unsigned FLAG_TASK_GENERATE = 1 << 0;
|
||||||
@ -40,8 +41,7 @@ public:
|
|||||||
std::vector<GenerationTask> m_generation_tasks;
|
std::vector<GenerationTask> m_generation_tasks;
|
||||||
|
|
||||||
ZoneCodeGeneratorArguments();
|
ZoneCodeGeneratorArguments();
|
||||||
|
bool ParseArgs(int argc, const char** argv, bool& shouldContinue);
|
||||||
bool Parse(int argc, const char** argv);
|
|
||||||
|
|
||||||
_NODISCARD bool ShouldGenerate() const;
|
_NODISCARD bool ShouldGenerate() const;
|
||||||
_NODISCARD bool ShouldPrint() const;
|
_NODISCARD bool ShouldPrint() const;
|
||||||
|
36
tools/scripts/version.lua
Normal file
36
tools/scripts/version.lua
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
local BuildSubFolderFolder = "premake"
|
||||||
|
local HeaderFileName = "GitVersion.h"
|
||||||
|
|
||||||
|
function GetGitVersion()
|
||||||
|
result, errorCode = os.outputof("git describe --tags")
|
||||||
|
|
||||||
|
if errorCode == 0 then
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
return "Unknown"
|
||||||
|
end
|
||||||
|
|
||||||
|
function GetVersionHeaderFolder()
|
||||||
|
return path.join(BuildFolder(), BuildSubFolderFolder)
|
||||||
|
end
|
||||||
|
|
||||||
|
function WriteVersionHeader()
|
||||||
|
local folder = GetVersionHeaderFolder()
|
||||||
|
local file = path.join(folder, HeaderFileName)
|
||||||
|
local content = string.format([[
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define GIT_VERSION "%s"
|
||||||
|
]], GetGitVersion())
|
||||||
|
|
||||||
|
if os.isdir(folder) ~= True then
|
||||||
|
os.mkdir(folder)
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok, err = os.writefile_ifnotequal(content, file)
|
||||||
|
|
||||||
|
if ok == -1 then
|
||||||
|
error("Could not create version file: " .. err)
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user