[engine] format
This commit is contained in:
parent
c90f8389f1
commit
76570e653c
|
@ -156,8 +156,10 @@ class Shell {
|
|||
std::function<int(int, char**)> exec_func);
|
||||
|
||||
/* Wrapper function, which calls other command thru shell's APIs */
|
||||
void set_command_execute_function(const ShellCommandId& cmd_id,
|
||||
std::function<int(Shell<T>*, T&, const Command&, const CommandContext&)> exec_func);
|
||||
void set_command_execute_function(
|
||||
const ShellCommandId& cmd_id,
|
||||
std::function<int(Shell<T>*, T&, const Command&, const CommandContext&)>
|
||||
exec_func);
|
||||
|
||||
void set_command_dependency(
|
||||
const ShellCommandId& cmd_id,
|
||||
|
@ -240,7 +242,8 @@ class Shell {
|
|||
command_builtin_execute_functions_;
|
||||
vtr::vector<ShellCommandId, std::function<int(int, char**)>>
|
||||
command_macro_execute_functions_;
|
||||
vtr::vector<ShellCommandId, std::function<int(Shell<T>*, T&, const Command&, const CommandContext&)>>
|
||||
vtr::vector<ShellCommandId, std::function<int(Shell<T>*, T&, const Command&,
|
||||
const CommandContext&)>>
|
||||
command_wrapper_execute_functions_;
|
||||
|
||||
/* Type of execute functions for each command.
|
||||
|
|
|
@ -6,13 +6,16 @@
|
|||
*******************************************************************/
|
||||
#include "basic_command.h"
|
||||
|
||||
#include "openfpga_title.h"
|
||||
#include "command_exit_codes.h"
|
||||
#include "openfpga_title.h"
|
||||
|
||||
/* begin namespace openfpga */
|
||||
namespace openfpga {
|
||||
|
||||
static int source_existing_command(openfpga::Shell<OpenfpgaContext>* shell, OpenfpgaContext& openfpga_ctx, const Command& cmd, const CommandContext& cmd_context) {
|
||||
static int source_existing_command(openfpga::Shell<OpenfpgaContext>* shell,
|
||||
OpenfpgaContext& openfpga_ctx,
|
||||
const Command& cmd,
|
||||
const CommandContext& cmd_context) {
|
||||
CommandOptionId opt_file = cmd.option("from_file");
|
||||
CommandOptionId opt_batch_mode = cmd.option("batch_mode");
|
||||
CommandOptionId opt_ss = cmd.option("command_stream");
|
||||
|
@ -24,7 +27,8 @@ static int source_existing_command(openfpga::Shell<OpenfpgaContext>* shell, Open
|
|||
|
||||
/* If a file is specified, run script mode of the shell, otherwise, */
|
||||
if (is_cmd_file) {
|
||||
shell->run_script_mode(cmd_ss.c_str(), openfpga_ctx, cmd_context.option_enable(cmd, opt_batch_mode));
|
||||
shell->run_script_mode(cmd_ss.c_str(), openfpga_ctx,
|
||||
cmd_context.option_enable(cmd, opt_batch_mode));
|
||||
} else {
|
||||
/* Split the string with ';' and run each command */
|
||||
/* Remove the space at the end of the line
|
||||
|
@ -66,21 +70,24 @@ static ShellCommandId add_openfpga_source_command(
|
|||
|
||||
/* Add an option '--command_stream' */
|
||||
CommandOptionId opt_cmdstream = shell_cmd.add_option(
|
||||
"command_stream", true, "A string/file stream which contains the commands to be executed");
|
||||
"command_stream", true,
|
||||
"A string/file stream which contains the commands to be executed");
|
||||
shell_cmd.set_option_require_value(opt_cmdstream, openfpga::OPT_STRING);
|
||||
|
||||
/* Add an option '--from_file' */
|
||||
shell_cmd.add_option("from_file", false, "Specify the command stream comes from a file");
|
||||
shell_cmd.add_option("from_file", false,
|
||||
"Specify the command stream comes from a file");
|
||||
|
||||
/* Add an option '--batch_mode' */
|
||||
shell_cmd.add_option("batch_mode", false, "Enable batch mode when executing the script from a file (not a string)");
|
||||
shell_cmd.add_option(
|
||||
"batch_mode", false,
|
||||
"Enable batch mode when executing the script from a file (not a string)");
|
||||
|
||||
/* Add command 'repack' to the Shell */
|
||||
ShellCommandId shell_cmd_id =
|
||||
shell.add_command(shell_cmd, "Source a string of commands or execute a script from a file");
|
||||
ShellCommandId shell_cmd_id = shell.add_command(
|
||||
shell_cmd, "Source a string of commands or execute a script from a file");
|
||||
shell.set_command_class(shell_cmd_id, cmd_class_id);
|
||||
shell.set_command_execute_function(shell_cmd_id,
|
||||
source_existing_command);
|
||||
shell.set_command_execute_function(shell_cmd_id, source_existing_command);
|
||||
|
||||
/* Add command dependency to the Shell */
|
||||
shell.set_command_dependency(shell_cmd_id, dependent_cmds);
|
||||
|
@ -88,7 +95,6 @@ static ShellCommandId add_openfpga_source_command(
|
|||
return shell_cmd_id;
|
||||
}
|
||||
|
||||
|
||||
void add_basic_commands(openfpga::Shell<OpenfpgaContext>& shell) {
|
||||
/* Add a new class of commands */
|
||||
ShellCommandClassId basic_cmd_class = shell.add_command_class("Basic");
|
||||
|
@ -122,7 +128,6 @@ void add_basic_commands(openfpga::Shell<OpenfpgaContext>& shell) {
|
|||
/* Add 'source' command which can run a set of commands */
|
||||
add_openfpga_source_command(shell, basic_cmd_class,
|
||||
std::vector<ShellCommandId>());
|
||||
|
||||
}
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
|
Loading…
Reference in New Issue