| 61 | |
| 62 | |
| 63 | int RunCooker(int argc, char *argv[]) |
| 64 | { |
| 65 | et::fw::ForceLinking(); |
| 66 | |
| 67 | // parse arguments |
| 68 | //----------------- |
| 69 | if (argc < 4) |
| 70 | { |
| 71 | std::cerr << "main > Not enough arguments, exiting! Usage: EtCooker.exe <database path> <out path> <create compiled resource [y/n]>" << std::endl; |
| 72 | return 1; |
| 73 | } |
| 74 | core::FileUtil::SetExecutablePath(argv[0]); // working dir from executable path |
| 75 | std::string databasePath(argv[1]); |
| 76 | std::string engineDbPath(argv[2]); |
| 77 | std::string outPath(argv[3]); |
| 78 | bool const genCompiledResource = (std::string(argv[4]) == "y"); |
| 79 | ET_ASSERT(genCompiledResource || (std::string(argv[4]) == "n"), "Expected argument 4 to be either 'y' or 'n'!"); |
| 80 | |
| 81 | // Init stuff |
| 82 | //------------ |
| 83 | core::Logger::Initialize(); |
| 84 | core::Logger::StartFileLogging("cooker.log"); |
| 85 | |
| 86 | LOG(FS("E.T.Cooker")); |
| 87 | LOG(FS("//////////")); |
| 88 | LOG(""); |
| 89 | LOG(FS(" - version: %s", build::Version::s_Name.c_str())); |
| 90 | LOG(""); |
| 91 | |
| 92 | core::AssetDatabase database; |
| 93 | if (!core::serialization::DeserializeFromFile(databasePath, database)) |
| 94 | { |
| 95 | LOG("main > unable to deserialize asset database at '" + std::string(databasePath) + std::string("'"), core::LogLevel::Error); |
| 96 | } |
| 97 | std::string dbBase = core::FileUtil::ExtractPath(databasePath); |
| 98 | |
| 99 | core::AssetDatabase engineDb; |
| 100 | if (!core::serialization::DeserializeFromFile(engineDbPath, engineDb)) |
| 101 | { |
| 102 | LOG("main > unable to deserialize engine database at '" + std::string(engineDbPath) + std::string("'"), core::LogLevel::Error); |
| 103 | } |
| 104 | std::string engineDbBase = core::FileUtil::ExtractPath(engineDbPath); |
| 105 | |
| 106 | if (genCompiledResource) |
| 107 | { |
| 108 | if (argc < 5) |
| 109 | { |
| 110 | std::cerr << "main > When specifying compiled resource, also specify the resource name in the last arg" << std::endl; |
| 111 | return 2; |
| 112 | } |
| 113 | std::string resName(argv[5]); |
| 114 | |
| 115 | CookCompiledPackage(dbBase, outPath, resName, database, engineDbBase, engineDb); |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | CookFilePackages(dbBase, outPath, database, engineDbBase, engineDb); |
| 120 | } |
no test coverage detected