All checks were successful
Bin2CPP / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 1m44s
Bin2CPP / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 1m45s
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd (Unity Build: OFF) (push) Successful in 48s
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd (Unity Build: ON) (push) Successful in 49s
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd_asan (Unity Build: OFF) (push) Successful in 1m6s
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd_asan (Unity Build: ON) (push) Successful in 1m5s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 1m28s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 1m28s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd (Unity Build: OFF) (push) Successful in 1m8s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd (Unity Build: ON) (push) Successful in 1m7s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd_asan (Unity Build: OFF) (push) Successful in 1m24s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd_asan (Unity Build: ON) (push) Successful in 1m22s
Bin2CPP / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 38s
Bin2CPP / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 34s
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd (Unity Build: OFF) (push) Successful in 31s
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd (Unity Build: ON) (push) Successful in 30s
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd_asan (Unity Build: OFF) (push) Successful in 43s
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd_asan (Unity Build: ON) (push) Successful in 44s
Bin2CPP / Clang Format Checks (push) Successful in 9s
63 lines
1.8 KiB
C++
63 lines
1.8 KiB
C++
#include <Generator.hpp>
|
|
#include <Log.hpp>
|
|
|
|
#include <CLI/CLI.hpp>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
Bin2CPP::Singleton<Bin2CPP::Log>::Lifetime loggerLifetime;
|
|
|
|
CLI::App app {"Bin2CPP allows you to generate a C++ header containing the binary content of an input file"};
|
|
argv = app.ensure_utf8(argv);
|
|
|
|
std::string input;
|
|
app.add_option("-f,--input", input, "The input file")->required();
|
|
std::string output;
|
|
app.add_option("-o,--output", output, "The output file")->required();
|
|
std::optional<std::string> arrayType;
|
|
app.add_option("--arrayType", arrayType, "The type of the array");
|
|
std::optional<std::string> arrayInclude;
|
|
app.add_option("--arrayInclude", arrayInclude, "Include for the array type");
|
|
std::optional<std::string> arrayName;
|
|
app.add_option("--arrayName", arrayName, "The array name");
|
|
std::optional<std::string> customNamespace;
|
|
app.add_option("--namespace", customNamespace, "The namespace");
|
|
|
|
CLI11_PARSE(app, argc, argv);
|
|
|
|
Bin2CPP::Generator generator(input);
|
|
if (arrayType)
|
|
{
|
|
generator.SetMapping(Bin2CPP::MappingKey::ARRAY_TYPE, arrayType.value());
|
|
}
|
|
if (arrayInclude)
|
|
{
|
|
generator.SetMapping(Bin2CPP::MappingKey::ARRAY_TYPE_INCLUDE, arrayInclude.value());
|
|
}
|
|
if (arrayName)
|
|
{
|
|
generator.SetMapping(Bin2CPP::MappingKey::ARRAY_NAME, arrayName.value());
|
|
}
|
|
if (customNamespace)
|
|
{
|
|
generator.SetMapping(Bin2CPP::MappingKey::NAMESPACE, customNamespace.value());
|
|
}
|
|
|
|
if (generator.Generate())
|
|
{
|
|
std::ofstream out(output);
|
|
if (!out)
|
|
{
|
|
BIN2CPP_LOG_ERROR("Failed to open '{}'", output);
|
|
return 1;
|
|
}
|
|
|
|
out << generator.Get();
|
|
out.close();
|
|
}
|
|
|
|
BIN2CPP_LOG_INFO("'{}' Generated !", output);
|
|
|
|
return 0;
|
|
}
|