diff --git a/es2panda/aot/main.cpp b/es2panda/aot/main.cpp index 2da57c1bb0edd3ccb5ad60058ec827725194fae1..6b0f618d48360e24550ba4bfe0b5790057e17d44 100644 --- a/es2panda/aot/main.cpp +++ b/es2panda/aot/main.cpp @@ -141,6 +141,14 @@ int Run(int argc, const char **argv) return 1; } + if (options->CompilerOptions().bcVersion || options->CompilerOptions().bcMinVersion) { + std::string version = options->CompilerOptions().bcVersion ? + panda::panda_file::GetVersion(panda::panda_file::version) : + panda::panda_file::GetVersion(panda::panda_file::minVersion); + std::cout << version << std::endl; + return 0; + } + std::map programsInfo; size_t expectedProgsCount = options->CompilerOptions().sourceFiles.size(); panda::ArenaAllocator allocator(panda::SpaceType::SPACE_TYPE_COMPILER, nullptr, true); diff --git a/es2panda/aot/options.cpp b/es2panda/aot/options.cpp index 7d56cfb73cda5854536aa510be4af5dee0ff57da..10410d94915a965db6615b908386a6194691aea6 100644 --- a/es2panda/aot/options.cpp +++ b/es2panda/aot/options.cpp @@ -158,6 +158,10 @@ bool Options::Parse(int argc, const char **argv) panda::PandArg opInputSymbolTable("input-symbol-table", "", "input symbol table file"); panda::PandArg opGeneratePatch("generate-patch", false, "generate patch abc"); + // version + panda::PandArg bcVersion("bc-version", false, "Print ark bytecode version"); + panda::PandArg bcMinVersion("bc-min-version", false, "Print ark bytecode minimum supported version"); + // tail arguments panda::PandArg inputFile("input", "", "input file"); @@ -193,12 +197,22 @@ bool Options::Parse(int argc, const char **argv) argparser_->Add(&opInputSymbolTable); argparser_->Add(&opGeneratePatch); + argparser_->Add(&bcVersion); + argparser_->Add(&bcMinVersion); + argparser_->PushBackTail(&inputFile); argparser_->EnableTail(); argparser_->EnableRemainder(); - if (!argparser_->Parse(argc, argv) || opHelp.GetValue() || (inputFile.GetValue().empty() - && base64Input.GetValue().empty())) { + bool parseStatus = argparser_->Parse(argc, argv); + + if (parseStatus && (bcVersion.GetValue() || bcMinVersion.GetValue())) { + compilerOptions_.bcVersion = bcVersion.GetValue(); + compilerOptions_.bcMinVersion = bcMinVersion.GetValue(); + return true; + } + + if (!parseStatus || opHelp.GetValue() || (inputFile.GetValue().empty() && base64Input.GetValue().empty())) { std::stringstream ss; ss << argparser_->GetErrorString() << std::endl; diff --git a/es2panda/es2panda.h b/es2panda/es2panda.h index c6144e2e6f206a8f12ef4ec9645837983010b2d5..ef72517fc345d13ab85fdcd41b5696aac7552292 100644 --- a/es2panda/es2panda.h +++ b/es2panda/es2panda.h @@ -81,6 +81,8 @@ struct CompilerOptions { std::string debugInfoSourceFile {}; std::vector sourceFiles; HotfixOptions hotfixOptions; + bool bcVersion {false}; + bool bcMinVersion {false}; }; enum class ErrorType {