From 1465fef9df8f018c4c55a754a32bedb5358a6740 Mon Sep 17 00:00:00 2001 From: cat Date: Thu, 28 Aug 2025 10:37:39 +0800 Subject: [PATCH] repair caniuse code Signed-off-by: cat --- interfaces/taihe/syscap/BUILD.gn | 22 +++++++++---------- ...lobal.taihe => internal.full.global.taihe} | 10 +++++---- .../taihe/syscap/src/ani_constructor.cpp | 17 +++++++++----- ...impl.cpp => internal.full.global.impl.cpp} | 9 +++----- 4 files changed, 32 insertions(+), 26 deletions(-) rename interfaces/taihe/syscap/idl/{global.taihe => internal.full.global.taihe} (81%) rename interfaces/taihe/syscap/src/{global.impl.cpp => internal.full.global.impl.cpp} (84%) diff --git a/interfaces/taihe/syscap/BUILD.gn b/interfaces/taihe/syscap/BUILD.gn index 543e1bba6..31bde69d3 100644 --- a/interfaces/taihe/syscap/BUILD.gn +++ b/interfaces/taihe/syscap/BUILD.gn @@ -16,18 +16,18 @@ import("//build/ohos.gni") import("//build/ohos/taihe_idl/taihe.gni") copy_taihe_idl("copy_global") { - sources = [ "idl/global.taihe" ] + sources = [ "idl/internal.full.global.taihe" ] } subsystem_name = "startup" part_name = "init" -taihe_generated_file_path = "$taihe_file_path/out/$subsystem_name/$part_name" +taihe_generated_file_path_global = "$taihe_file_path/out/$subsystem_name/$part_name/global" ohos_taihe("run_taihe") { - taihe_generated_file_path = "$taihe_generated_file_path" + taihe_generated_file_path = "$taihe_generated_file_path_global" deps = [ ":copy_global" ] outputs = [ - "$taihe_generated_file_path/src/global.ani.cpp", - "$taihe_generated_file_path/src/global.abi.c", + "$taihe_generated_file_path/src/internal.full.global.ani.cpp", + "$taihe_generated_file_path/src/internal.full.global.abi.c", ] } @@ -37,14 +37,14 @@ taihe_shared_library("global_taihe_native") { cfi_cross_dso = true debug = false } - taihe_generated_file_path = "$taihe_generated_file_path" + taihe_generated_file_path = "$taihe_generated_file_path_global" part_name = "$part_name" subsystem_name = "$subsystem_name" sources = get_target_outputs(":run_taihe") - include_dirs = [ "//base/startup/init/interfaces/innerkits/include" ] + include_dirs = [ "${init_innerkits_path}/include" ] sources += [ "src/ani_constructor.cpp", - "src/global.impl.cpp", + "src/internal.full.global.impl.cpp", ] deps = [ ":run_taihe", @@ -53,8 +53,8 @@ taihe_shared_library("global_taihe_native") { } generate_static_abc("global") { - base_url = "$taihe_generated_file_path" - files = [ "$taihe_generated_file_path/global.ets" ] + base_url = "$taihe_generated_file_path_global" + files = [ "$taihe_generated_file_path_global/@internal.full.global.ets" ] is_boot_abc = "True" device_dst_file = "/system/framework/global.abc" dependencies = [ ":run_taihe" ] @@ -66,4 +66,4 @@ ohos_prebuilt_etc("global_etc") { part_name = "$part_name" subsystem_name = "$subsystem_name" deps = [ ":global" ] -} +} \ No newline at end of file diff --git a/interfaces/taihe/syscap/idl/global.taihe b/interfaces/taihe/syscap/idl/internal.full.global.taihe similarity index 81% rename from interfaces/taihe/syscap/idl/global.taihe rename to interfaces/taihe/syscap/idl/internal.full.global.taihe index 4118a6476..cafb2b150 100644 --- a/interfaces/taihe/syscap/idl/global.taihe +++ b/interfaces/taihe/syscap/idl/internal.full.global.taihe @@ -12,7 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@!sts_inject(""" -loadLibrary("global_taihe_native") -""") -function canIUse(syscap: String): bool; \ No newline at end of file + @!namespace("@internal.full.global") + + @!sts_inject(""" + loadLibrary("global_taihe_native.z") + """) + function canIUse(syscap: String): bool; \ No newline at end of file diff --git a/interfaces/taihe/syscap/src/ani_constructor.cpp b/interfaces/taihe/syscap/src/ani_constructor.cpp index a90c1c386..f7cdf8b88 100644 --- a/interfaces/taihe/syscap/src/ani_constructor.cpp +++ b/interfaces/taihe/syscap/src/ani_constructor.cpp @@ -12,18 +12,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "taihe/runtime.hpp" -#include "global.ani.hpp" +#include "taihe.platform.ani.ani.hpp" +#include "internal.full.global.ani.hpp" +#if __has_include() +#include +#elif __has_include() +#include +#else +#error "ani.h not found, Please ensure the Ani SDK is correctly installed." +#endif ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) { ani_env *env; if (ANI_OK != vm->GetEnv(ANI_VERSION_1, &env)) { return ANI_ERROR; } - if (ANI_OK != global::ANIRegister(env)) { - std::cerr << "Error from global::ANIRegister" << std::endl; + if (ANI_OK != internal::full::global::ANIRegister(env)) { + std::cerr << "Error from internal::full::global::ANIRegister" << std::endl; return ANI_ERROR; } *result = ANI_VERSION_1; return ANI_OK; -} +} \ No newline at end of file diff --git a/interfaces/taihe/syscap/src/global.impl.cpp b/interfaces/taihe/syscap/src/internal.full.global.impl.cpp similarity index 84% rename from interfaces/taihe/syscap/src/global.impl.cpp rename to interfaces/taihe/syscap/src/internal.full.global.impl.cpp index e1f25df80..bc6a27880 100644 --- a/interfaces/taihe/syscap/src/global.impl.cpp +++ b/interfaces/taihe/syscap/src/internal.full.global.impl.cpp @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "global.proj.hpp" -#include "global.impl.hpp" +#include "internal.full.global.proj.hpp" +#include "internal.full.global.impl.hpp" #include "taihe/runtime.hpp" #include "stdexcept" #include "systemcapability.h" @@ -28,9 +28,6 @@ bool canIUse(string_view syscap) bool ret = HasSystemCapability(std::string(syscap).c_str()); return ret; } -} // namespace +} //namespace -// Since these macros are auto-generate, lint will cause false positive. -// NOLINTBEGIN TH_EXPORT_CPP_API_canIUse(canIUse); -// NOLINTEND -- Gitee