/++
read configuration files
- read config files
meta_config_files.d
+/
module sdp.meta.read_config_files;
static template configIn() {
import
sdp.meta,
sdp.output.paths_source,
std.file,
std.path;
final string configIn(M,E,C)(M manifest, E env, C conf_sdl) {
auto possible_config_path_locations = ConfigFilePaths!()(manifest, env).possible_config_path_locations;
string config_file_str;
foreach(pth; possible_config_path_locations) {
auto conf_file = format(
"%s/%s",
pth,
conf_sdl,
);
if (config_file_str.length > 0) {
break;
}
try {
if (exists(conf_file)) {
debug(configfile) {
writeln(conf_file);
}
config_file_str = conf_file.readText;
break;
}
}
catch (ErrnoException ex) {
}
catch (FileException ex) {
}
}
return config_file_str;
}
}
/+
+/
static template ConfigSDLang() {
import sdlang;
import
sdp.meta,
sdp.output.paths_source,
std.file,
std.path;
auto ConfigSDLang(string configuration, string conf_sdl_filename) {
Tag sdl_root_conf;
try {
sdl_root_conf = parseSource(configuration);
}
catch(ParseException e) {
stderr.writeln("SDLang problem with content for ", conf_sdl_filename);
stderr.writeln(e.msg);
}
return sdl_root_conf;
}
}
/+
+/
static template configRead() {
import
sdp.meta,
sdp.output.paths_source,
std.file,
std.path;
final auto configRead(M,E,C)(M manifest, E env, C conf_sdl) {
auto configuration = configIn!()(manifest, env, conf_sdl);
auto sdl_root = ConfigSDLang!()(configuration, conf_sdl);
return sdl_root;
}
}