mirror of
https://github.com/0x221E/ibuild.git
synced 2026-01-18 02:42:20 +00:00
Refactor: Rename configuration process functions
This commit is contained in:
18
ibuild.c
18
ibuild.c
@@ -72,7 +72,6 @@ void log_write(const char* func, const char* fmt, ...)
|
|||||||
|
|
||||||
/*** file management ***/
|
/*** file management ***/
|
||||||
|
|
||||||
|
|
||||||
long file_get_size(FILE* fd)
|
long file_get_size(FILE* fd)
|
||||||
{
|
{
|
||||||
if(fd == NULL) DIE("fd cannot be NULL.");
|
if(fd == NULL) DIE("fd cannot be NULL.");
|
||||||
@@ -425,7 +424,7 @@ void debug_parser(Node* n, int indent)
|
|||||||
|
|
||||||
/*** configuration process ***/
|
/*** configuration process ***/
|
||||||
|
|
||||||
void set_configuration_option(Configuration* co, Key k, char* val)
|
void configuration_set_option(Configuration* co, Key k, char* val)
|
||||||
{
|
{
|
||||||
switch(k)
|
switch(k)
|
||||||
{
|
{
|
||||||
@@ -440,18 +439,18 @@ void set_configuration_option(Configuration* co, Key k, char* val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void populate_configuration_node(Configuration* co, Node* n)
|
void configuration_process_node(Configuration* co, Node* n)
|
||||||
{
|
{
|
||||||
switch(n->type)
|
switch(n->type)
|
||||||
{
|
{
|
||||||
case N_PAIR:
|
case N_PAIR:
|
||||||
Key k = n->key;
|
Key k = n->key;
|
||||||
set_configuration_option(co, k, (char*)((Node*)n->value)->value);
|
configuration_set_option(co, k, (char*)((Node*)n->value)->value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Configuration setup_configuration(int len, Node** st)
|
Configuration configuration_struct_setup(int len, Node** st)
|
||||||
{
|
{
|
||||||
Configuration config;
|
Configuration config;
|
||||||
config.compiler_path = "/usr/bin/gcc";
|
config.compiler_path = "/usr/bin/gcc";
|
||||||
@@ -462,20 +461,19 @@ Configuration setup_configuration(int len, Node** st)
|
|||||||
config.dep_searcher_flags = "-MM";
|
config.dep_searcher_flags = "-MM";
|
||||||
|
|
||||||
for (size_t i = 0; i < len; i++)
|
for (size_t i = 0; i < len; i++)
|
||||||
populate_configuration_node(&config, st[i]);
|
configuration_process_node(&config, st[i]);
|
||||||
|
|
||||||
LOG_USER("Configured IBUILD options.");
|
LOG_USER("Configured IBUILD options.");
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*** configuration file management ***/
|
/*** configuration file management ***/
|
||||||
|
|
||||||
Configuration process_config()
|
Configuration process_config()
|
||||||
{
|
{
|
||||||
if(!file_has_r_access(CONFIG_FILE))
|
if(!file_has_r_access(CONFIG_FILE))
|
||||||
{
|
{
|
||||||
return setup_configuration(0, NULL);
|
return configuration_struct_setup(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_USER("IBUILD Configuration file detected.\n");
|
LOG_USER("IBUILD Configuration file detected.\n");
|
||||||
@@ -512,14 +510,12 @@ Configuration process_config()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return setup_configuration(p_count, statements);
|
return configuration_struct_setup(p_count, statements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
LOG_USER("Build version: %s", VERSION);
|
LOG_USER("Build version: %s", VERSION);
|
||||||
Node** ast = NULL;
|
|
||||||
Configuration c = process_config();
|
Configuration c = process_config();
|
||||||
launch_compile(&c);
|
launch_compile(&c);
|
||||||
memory_free();
|
memory_free();
|
||||||
|
|||||||
Reference in New Issue
Block a user