void jb_rmtree (const char *dir) { /* * Be paranoid and refuse abberant inputs. These tests are not * assertions to make sure that they won't be compiled out. */ if (dir == NULL) g_error("dir is NULL"); if (g_path_is_absolute(dir)) g_error("refusing to rmtree an absolute path"); jb_exec(NULL, NULL, "rm -rf %s", dir); }
gboolean jb_test_run (const char *filename, const char *cflags, const char *cppflags, const char *ldflags, const char *libs) { g_return_val_if_fail(filename != NULL, FALSE); if (! jb_test_link(filename, cflags, cppflags, ldflags, libs)) return FALSE; return jb_exec(NULL, NULL, "build/test"); }
void jb_check_host_system (void) { char *output; gboolean status = FALSE; if (jb_variable_get_variable("host-cpu") != NULL) return; /* already checked */ jb_message_checking("the host system type"); if (jb_exec(&output, NULL, "jbsrc/tools/config.sub `jbsrc/tools/config.guess`")) { char **fields; int len; fields = g_strsplit(output, "-", 0); len = g_strv_length(fields); if (len == 3) { jb_variable_set_string("host-cpu", fields[0]); jb_variable_set_string("host-manufacturer", fields[1]); jb_variable_set_string("host-kernel", NULL); jb_variable_set_string("host-os", fields[2]); status = TRUE; } else if (len == 4) { jb_variable_set_string("host-cpu", fields[0]); jb_variable_set_string("host-manufacturer", fields[1]); jb_variable_set_string("host-kernel", fields[2]); jb_variable_set_string("host-os", fields[3]); status = TRUE; } g_strfreev(fields); } if (status) jb_message_result_string(output); else jb_message_result_string("unknown"); g_free(output); if (! status) jb_error("unable to determine host system type"); }
gboolean jb_exec_expand (char **standard_output, char **standard_error, const char *str, ...) { va_list args; char *command; gboolean result; g_return_val_if_fail(str != NULL, FALSE); va_start(args, str); command = jb_variable_expandv(str, args); va_end(args); result = jb_exec(standard_output, standard_error, "%s", command); g_free(command); return result; }