14
14
#include < cassert>
15
15
#include < cstdio>
16
16
#include < cstdlib>
17
+ #include < fcntl.h>
17
18
#include < fstream>
18
19
#include < iostream>
19
20
#include < memory>
@@ -426,7 +427,8 @@ static int set_arch_variables(const char *arch = nullptr) {
426
427
this_arch = ab_get_current_architecture ();
427
428
}
428
429
// ARCH=$(abdetectarch)
429
- bind_global_variable (" ARCH" , const_cast <char *>(this_arch.c_str ()), ASS_NOEVAL);
430
+ bind_global_variable (" ARCH" , const_cast <char *>(this_arch.c_str ()),
431
+ ASS_NOEVAL);
430
432
// ABHOST=ARCH
431
433
bind_global_variable (" ABHOST" , const_cast <char *>(this_arch.c_str ()),
432
434
ASS_NOEVAL);
@@ -795,20 +797,20 @@ static int abelf_copy_dbg(WORD_LIST *list) {
795
797
int opt = 0 ;
796
798
while ((opt = internal_getopt (list, const_cast <char *>(" exrp" ))) != -1 ) {
797
799
switch (opt) {
798
- case ' x' :
799
- flags |= AB_ELF_STRIP_ONLY;
800
- break ;
801
- case ' r' :
802
- flags |= AB_ELF_CHECK_ONLY;
803
- break ;
804
- case ' e' :
805
- flags |= AB_ELF_USE_EU_STRIP;
806
- break ;
807
- case ' p' :
808
- flags |= AB_ELF_SAVE_WITH_PATH;
809
- break ;
810
- default :
811
- return 1 ;
800
+ case ' x' :
801
+ flags |= AB_ELF_STRIP_ONLY;
802
+ break ;
803
+ case ' r' :
804
+ flags |= AB_ELF_CHECK_ONLY;
805
+ break ;
806
+ case ' e' :
807
+ flags |= AB_ELF_USE_EU_STRIP;
808
+ break ;
809
+ case ' p' :
810
+ flags |= AB_ELF_SAVE_WITH_PATH;
811
+ break ;
812
+ default :
813
+ return 1 ;
812
814
}
813
815
}
814
816
@@ -822,14 +824,14 @@ static int abelf_copy_dbg(WORD_LIST *list) {
822
824
return EX_BADUSAGE;
823
825
GuardedSet<std::string> symbols{};
824
826
GuardedSet<std::string> sonames;
825
- const int ret =
826
- elf_copy_debug_symbols (src, dst, flags, symbols, sonames);
827
+ const int ret = elf_copy_debug_symbols (src, dst, flags, symbols, sonames);
827
828
if (ret < 0 )
828
829
return 10 ;
829
830
return 0 ;
830
831
}
831
832
832
- static void ab_set_to_bash_array (const char *varname, const std::unordered_set<std::string> &set) {
833
+ static void ab_set_to_bash_array (const char *varname,
834
+ const std::unordered_set<std::string> &set) {
833
835
auto *var = make_new_array_variable (const_cast <char *>(varname));
834
836
var->attributes |= att_readonly;
835
837
auto *var_a = array_cell (var);
@@ -881,8 +883,8 @@ static int abelf_copy_dbg_parallel(WORD_LIST *list) {
881
883
args.pop_back ();
882
884
std::unordered_set<std::string> so_deps{};
883
885
std::unordered_set<std::string> sonames;
884
- const int ret =
885
- elf_copy_debug_symbols_parallel (args, dst. c_str (), so_deps, sonames, flags);
886
+ const int ret = elf_copy_debug_symbols_parallel (args, dst. c_str (), so_deps,
887
+ sonames, flags);
886
888
if (ret < 0 )
887
889
return 10 ;
888
890
// copy the data to the bash variable
@@ -1285,7 +1287,8 @@ static int ab_parse_set_modifiers(WORD_LIST *list) {
1285
1287
return 0 ;
1286
1288
}
1287
1289
1288
- static int ab_dump_variables (const std::vector<std::string> &names, bool write_to_file) {
1290
+ static int ab_dump_variables (const std::vector<std::string> &names,
1291
+ bool write_to_file) {
1289
1292
const std::string res = autobuild_serialized_variables (names);
1290
1293
if (write_to_file) {
1291
1294
std::ofstream file (" .srcinfo.json" );
@@ -1429,6 +1432,10 @@ void register_all_native_functions() {
1429
1432
autobuild_register_builtins (functions);
1430
1433
}
1431
1434
1435
+ static int load_config_file () {
1436
+ return autobuild_load_file (" /etc/autobuild/ab4cfg.sh" , false ) == true ;
1437
+ }
1438
+
1432
1439
int register_builtin_variables () {
1433
1440
int ret = 0 ;
1434
1441
// Initialize logger
@@ -1439,6 +1446,7 @@ int register_builtin_variables() {
1439
1446
fmt::format (" Failed to setup default env variables: {0}" , ret));
1440
1447
return ret;
1441
1448
}
1449
+ (void )load_config_file ();
1442
1450
if ((ret = set_arch_variables ())) {
1443
1451
get_logger ()->error (fmt::format (
1444
1452
" Failed to setup default architecture variables: {0}" , ret));
@@ -1509,7 +1517,7 @@ void autobuild_crash_handler(int sig, siginfo_t *info, void *ucontext) {
1509
1517
}
1510
1518
1511
1519
void setup_crash_handler () {
1512
- struct sigaction action {};
1520
+ struct sigaction action{};
1513
1521
action.sa_sigaction = autobuild_crash_handler;
1514
1522
action.sa_flags = SA_SIGINFO;
1515
1523
sigaction (SIGSEGV, &action, nullptr );
0 commit comments