[Tool] Add --version to openfpga shell option and a command to openfpga shell
This commit is contained in:
parent
487bcd6734
commit
d9fda31a9f
|
@ -1,8 +1,10 @@
|
|||
/********************************************************************
|
||||
* Add basic commands to the OpenFPGA shell interface, including:
|
||||
* - exit
|
||||
* - version
|
||||
* - help
|
||||
*******************************************************************/
|
||||
#include "openfpga_title.h"
|
||||
#include "basic_command.h"
|
||||
|
||||
/* begin namespace openfpga */
|
||||
|
@ -17,7 +19,15 @@ void add_basic_commands(openfpga::Shell<OpenfpgaContext>& shell) {
|
|||
shell.set_command_class(shell_cmd_exit_id, basic_cmd_class);
|
||||
shell.set_command_execute_function(shell_cmd_exit_id, [shell](){shell.exit();});
|
||||
|
||||
/* Note: help must be the last to add because the linking to execute function will do a snapshot on the shell */
|
||||
/* Version */
|
||||
Command shell_cmd_version("version");
|
||||
ShellCommandId shell_cmd_version_id = shell.add_command(shell_cmd_version, "Show version information");
|
||||
shell.set_command_class(shell_cmd_version_id, basic_cmd_class);
|
||||
shell.set_command_execute_function(shell_cmd_version_id, print_openfpga_version_info);
|
||||
|
||||
/* Note:
|
||||
* help MUST be the last to add because the linking to execute function will do a snapshot on the shell
|
||||
*/
|
||||
Command shell_cmd_help("help");
|
||||
ShellCommandId shell_cmd_help_id = shell.add_command(shell_cmd_help, "Launch help desk");
|
||||
shell.set_command_class(shell_cmd_help_id, basic_cmd_class);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* This file includes the functions to create the title page
|
||||
* which introduces generality of OpenFPGA framework
|
||||
*******************************************************************/
|
||||
#include "vtr_log.h"
|
||||
|
||||
#include "openfpga_title.h"
|
||||
#include "openfpga_version.h"
|
||||
|
||||
|
@ -50,13 +52,19 @@ std::string create_openfpga_title() {
|
|||
title += std::string("THE SOFTWARE.\n");
|
||||
title += std::string("\n");
|
||||
|
||||
/* Display version */
|
||||
title += std::string("Version: " + std::string(openfpga::VERSION) + "\n");
|
||||
title += std::string("Revision: " + std::string(openfpga::VCS_REVISION) + "\n");
|
||||
title += std::string("Compiled: " + std::string(openfpga::BUILD_TIMESTAMP) + "\n");
|
||||
title += std::string("Compiler: " + std::string(openfpga::COMPILER) + "\n");
|
||||
title += std::string("Build Info: " + std::string(openfpga::BUILD_INFO) + "\n");
|
||||
title += std::string("\n");
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* Generate a string of openfpga title introduction
|
||||
* This is mainly used when launching OpenFPGA shell
|
||||
*******************************************************************/
|
||||
void print_openfpga_version_info() {
|
||||
/* Display version */
|
||||
VTR_LOG("Version: %s\n", openfpga::VERSION);
|
||||
VTR_LOG("Revision: %s\n", openfpga::VCS_REVISION);
|
||||
VTR_LOG("Compiled: %s\n", openfpga::BUILD_TIMESTAMP);
|
||||
VTR_LOG("Compiler: %s\n", openfpga::COMPILER);
|
||||
VTR_LOG("Build Info: %s\n", openfpga::BUILD_INFO);
|
||||
VTR_LOG("\n");
|
||||
}
|
||||
|
|
|
@ -11,4 +11,6 @@
|
|||
*******************************************************************/
|
||||
std::string create_openfpga_title();
|
||||
|
||||
void print_openfpga_version_info();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,21 +29,27 @@ int main(int argc, char** argv) {
|
|||
|
||||
/* Create the command to launch shell in different modes */
|
||||
openfpga::Command start_cmd("OpenFPGA");
|
||||
/* Add options:
|
||||
* '--interactive', -i': launch the interactive mode
|
||||
* '--file', -f': launch the script mode
|
||||
* '--batch_execution': execute the script in batch mode. Will exit immediately when fatal errors occurred
|
||||
*/
|
||||
/* Add options to openfpga shell interface */
|
||||
/* '--interactive', -i': launch the interactive mode */
|
||||
openfpga::CommandOptionId opt_interactive = start_cmd.add_option("interactive", false, "Launch OpenFPGA in interactive mode");
|
||||
start_cmd.set_option_short_name(opt_interactive, "i");
|
||||
|
||||
/* '--file', -f': launch the script mode */
|
||||
openfpga::CommandOptionId opt_script_mode = start_cmd.add_option("file", false, "Launch OpenFPGA in script mode");
|
||||
start_cmd.set_option_require_value(opt_script_mode, openfpga::OPT_STRING);
|
||||
start_cmd.set_option_short_name(opt_script_mode, "f");
|
||||
|
||||
/* '--batch_execution': execute the script in batch mode.
|
||||
* Will exit immediately when fatal errors occurred
|
||||
*/
|
||||
openfpga::CommandOptionId opt_batch_exec = start_cmd.add_option("batch_execution", false, "Launch OpenFPGA in batch mode when running scripts");
|
||||
start_cmd.set_option_short_name(opt_batch_exec, "batch");
|
||||
|
||||
/* '--version', -v': print version information */
|
||||
openfpga::CommandOptionId opt_version = start_cmd.add_option("version", false, "Show OpenFPGA version");
|
||||
start_cmd.set_option_short_name(opt_version, "v");
|
||||
|
||||
/* '--help', -h': print help desk */
|
||||
openfpga::CommandOptionId opt_help = start_cmd.add_option("help", false, "Help desk");
|
||||
start_cmd.set_option_short_name(opt_help, "h");
|
||||
|
||||
|
@ -95,7 +101,13 @@ int main(int argc, char** argv) {
|
|||
/* Parse fail: Echo the command */
|
||||
openfpga::print_command_options(start_cmd);
|
||||
} else {
|
||||
/* Parse succeed. Start a shell */
|
||||
/* Parse succeed. Branch on options */
|
||||
/* Show version */
|
||||
if (true == start_cmd_context.option_enable(start_cmd, opt_version)) {
|
||||
print_openfpga_version_info();
|
||||
return 0;
|
||||
}
|
||||
/* Start a shell */
|
||||
if (true == start_cmd_context.option_enable(start_cmd, opt_interactive)) {
|
||||
|
||||
shell.run_interactive_mode(openfpga_context);
|
||||
|
|
Loading…
Reference in New Issue