diff --git a/build/ten_runtime/options.gni b/build/ten_runtime/options.gni index 67c40b951..16c11377d 100644 --- a/build/ten_runtime/options.gni +++ b/build/ten_runtime/options.gni @@ -51,6 +51,9 @@ declare_args() { # The go lint only depends on GO SDK which is platform independent, so only # one CI node is enough to run the lint. ten_enable_go_lint = ten_enable_go_binding && is_linux && is_clang && is_debug + + # Whether to call apis in the ten_rust library from ten_runtime. + ten_enable_ten_rust_apis = true } declare_args() { @@ -66,6 +69,10 @@ if (ten_enable_memory_check) { ten_runtime_common_defines += [ "TEN_ENABLE_MEMORY_CHECK" ] } +if (ten_enable_ten_rust && ten_enable_ten_rust_apis) { + ten_runtime_common_defines += [ "TEN_ENABLE_TEN_RUST_APIS" ] +} + common_deps = [] common_public_deps = [] diff --git a/core/src/ten_runtime/app/BUILD.gn b/core/src/ten_runtime/app/BUILD.gn index 5ec087667..9d5d21665 100644 --- a/core/src/ten_runtime/app/BUILD.gn +++ b/core/src/ten_runtime/app/BUILD.gn @@ -5,6 +5,7 @@ # Refer to the "LICENSE" file in the root directory for more information. # import("//build/ten_runtime/glob.gni") +import("//build/ten_runtime/options.gni") glob("app") { file_list = all_native_files @@ -13,5 +14,7 @@ glob("app") { "ten_env", ] - public_deps = [ "//core/src/ten_rust:ten_rust_binding" ] + if (ten_enable_ten_rust && ten_enable_ten_rust_apis) { + public_deps = [ "//core/src/ten_rust:ten_rust_binding" ] + } } diff --git a/core/src/ten_runtime/app/graph.c b/core/src/ten_runtime/app/graph.c index 1ac8521c6..635436bf9 100644 --- a/core/src/ten_runtime/app/graph.c +++ b/core/src/ten_runtime/app/graph.c @@ -8,17 +8,22 @@ #include "include_internal/ten_runtime/app/app.h" #include "include_internal/ten_runtime/app/base_dir.h" +#include "ten_runtime/app/app.h" +#include "ten_utils/macro/mark.h" + +#if defined(TEN_ENABLE_TEN_RUST_APIS) #include "include_internal/ten_runtime/common/constant_str.h" #include "include_internal/ten_rust/ten_rust.h" -#include "ten_runtime/app/app.h" #include "ten_utils/macro/memory.h" +#endif bool ten_app_check_start_graph_cmd_json(ten_app_t *self, ten_json_t *start_graph_cmd_json, - ten_error_t *err) { + TEN_UNUSED ten_error_t *err) { TEN_ASSERT(self && ten_app_check_integrity(self, true), "Should not happen."); TEN_ASSERT(start_graph_cmd_json, "Invalid argument."); +#if defined(TEN_ENABLE_TEN_RUST_APIS) const char *base_dir = ten_app_get_base_dir(self); // The pkg_info of extensions in the graph is read from the ten_packages @@ -49,4 +54,7 @@ bool ten_app_check_start_graph_cmd_json(ten_app_t *self, } return rc; +#else + return true; +#endif } diff --git a/core/src/ten_runtime/metadata/BUILD.gn b/core/src/ten_runtime/metadata/BUILD.gn index 248e18c3a..8e27c0266 100644 --- a/core/src/ten_runtime/metadata/BUILD.gn +++ b/core/src/ten_runtime/metadata/BUILD.gn @@ -5,9 +5,13 @@ # Refer to the "LICENSE" file in the root directory for more information. # import("//build/ten_runtime/glob.gni") +import("//build/ten_runtime/options.gni") glob("metadata") { file_list = all_native_files deps = [ "default" ] - public_deps = [ "//core/src/ten_rust:ten_rust_binding" ] + + if (ten_enable_ten_rust && ten_enable_ten_rust_apis) { + public_deps = [ "//core/src/ten_rust:ten_rust_binding" ] + } } diff --git a/core/src/ten_runtime/metadata/metadata.c b/core/src/ten_runtime/metadata/metadata.c index 3bc13c1e5..6fd2f4a3d 100644 --- a/core/src/ten_runtime/metadata/metadata.c +++ b/core/src/ten_runtime/metadata/metadata.c @@ -9,7 +9,6 @@ #include "include_internal/ten_runtime/common/constant_str.h" #include "include_internal/ten_runtime/metadata/metadata_info.h" #include "include_internal/ten_runtime/schema_store/store.h" -#include "include_internal/ten_rust/ten_rust.h" #include "ten_runtime/ten_env/ten_env.h" #include "ten_utils/lib/alloc.h" #include "ten_utils/lib/error.h" @@ -19,6 +18,10 @@ #include "ten_utils/value/value_is.h" #include "ten_utils/value/value_object.h" +#if defined(TEN_ENABLE_TEN_RUST_APIS) +#include "include_internal/ten_rust/ten_rust.h" +#endif + static bool ten_metadata_load_from_json_string(ten_value_t *metadata, const char *json_str, ten_error_t *err) { @@ -150,6 +153,7 @@ bool ten_manifest_json_string_is_valid(const char *json_string, TEN_ASSERT(json_string, "Invalid argument."); TEN_ASSERT(err && ten_error_check_integrity(err), "Invalid argument."); +#if defined(TEN_ENABLE_TEN_RUST_APIS) const char *err_msg = NULL; bool rc = ten_validate_manifest_json_string(json_string, &err_msg); @@ -158,6 +162,7 @@ bool ten_manifest_json_string_is_valid(const char *json_string, ten_rust_free_cstring(err_msg); return false; } +#endif return true; } @@ -166,6 +171,7 @@ bool ten_manifest_json_file_is_valid(const char *json_file, ten_error_t *err) { TEN_ASSERT(json_file, "Invalid argument."); TEN_ASSERT(err && ten_error_check_integrity(err), "Invalid argument."); +#if defined(TEN_ENABLE_TEN_RUST_APIS) const char *err_msg = NULL; bool rc = ten_validate_manifest_json_file(json_file, &err_msg); @@ -174,6 +180,7 @@ bool ten_manifest_json_file_is_valid(const char *json_file, ten_error_t *err) { ten_rust_free_cstring(err_msg); return false; } +#endif return true; } @@ -183,6 +190,7 @@ bool ten_property_json_string_is_valid(const char *json_string, TEN_ASSERT(json_string, "Invalid argument."); TEN_ASSERT(err && ten_error_check_integrity(err), "Invalid argument."); +#if defined(TEN_ENABLE_TEN_RUST_APIS) const char *err_msg = NULL; bool rc = ten_validate_property_json_string(json_string, &err_msg); @@ -191,6 +199,7 @@ bool ten_property_json_string_is_valid(const char *json_string, ten_rust_free_cstring(err_msg); return false; } +#endif return true; } @@ -199,6 +208,7 @@ bool ten_property_json_file_is_valid(const char *json_file, ten_error_t *err) { TEN_ASSERT(json_file, "Invalid argument."); TEN_ASSERT(err && ten_error_check_integrity(err), "Invalid argument."); +#if defined(TEN_ENABLE_TEN_RUST_APIS) const char *err_msg = NULL; bool rc = ten_validate_property_json_file(json_file, &err_msg); @@ -207,6 +217,7 @@ bool ten_property_json_file_is_valid(const char *json_file, ten_error_t *err) { ten_rust_free_cstring(err_msg); return false; } +#endif return true; } diff --git a/core/src/ten_runtime/schema_store/BUILD.gn b/core/src/ten_runtime/schema_store/BUILD.gn index bd804965f..e4ed545e1 100644 --- a/core/src/ten_runtime/schema_store/BUILD.gn +++ b/core/src/ten_runtime/schema_store/BUILD.gn @@ -5,8 +5,12 @@ # Refer to the "LICENSE" file in the root directory for more information. # import("//build/ten_runtime/glob.gni") +import("//build/ten_runtime/options.gni") glob("schema_store") { file_list = all_native_files - deps = [ "//core/src/ten_rust:ten_rust_binding" ] + + if (ten_enable_ten_rust && ten_enable_ten_rust_apis) { + deps = [ "//core/src/ten_rust:ten_rust_binding" ] + } } diff --git a/core/src/ten_runtime/schema_store/interface_info.c b/core/src/ten_runtime/schema_store/interface_info.c index ff88b5bf0..17f47bd3e 100644 --- a/core/src/ten_runtime/schema_store/interface_info.c +++ b/core/src/ten_runtime/schema_store/interface_info.c @@ -5,19 +5,23 @@ // Refer to the "LICENSE" file in the root directory for more information. // #include "include_internal/ten_runtime/schema_store/interface.h" -#include "include_internal/ten_rust/ten_rust.h" #include "ten_runtime/common/errno.h" #include "ten_utils/lib/error.h" -#include "ten_utils/lib/json.h" #include "ten_utils/macro/check.h" -#include "ten_utils/macro/memory.h" +#include "ten_utils/macro/mark.h" #include "ten_utils/value/value.h" #include "ten_utils/value/value_is.h" #include "ten_utils/value/value_json.h" +#if defined(TEN_ENABLE_TEN_RUST_APIS) +#include "include_internal/ten_rust/ten_rust.h" +#include "ten_utils/lib/json.h" +#include "ten_utils/macro/memory.h" +#endif + ten_value_t *ten_interface_schema_info_resolve( - ten_value_t *unresolved_interface_schema_def, const char *base_dir, - ten_error_t *err) { + ten_value_t *unresolved_interface_schema_def, + TEN_UNUSED const char *base_dir, ten_error_t *err) { TEN_ASSERT(unresolved_interface_schema_def && ten_value_check_integrity(unresolved_interface_schema_def), "Invalid argument."); @@ -29,6 +33,7 @@ ten_value_t *ten_interface_schema_info_resolve( return NULL; } +#if defined(TEN_ENABLE_TEN_RUST_APIS) ten_json_t *unresolved_interface_schema_json = ten_value_to_json(unresolved_interface_schema_def); @@ -76,4 +81,7 @@ ten_value_t *ten_interface_schema_info_resolve( } return resolved_interface_schema_def; +#else + return NULL; +#endif } diff --git a/core/src/ten_runtime/schema_store/store.c b/core/src/ten_runtime/schema_store/store.c index 600fdc7ba..860e29fdb 100644 --- a/core/src/ten_runtime/schema_store/store.c +++ b/core/src/ten_runtime/schema_store/store.c @@ -27,6 +27,7 @@ #include "ten_utils/lib/string.h" #include "ten_utils/macro/check.h" #include "ten_utils/macro/field.h" +#include "ten_utils/macro/mark.h" #include "ten_utils/value/value.h" #include "ten_utils/value/value_is.h" #include "ten_utils/value/value_kv.h" @@ -234,6 +235,7 @@ bool ten_schema_store_set_schema_definition(ten_schema_store_t *self, return true; } +#if defined(TEN_ENABLE_TEN_RUST_APIS) static void ten_schemas_parse_interface_part( ten_hashtable_t *interface_schema_map, ten_value_t *interface_schema_value, const char *base_dir) { @@ -329,22 +331,23 @@ static bool ten_schema_store_merge_interface_schemas_into_msg_schemas( return true; } +#endif /** * @param base_dir The base directory of the addon. If the interface definition * is a file reference, it is used to resolve the file reference based on the * base_dir. */ -bool ten_schema_store_set_interface_schema_definition(ten_schema_store_t *self, - ten_value_t *schema_def, - const char *base_dir, - ten_error_t *err) { +bool ten_schema_store_set_interface_schema_definition( + ten_schema_store_t *self, ten_value_t *schema_def, + TEN_UNUSED const char *base_dir, ten_error_t *err) { TEN_ASSERT(self && ten_schema_store_check_integrity(self), "Invalid argument."); TEN_ASSERT(schema_def && ten_value_check_integrity(schema_def), "Invalid argument."); TEN_ASSERT(err && ten_error_check_integrity(err), "Invalid argument."); +#if defined(TEN_ENABLE_TEN_RUST_APIS) if (!ten_value_is_object(schema_def)) { ten_error_set(err, TEN_ERRNO_GENERIC, "The interface schema should be an object."); @@ -374,6 +377,7 @@ bool ten_schema_store_set_interface_schema_definition(ten_schema_store_t *self, return false; } } +#endif return true; } diff --git a/tests/ten_runtime/integration/cpp/BUILD.gn b/tests/ten_runtime/integration/cpp/BUILD.gn index 469176238..a20b06b88 100644 --- a/tests/ten_runtime/integration/cpp/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/BUILD.gn @@ -14,7 +14,6 @@ group("cpp") { "hello_world", "http_basic", "large_result", - "multi_apps", "standalone_test_cpp", ] @@ -24,4 +23,10 @@ group("cpp") { "ffmpeg_bypass", ] } + + if (ten_enable_ten_rust && ten_enable_ten_rust_apis) { + # This case will start an invalid graph, and it will be failed without + # graph checking. + deps += [ "multi_apps" ] + } } diff --git a/tests/ten_runtime/smoke/BUILD.gn b/tests/ten_runtime/smoke/BUILD.gn index 78797dbeb..d8e0d1c73 100644 --- a/tests/ten_runtime/smoke/BUILD.gn +++ b/tests/ten_runtime/smoke/BUILD.gn @@ -38,15 +38,20 @@ ten_executable("ten_runtime_smoke_test") { "data_test", "extension_test", "graph_test", - "interface_test", "msg_test", "notify_test", "result_conversion", - "schema_test", "standalone_test", "video_frame_test", ] + if (ten_enable_ten_rust && ten_enable_ten_rust_apis) { + deps += [ + "interface_test", + "schema_test", + ] + } + if (ten_enable_curl) { deps += [ "//third_party/curl" ] }