示例#1
0
int
fatso_guess_toolchain(struct fatso* f, struct fatso_package* p, struct fatso_toolchain* out_toolchain) {

  if( p->toolchain != NULL ){
    fatso_logf(f, FATSO_LOG_INFO, "Using explicitly provided toolchain '%s'.", p->toolchain );

    // TODO: optionally set this to p->toolchain
    out_toolchain->name = "[config provided]";
    out_toolchain->build = &build_provided_toolchain;
    out_toolchain->install = &install_provided_toolchain;
    return 0; // we found the toolchain
  }

  char* path = fatso_package_build_path(f, p);
  bool found = false;
  for (const struct init_named_toolchain* i = named_toolchains; i->name; ++i) {
    if (i->guess(path)) {
      found = true;
      i->init(out_toolchain);
    }
  }
  fatso_free(path);
  if (!found) {
    fatso_logf(f, FATSO_LOG_FATAL, "Fatso couldn't guess the toolchain of package '%s', and none was explicitly defined!", p->name);
    return 1;
  }
  return 0;
}
示例#2
0
文件: project.c 项目: ylecuyer/fatso
int
fatso_load_project(struct fatso* f) {
  int r = 0;
  char* fatso_yml = NULL;
  char* error_message = NULL;

  if (f->project != NULL) {
    // Project is already loaded.
    goto out;
  }

  f->project = fatso_alloc(sizeof(struct fatso_project));
  fatso_project_init(f->project);
  f->project->path = strdup(fatso_project_directory(f));

  asprintf(&fatso_yml, "%s/fatso.yml", f->project->path);
  r = parse_fatso_yml(f->project, fatso_yml, &error_message);
  if (r != 0) {
    fatso_logf(f, FATSO_LOG_FATAL, "Cannot load project: %s", error_message);
    goto error;
  }

out:
  fatso_free(error_message);
  fatso_free(fatso_yml);
  return r;
error:
  r = 1;
  fatso_unload_project(f);
  goto out;
}
示例#3
0
int
fatso_guess_toolchain(struct fatso* f, struct fatso_package* p, struct fatso_toolchain* out_toolchain) {
  // TODO: Use 'toolchain' option in package.

  char* path = fatso_package_build_path(f, p);
  bool found = false;
  for (const struct init_named_toolchain* i = named_toolchains; i->name; ++i) {
    if (i->guess(path)) {
      found = true;
      i->init(out_toolchain);
    }
  }
  fatso_free(path);
  if (!found) {
    fatso_logf(f, FATSO_LOG_FATAL, "Fatso couldn't guess the toolchain of package '%s', and none was explicitly defined!", p->name);
    return 1;
  }
  return 0;
}
示例#4
0
static int install_provided_toolchain( struct fatso* f, struct fatso_package* p, fatso_report_progress_callback_t progress, const struct fatso_process_callbacks* stdio_callbacks){

  if( p->toolchain == NULL ){
    // error
    return -1;
  }

  int r = 0;

  progress(f, p, p->toolchain, 0, 1);
  r = fatso_system_with_callbacks( p->toolchain, stdio_callbacks );
  if( r != 0 ){
    fatso_logf(f, FATSO_LOG_FATAL, "Error during %s.", p->toolchain);
    goto out;
  }
  progress(f, p, p->toolchain, 1, 1);

out:

  return r;
}
示例#5
0
文件: project.c 项目: ylecuyer/fatso
int
fatso_load_dependency_graph(struct fatso* f) {
  fatso_logf(f, FATSO_LOG_FATAL, "%s: NIY", __func__);
  return -1;
}