mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 00:03:58 +01:00
Packages: adds option PACKAGES_REMOVE_DISABLED to remove disabled package managers from the build entirely
This commit is contained in:
@@ -4,41 +4,41 @@
|
||||
|
||||
typedef enum FF_A_PACKED FFPackagesFlags {
|
||||
FF_PACKAGES_FLAG_NONE = 0,
|
||||
FF_PACKAGES_FLAG_APK_BIT = 1ULL << 0,
|
||||
FF_PACKAGES_FLAG_BREW_BIT = 1ULL << 1,
|
||||
FF_PACKAGES_FLAG_CHOCO_BIT = 1ULL << 2,
|
||||
FF_PACKAGES_FLAG_DPKG_BIT = 1ULL << 3,
|
||||
FF_PACKAGES_FLAG_EMERGE_BIT = 1ULL << 4,
|
||||
FF_PACKAGES_FLAG_EOPKG_BIT = 1ULL << 5,
|
||||
FF_PACKAGES_FLAG_FLATPAK_BIT = 1ULL << 6,
|
||||
FF_PACKAGES_FLAG_NIX_BIT = 1ULL << 7,
|
||||
FF_PACKAGES_FLAG_OPKG_BIT = 1ULL << 8,
|
||||
FF_PACKAGES_FLAG_PACMAN_BIT = 1ULL << 9,
|
||||
FF_PACKAGES_FLAG_PALUDIS_BIT = 1ULL << 10,
|
||||
FF_PACKAGES_FLAG_PKG_BIT = 1ULL << 11,
|
||||
FF_PACKAGES_FLAG_PKGTOOL_BIT = 1ULL << 12,
|
||||
FF_PACKAGES_FLAG_MACPORTS_BIT = 1ULL << 13,
|
||||
FF_PACKAGES_FLAG_RPM_BIT = 1ULL << 14,
|
||||
FF_PACKAGES_FLAG_SCOOP_BIT = 1ULL << 15,
|
||||
FF_PACKAGES_FLAG_SNAP_BIT = 1ULL << 16,
|
||||
FF_PACKAGES_FLAG_WINGET_BIT = 1ULL << 17,
|
||||
FF_PACKAGES_FLAG_XBPS_BIT = 1ULL << 18,
|
||||
FF_PACKAGES_FLAG_AM_BIT = 1ULL << 19,
|
||||
FF_PACKAGES_FLAG_SORCERY_BIT = 1ULL << 20,
|
||||
FF_PACKAGES_FLAG_LPKG_BIT = 1ULL << 21,
|
||||
FF_PACKAGES_FLAG_LPKGBUILD_BIT = 1ULL << 22,
|
||||
FF_PACKAGES_FLAG_GUIX_BIT = 1ULL << 23,
|
||||
FF_PACKAGES_FLAG_LINGLONG_BIT = 1ULL << 24,
|
||||
FF_PACKAGES_FLAG_PACSTALL_BIT = 1ULL << 25,
|
||||
FF_PACKAGES_FLAG_MPORT_BIT = 1ULL << 26,
|
||||
FF_PACKAGES_FLAG_PKGSRC_BIT = 1ULL << 27,
|
||||
FF_PACKAGES_FLAG_HPKG_BIT = 1ULL << 28,
|
||||
FF_PACKAGES_FLAG_PISI_BIT = 1ULL << 29,
|
||||
FF_PACKAGES_FLAG_SOAR_BIT = 1ULL << 30,
|
||||
FF_PACKAGES_FLAG_KISS_BIT = 1ULL << 31,
|
||||
FF_PACKAGES_FLAG_MOSS_BIT = 1ULL << 32,
|
||||
FF_PACKAGES_FLAG_APPIMAGE_BIT = 1ULL << 33,
|
||||
FF_PACKAGES_FLAG_CARDS_BIT = 1ULL << 34,
|
||||
FF_PACKAGES_FLAG_APK_BIT = UINT64_C(1) << 0U,
|
||||
FF_PACKAGES_FLAG_BREW_BIT = UINT64_C(1) << 1U,
|
||||
FF_PACKAGES_FLAG_CHOCO_BIT = UINT64_C(1) << 2U,
|
||||
FF_PACKAGES_FLAG_DPKG_BIT = UINT64_C(1) << 3U,
|
||||
FF_PACKAGES_FLAG_EMERGE_BIT = UINT64_C(1) << 4U,
|
||||
FF_PACKAGES_FLAG_EOPKG_BIT = UINT64_C(1) << 5U,
|
||||
FF_PACKAGES_FLAG_FLATPAK_BIT = UINT64_C(1) << 6U,
|
||||
FF_PACKAGES_FLAG_NIX_BIT = UINT64_C(1) << 7U,
|
||||
FF_PACKAGES_FLAG_OPKG_BIT = UINT64_C(1) << 8U,
|
||||
FF_PACKAGES_FLAG_PACMAN_BIT = UINT64_C(1) << 9U,
|
||||
FF_PACKAGES_FLAG_PALUDIS_BIT = UINT64_C(1) << 10U,
|
||||
FF_PACKAGES_FLAG_PKG_BIT = UINT64_C(1) << 11U,
|
||||
FF_PACKAGES_FLAG_PKGTOOL_BIT = UINT64_C(1) << 12U,
|
||||
FF_PACKAGES_FLAG_MACPORTS_BIT = UINT64_C(1) << 13U,
|
||||
FF_PACKAGES_FLAG_RPM_BIT = UINT64_C(1) << 14U,
|
||||
FF_PACKAGES_FLAG_SCOOP_BIT = UINT64_C(1) << 15U,
|
||||
FF_PACKAGES_FLAG_SNAP_BIT = UINT64_C(1) << 16U,
|
||||
FF_PACKAGES_FLAG_WINGET_BIT = UINT64_C(1) << 17U,
|
||||
FF_PACKAGES_FLAG_XBPS_BIT = UINT64_C(1) << 18U,
|
||||
FF_PACKAGES_FLAG_AM_BIT = UINT64_C(1) << 19U,
|
||||
FF_PACKAGES_FLAG_SORCERY_BIT = UINT64_C(1) << 20U,
|
||||
FF_PACKAGES_FLAG_LPKG_BIT = UINT64_C(1) << 21U,
|
||||
FF_PACKAGES_FLAG_LPKGBUILD_BIT = UINT64_C(1) << 22U,
|
||||
FF_PACKAGES_FLAG_GUIX_BIT = UINT64_C(1) << 23U,
|
||||
FF_PACKAGES_FLAG_LINGLONG_BIT = UINT64_C(1) << 24U,
|
||||
FF_PACKAGES_FLAG_PACSTALL_BIT = UINT64_C(1) << 25U,
|
||||
FF_PACKAGES_FLAG_MPORT_BIT = UINT64_C(1) << 26U,
|
||||
FF_PACKAGES_FLAG_PKGSRC_BIT = UINT64_C(1) << 27U,
|
||||
FF_PACKAGES_FLAG_HPKG_BIT = UINT64_C(1) << 28U,
|
||||
FF_PACKAGES_FLAG_PISI_BIT = UINT64_C(1) << 29U,
|
||||
FF_PACKAGES_FLAG_SOAR_BIT = UINT64_C(1) << 30U,
|
||||
FF_PACKAGES_FLAG_KISS_BIT = UINT64_C(1) << 31U,
|
||||
FF_PACKAGES_FLAG_MOSS_BIT = UINT64_C(1) << 32U,
|
||||
FF_PACKAGES_FLAG_APPIMAGE_BIT = UINT64_C(1) << 33U,
|
||||
FF_PACKAGES_FLAG_CARDS_BIT = UINT64_C(1) << 34U,
|
||||
FF_PACKAGES_FLAG_FORCE_UNSIGNED = UINT64_MAX,
|
||||
} FFPackagesFlags;
|
||||
static_assert(sizeof(FFPackagesFlags) == sizeof(uint64_t), "");
|
||||
@@ -46,7 +46,9 @@ static_assert(sizeof(FFPackagesFlags) == sizeof(uint64_t), "");
|
||||
typedef struct FFPackagesOptions {
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
#if !FF_PACKAGES_REMOVE_DISABLED
|
||||
FFPackagesFlags disabled;
|
||||
#endif
|
||||
bool combined;
|
||||
} FFPackagesOptions;
|
||||
|
||||
|
||||
@@ -211,6 +211,7 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#if !FF_PACKAGES_REMOVE_DISABLED
|
||||
if (unsafe_yyjson_equals_str(key, "disabled")) {
|
||||
if (!yyjson_is_null(val) && !yyjson_is_arr(val)) {
|
||||
ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid JSON value for %s", unsafe_yyjson_get_str(key));
|
||||
@@ -229,10 +230,10 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module) {
|
||||
}
|
||||
const char* flag = unsafe_yyjson_get_str(flagObj);
|
||||
|
||||
#define FF_TEST_PACKAGE_NAME(name) \
|
||||
else if (ffStrEqualsIgnCase(flag, #name)) { \
|
||||
options->disabled |= FF_PACKAGES_FLAG_##name##_BIT; \
|
||||
}
|
||||
#define FF_TEST_PACKAGE_NAME(name) \
|
||||
else if (ffStrEqualsIgnCase(flag, #name)) { \
|
||||
options->disabled |= FF_PACKAGES_FLAG_##name##_BIT; \
|
||||
}
|
||||
switch (toupper(flag[0])) {
|
||||
case 'A':
|
||||
if (false)
|
||||
@@ -342,11 +343,12 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module) {
|
||||
FF_TEST_PACKAGE_NAME(XBPS)
|
||||
break;
|
||||
}
|
||||
#undef FF_TEST_PACKAGE_NAME
|
||||
#undef FF_TEST_PACKAGE_NAME
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (unsafe_yyjson_equals_str(key, "combined")) {
|
||||
options->combined = yyjson_get_bool(val);
|
||||
@@ -360,14 +362,15 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module) {
|
||||
void ffGeneratePackagesJsonConfig(FFPackagesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
|
||||
#if !FF_PACKAGES_REMOVE_DISABLED
|
||||
FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate();
|
||||
yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "disabled");
|
||||
#define FF_TEST_PACKAGE_NAME(name) \
|
||||
else if ((options->disabled & FF_PACKAGES_FLAG_##name##_BIT)) { \
|
||||
ffStrbufSetS(&buf, #name); \
|
||||
ffStrbufLowerCase(&buf); \
|
||||
yyjson_mut_arr_add_strbuf(doc, arr, &buf); \
|
||||
}
|
||||
#define FF_TEST_PACKAGE_NAME(name) \
|
||||
else if ((options->disabled & FF_PACKAGES_FLAG_##name##_BIT)) { \
|
||||
ffStrbufSetS(&buf, #name); \
|
||||
ffStrbufLowerCase(&buf); \
|
||||
yyjson_mut_arr_add_strbuf(doc, arr, &buf); \
|
||||
}
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(AM)
|
||||
@@ -405,12 +408,13 @@ void ffGeneratePackagesJsonConfig(FFPackagesOptions* options, yyjson_mut_doc* do
|
||||
FF_TEST_PACKAGE_NAME(SORCERY)
|
||||
FF_TEST_PACKAGE_NAME(WINGET)
|
||||
FF_TEST_PACKAGE_NAME(XBPS)
|
||||
#undef FF_TEST_PACKAGE_NAME
|
||||
#undef FF_TEST_PACKAGE_NAME
|
||||
#endif
|
||||
|
||||
yyjson_mut_obj_add_bool(doc, module, "combined", options->combined);
|
||||
}
|
||||
|
||||
bool ffGeneratePackagesJsonResult(FF_A_UNUSED FFPackagesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
bool ffGeneratePackagesJsonResult(FFPackagesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
FFPackagesResult counts = {};
|
||||
ffStrbufInit(&counts.pacmanBranch);
|
||||
|
||||
@@ -481,7 +485,9 @@ bool ffGeneratePackagesJsonResult(FF_A_UNUSED FFPackagesOptions* options, yyjson
|
||||
void ffInitPackagesOptions(FFPackagesOptions* options) {
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
#if !FF_PACKAGES_REMOVE_DISABLED
|
||||
options->disabled = FF_PACKAGES_DISABLE_LIST;
|
||||
#endif
|
||||
options->combined = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user