Skip to content

Commit

Permalink
bsys: Start working on building dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Dec 19, 2024
1 parent 6cc1978 commit e0aabc5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
36 changes: 32 additions & 4 deletions src/bsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,45 @@ int bsys_dep_tree(bsys_t const* bsys, int argc, char* argv[]) {
return 0;
}

static int bsys_deps(bsys_t const* bsys) {
if (bsys->dep_tree == NULL || bsys->build_deps == NULL) {
return 0;
}

// Create dependency tree.

bool circular;
dep_node_t* const tree = bsys->dep_tree(0, NULL, &circular);

if (tree == NULL) {
if (circular) {
LOG_FATAL("Dependency tree is circular.");
}

return -1;
}

assert(!circular);

// Build each dependency.

int const rv = bsys->build_deps(tree);
deps_tree_free(tree);

return rv;
}

int bsys_build(bsys_t const* bsys, char const* preinstall_prefix) {
if (bsys->build == NULL) {
LOG_WARN("%s build system does not have a build step; nothing to build!", bsys->name);
return 0;
}

// TODO Install dependencies.
// Install dependencies.

// if (bsys_deps(bsys) < 0) {
// return -1;
// }
if (bsys_deps(bsys) < 0) {
return -1;
}

// Ensure the output path exists.
// TODO Do this with mkdir_recursive? Do this in main.c?
Expand Down
1 change: 1 addition & 0 deletions src/bsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct bsys_t {
bool (*identify)(void);
int (*setup)(void);
dep_node_t* (*dep_tree)(size_t path_len, uint64_t* path_hashes, bool* circular);
int (*build_deps)(dep_node_t* tree);
int (*build)(char const* preinstall_prefix);
int (*install)(char const* prefix);
int (*run)(int argc, char* argv[]);
Expand Down

0 comments on commit e0aabc5

Please sign in to comment.