Support name-spaced add-ons, exposed via user configurable extension
repositories.
Directories for add-ons can be added at run-time and are name-spaced to
avoid name-collisions with Python modules or add-ons from other
repositories.
This is exposed as an experimental feature "Extension Repositories".
Details:
- A `bUserExtensionRepo` type which represents a repository which is
listed in the add-ons repository.
- `JunctionModuleHandle` class to manage a package with sub-modules
which can point to arbitrary locations.
- `bpy.app.handlers._extension_repos_update_{pre/post}` internal
callbacks run before/after changes to extension repositories,
callbacks are used to sync the changes to the Python package that
exposes these to add-ons.
- The size of an add-on name has been increased so a user-defined package
prefix can be included without enforcing shorter add-on names.
- Functionality relating to package management has been left out of this
change and will be developed separately.
Further work:
- While a repository can be renamed, enabled add-ons aren't renamed.
Eventually we might want to support this although we could also
disallow renaming repositories with add-ons enabled as the name isn't
all that significant.
- Removing a repository should remove all the add-ons located in this
repository.
- Sub-module names are currently restricted to `[A-Za-z]+[A-Za-z0-9_]*`
we might want to relax this to allow unicode characters (we might
still want to disallow `-` or any characters that would prevent
attribute access in code).
Ref !110869.
Reviewed By: brecht
46 lines
1.0 KiB
C
46 lines
1.0 KiB
C
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
#pragma once
|
|
|
|
/** \file
|
|
* \ingroup bke
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct ListBase;
|
|
struct bAddon;
|
|
|
|
#ifdef __RNA_TYPES_H__
|
|
typedef struct bAddonPrefType {
|
|
/** Type info, match #bAddon::module. */
|
|
char idname[128];
|
|
|
|
/* RNA integration */
|
|
ExtensionRNA rna_ext;
|
|
} bAddonPrefType;
|
|
|
|
#else
|
|
typedef struct bAddonPrefType bAddonPrefType;
|
|
#endif
|
|
|
|
bAddonPrefType *BKE_addon_pref_type_find(const char *idname, bool quiet);
|
|
void BKE_addon_pref_type_add(bAddonPrefType *apt);
|
|
void BKE_addon_pref_type_remove(const bAddonPrefType *apt);
|
|
|
|
void BKE_addon_pref_type_init(void);
|
|
void BKE_addon_pref_type_free(void);
|
|
|
|
struct bAddon *BKE_addon_new(void);
|
|
struct bAddon *BKE_addon_find(struct ListBase *addon_list, const char *module);
|
|
struct bAddon *BKE_addon_ensure(struct ListBase *addon_list, const char *module);
|
|
bool BKE_addon_remove_safe(struct ListBase *addon_list, const char *module);
|
|
void BKE_addon_free(struct bAddon *addon);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|