aboutsummaryrefslogtreecommitdiff
path: root/src/recipes.c
diff options
context:
space:
mode:
authordacctal <donotcontactmevia@email.invalid>2026-10-22 15:00:26 +0000
committerdacctal <donotcontactmevia@email.invalid>2026-10-22 15:00:26 +0000
commit5bea8b95e3857b250e98327140a580ef68a59d9c (patch)
tree710026fb87bfd94d87cb16fa650b06e85ac401d6 /src/recipes.c
parent865342c3fabb50672e2188ccd4d7c3eb7bfb045a (diff)
added some bldit stuff, it's still broken though
Diffstat (limited to 'src/recipes.c')
-rw-r--r--src/recipes.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/src/recipes.c b/src/recipes.c
index 246224e..a4a08e8 100644
--- a/src/recipes.c
+++ b/src/recipes.c
@@ -44,6 +44,21 @@
log_info("'%.*s' %s done", str_fmt(&(pkg)->name), operation); \
} while (0)
+#define try_bldit_fn(fn, pkg, operation, smol) \
+ do { \
+ if (pkg_read_status(smol, pkg)) return true; \
+ if (!flags.quiet) log_info("'%.*s' %s in progress...", \
+ str_fmt(&(pkg)->name), operation); \
+ if (!(fn((pkg),(operation)))) { \
+ log_error("%s failed", operation); \
+ return false; \
+ } \
+ char big[2] = "\0"; \
+ big[0] = smol; \
+ if (!pkg_write_status(big, pkg)) return false; \
+ log_info("'%.*s' %s done", str_fmt(&(pkg)->name), operation); \
+ } while (0)
+
static bool pkg_write_status(const char *status, package_t *pkg) {
bool success = false;
str status_str = mstr(status);
@@ -105,7 +120,13 @@ static bool pkg_enter(package_t *pkg) {
bool pkg_setup(package_t *pkg) {
if (pkg_read_status('s', pkg)) return true;
if (!pkg_enter(pkg)) return false;
- try_pkg_fn(pkg_hook_setup, pkg, "setup", 's');
+ if (bldit_file_exists(pkg)) {
+ log_info("using bldit.lua");
+ try_bldit_fn(bldit_hook_recipe, pkg, "setup", 's');
+ } else {
+ log_info("using your config");
+ try_pkg_fn(pkg_hook_setup, pkg, "setup", 's');
+ }
log_success("'%.*s' set up", str_fmt(&pkg->name));
return true;
}
@@ -113,22 +134,35 @@ bool pkg_setup(package_t *pkg) {
bool pkg_build(package_t *pkg) {
if (pkg_read_status('b', pkg)) return true;
if (!pkg_enter(pkg)) return false;
- try_pkg_fn(pkg_hook_build, pkg, "build", 'b');
+ if (bldit_file_exists(pkg)) {
+ log_info("using bldit.lua");
+ try_bldit_fn(bldit_hook_recipe, pkg, "build", 'b');
+ } else {
+ log_info("using your config");
+ try_pkg_fn(pkg_hook_build, pkg, "build", 'b');
+ }
log_success("'%.*s' built", str_fmt(&pkg->name));
return true;
}
bool pkg_install(package_t *pkg) {
if (is_pkg_installed(pkg) && !flags.force) return true;
- try_pkg_fn(pkg_fetch_sources, pkg, "fetch", 'f');
if (!pkg_enter(pkg)) return false;
- try_pkg_fn(pkg_hook_setup, pkg, "setup", 's');
- try_pkg_fn(pkg_hook_build, pkg, "build", 'b');
try_pkg_fn(pkg_hook_install, pkg, "install", 'i');
log_success("'%.*s' installed", str_fmt(&pkg->name));
return true;
}
+bool pkg_full_install(package_t *pkg) {
+ if (is_pkg_installed(pkg) && !flags.force) return true;
+ try_pkg_fn(pkg_fetch_sources, pkg, "fetch", 'f');
+ if (!pkg_enter(pkg)) return false;
+ pkg_setup(pkg);
+ pkg_build(pkg);
+ pkg_install(pkg);
+ return true;
+}
+
bool pkg_remove(package_t *pkg) {
if (!pkg_enter(pkg)) return false;
if (!pkg_hook_remove(pkg)) return false;