Skip to content

Commit

Permalink
feat: load python extensions according to app manifest (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn authored Nov 25, 2024
1 parent 4d790c3 commit dff7500
Show file tree
Hide file tree
Showing 55 changed files with 595 additions and 1,619 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@
"name": "app (C/C++) (lldb, launch)",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_app/bin/check_start_graph_source",
"program": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/cpp/standalone_test_cpp/default_extension_cpp/out/linux/x64/tests/default_extension_cpp_test",
"args": [],
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_app",
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/cpp/standalone_test_cpp/default_extension_cpp/out/linux/x64/tests/",
"env": {
"ASAN_OPTIONS": "use_sigaltstack=0",
},
Expand Down
2 changes: 1 addition & 1 deletion core/include/ten_runtime/binding/cpp/internal/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "ten_runtime/app/app.h"
#include "ten_runtime/binding/common.h"
#include "ten_runtime/binding/cpp/internal/common.h"
#include "ten_runtime/binding/cpp/internal/extension_group.h"
#include "ten_runtime/binding/cpp/internal/ten_env.h"
#include "ten_runtime/ten.h"
#include "ten_utils/macro/check.h"

Expand Down
212 changes: 0 additions & 212 deletions core/include/ten_runtime/binding/cpp/internal/extension_group.h

This file was deleted.

5 changes: 0 additions & 5 deletions core/include/ten_runtime/binding/cpp/internal/ten_env_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "ten_runtime/binding/cpp/internal/addon.h"
#include "ten_runtime/binding/cpp/internal/extension.h"
#include "ten_runtime/binding/cpp/internal/extension_group.h"
#include "ten_runtime/binding/cpp/internal/ten_env.h"
#include "ten_utils/lang/cpp/lib/error.h"

Expand All @@ -30,10 +29,6 @@ inline bool ten_env_t::on_create_instance_done(void *instance, void *context,
case ADDON_TASK_CREATE_EXTENSION:
c_instance = static_cast<extension_t *>(instance)->get_c_extension();
break;
case ADDON_TASK_CREATE_EXTENSION_GROUP:
c_instance =
static_cast<extension_group_t *>(instance)->get_c_extension_group();
break;
default:
TEN_ASSERT(0, "Should not happen.");
break;
Expand Down
1 change: 0 additions & 1 deletion core/include/ten_runtime/binding/cpp/ten.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@
#include "ten_runtime/addon/extension_group/extension_group.h" // IWYU pragma: export
#include "ten_runtime/binding/cpp/internal/addon.h" // IWYU pragma: export
#include "ten_runtime/binding/cpp/internal/app.h" // IWYU pragma: export
#include "ten_runtime/binding/cpp/internal/extension_group.h" // IWYU pragma: export
#include "ten_runtime/binding/cpp/internal/extension_impl.h" // IWYU pragma: export
#include "ten_runtime/binding/cpp/internal/ten_env_impl.h" // IWYU pragma: export
2 changes: 0 additions & 2 deletions core/include/ten_utils/lib/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ TEN_UTILS_API int ten_file_size(const char *filename);

TEN_UTILS_API char *ten_file_read(const char *filename);

TEN_UTILS_API char *ten_file_read_from_open_file(FILE *fp);

TEN_UTILS_API char *ten_symlink_file_read(const char *path);

TEN_UTILS_API int ten_file_write(const char *filename, ten_buf_t buf);
Expand Down
5 changes: 4 additions & 1 deletion core/include/ten_utils/lib/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ TEN_UTILS_API void *ten_module_load(const ten_string_t *name, int as_local);
* @param handle The handle of the module to unload.
* @return 0 on success, or -1 on failure.
*/
TEN_UTILS_API int ten_module_close(void *handle);
TEN_UTILS_API int ten_module_close(void *handle);

TEN_UTILS_API void *ten_module_get_symbol(void *handle,
const char *symbol_name);
5 changes: 5 additions & 0 deletions core/include_internal/ten_runtime/addon/addon.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ typedef struct ten_addon_host_t {
ten_env_t *ten_env;

TEN_ADDON_TYPE type;

void *user_data;
} ten_addon_host_t;

typedef struct ten_addon_on_create_instance_info_t {
Expand Down Expand Up @@ -102,6 +104,9 @@ TEN_RUNTIME_PRIVATE_API ten_addon_host_t *ten_addon_host_create(

TEN_RUNTIME_API void ten_addon_host_destroy(ten_addon_host_t *self);

TEN_RUNTIME_PRIVATE_API TEN_ADDON_TYPE
ten_addon_type_from_string(const char *addon_type_str);

TEN_RUNTIME_PRIVATE_API void ten_addon_register(ten_addon_store_t *addon_store,
ten_addon_host_t *addon_host,
const char *name,
Expand Down
2 changes: 2 additions & 0 deletions core/include_internal/ten_runtime/addon/addon_autoload.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

typedef struct ten_app_t ten_app_t;

typedef void (*ten_addon_register_func_t)(void *register_ctx);

TEN_RUNTIME_PRIVATE_API bool ten_addon_load_all_from_app_base_dir(
ten_app_t *app, ten_list_t *extension_dependencies,
ten_list_t *extension_group_dependencies, ten_list_t *protocol_dependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@
#include "ten_runtime/ten_config.h"

typedef struct ten_addon_store_t ten_addon_store_t;
typedef struct ten_addon_t ten_addon_t;

TEN_RUNTIME_PRIVATE_API ten_addon_store_t *ten_extension_get_store(void);
TEN_RUNTIME_PRIVATE_API ten_addon_store_t *ten_extension_get_global_store(void);

TEN_RUNTIME_API void ten_addon_register_extension_v2(const char *name,
const char *base_dir,
void *register_ctx,
ten_addon_t *addon);
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
typedef struct ten_env_t ten_env_t;
typedef struct ten_addon_store_t ten_addon_store_t;

TEN_RUNTIME_PRIVATE_API ten_addon_store_t *ten_extension_group_get_store(void);
TEN_RUNTIME_PRIVATE_API ten_addon_store_t *ten_extension_group_get_global_store(
void);

TEN_RUNTIME_API bool ten_addon_create_extension_group(
ten_env_t *ten_env, const char *addon_name, const char *instance_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TEN_RUNTIME_PRIVATE_API bool ten_addon_create_protocol(
TEN_PROTOCOL_ROLE role, ten_env_addon_on_create_protocol_async_cb_t cb,
void *user_data, ten_error_t *err);

TEN_RUNTIME_PRIVATE_API ten_addon_store_t *ten_protocol_get_store(void);
TEN_RUNTIME_PRIVATE_API ten_addon_store_t *ten_protocol_get_global_store(void);

TEN_RUNTIME_PRIVATE_API ten_addon_host_t *ten_addon_protocol_find(
const char *protocol);
Expand Down
31 changes: 3 additions & 28 deletions core/include_internal/ten_runtime/app/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <stdbool.h>
#include <stddef.h>

#include "include_internal/ten_runtime/common/constant_str.h"
#include "ten_utils/lib/error.h"

typedef struct ten_app_t ten_app_t;
Expand All @@ -29,6 +28,9 @@ typedef struct ten_app_ten_namespace_prop_info_t {

TEN_RUNTIME_PRIVATE_API void ten_app_handle_metadata(ten_app_t *self);

TEN_RUNTIME_API void ten_app_get_extension_dependencies_for_extension(
ten_app_t *self, ten_list_t *extension_dependencies);

TEN_RUNTIME_PRIVATE_API bool ten_app_handle_ten_namespace_properties(
ten_app_t *self);

Expand All @@ -54,30 +56,3 @@ TEN_RUNTIME_PRIVATE_API bool ten_app_init_log_level(ten_app_t *self,

TEN_RUNTIME_PRIVATE_API bool ten_app_init_log_file(ten_app_t *self,
ten_value_t *value);

static const ten_app_ten_namespace_prop_info_t
ten_app_ten_namespace_prop_info_list[] = {
{
.name = TEN_STR_ONE_EVENT_LOOP_PER_ENGINE,
.init_from_value = ten_app_init_one_event_loop_per_engine,
},
{
.name = TEN_STR_LONG_RUNNING_MODE,
.init_from_value = ten_app_init_long_running_mode,
},
{
.name = TEN_STR_URI,
.init_from_value = ten_app_init_uri,
},
{
.name = TEN_STR_LOG_LEVEL,
.init_from_value = ten_app_init_log_level,
},
{
.name = TEN_STR_LOG_FILE,
.init_from_value = ten_app_init_log_file,
}};

static const size_t ten_app_ten_namespace_prop_info_list_size =
sizeof(ten_app_ten_namespace_prop_info_list) /
sizeof(ten_app_ten_namespace_prop_info_list[0]);
Loading

0 comments on commit dff7500

Please sign in to comment.