Compiles a cluster definition file into an executable bash script. More...
#include <Compiler.h>
Public Member Functions | |
Compiler (const string &fname) | |
Constructor. More... | |
string | output_script () |
Returns pathname of output script. More... | |
Private Member Functions | |
bool | compilation_needed () |
Determines if script needs to be re-built. More... | |
void | make () |
Compiles the definition file into a task execution script. More... | |
Private Attributes | |
string | m_definition_file |
Cluster definition file. More... | |
string | m_output_script |
Output script. More... | |
Compiles a cluster definition file into an executable bash script.
Definition at line 45 of file Compiler.h.
Compiler::Compiler | ( | const string & | fname | ) |
Constructor.
Initializes m_definition_file with fname
and initializes m_output_script with the pathname of the output script constructed as follows:
${HOME} + "/.cluster/" + m_definition_file + ".sh"
It then calls compilation_needed() to determine if the script needs to be rebuilt and, if so, calls make().
fname | Pathname of cluster definition file |
Definition at line 154 of file Compiler.cc.
|
private |
Determines if script needs to be re-built.
This function returns true if 1) the output script (m_output_script) does not exist, or 2) the modification timestamp of the definition file (m_definition_file) or any of its dependencies (included files) is greater than the modification timestamp of the output script, or 3) The Hypertable version string listed in the comment header of the output script does not match the current Hypertable version string. The dependencies are listed in a comment header of the output script.
Definition at line 166 of file Compiler.cc.
|
private |
Compiles the definition file into a task execution script.
This function compiles m_definition_file into a task execution script and writes it to the m_output_script file and then does a chmod 755
on that file. The script is assembled as follows. It tokenizes the input definition file with Tokenizer and translates each token using its corresponding translator (TranslatorCode, TranslatorRole, TranslatorTask, TranslatorVariable). After the translated tokens are written, a couple of built-in functions are generated:
Function | Description |
---|---|
show_variables | Displays all of the global variables and role defintion variables |
with | Runs a shell command on any of the roles |
After the built-in functions, argument parsing logic is added to handle the command line arguments:
Argument | Description |
---|---|
-T, –tasks | Displays all tasks with a short description |
-e <task>, –explain <task> | Displays a detailed description of <task> |
<function> | Executes <function> which is one of the task functions or or a built-in function (show_variables or with ) |
A comment header is written to the output script that looks something like this:
# version: 0.9.8.1 (v0.9.8.1-35-g20a3c08) # dependency: /home/doug/core.tasks # dependency: /home/doug/test.tasks
There is one dependency:
line for each file that is included with an include:
directive. These header lines are used by the compilation_needed() function.
Definition at line 224 of file Compiler.cc.
|
inline |
Returns pathname of output script.
Definition at line 62 of file Compiler.h.
|
private |
Cluster definition file.
Definition at line 138 of file Compiler.h.
|
private |
Output script.
Definition at line 141 of file Compiler.h.