From f0cde381ad3465207a044cf42c2a09cb93ab9b45 Mon Sep 17 00:00:00 2001 From: WX1379483 Date: Tue, 3 Jun 2025 15:48:02 +0800 Subject: [PATCH] =?UTF-8?q?feat=20(=E6=A0=87=E8=AF=86):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9CrossModuleReference=E4=BB=93=E5=BA=93=E6=A0=87?= =?UTF-8?q?=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/build-profile.json5 | 17 +++++++++++- .../static_module/src/main/cpp/napi_har.h | 26 +++++++++++++++++++ .../static_module/src/main/cpp/napi_har1.h | 23 ++++++++++++++++ staticModule/build-profile.json5 | 6 +++++ 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 entry/oh_modules/static_module/src/main/cpp/napi_har.h create mode 100644 entry/oh_modules/static_module/src/main/cpp/napi_har1.h diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index 1001fff..00d934e 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -1,13 +1,26 @@ +// [Start json5_start2] +// [StartExclude json5_start2] { "apiType": "stageMode", + // [EndExclude json5_start2] "buildOption": { + // [StartExclude json5_start2] "externalNativeOptions": { "path": "./src/main/cpp/CMakeLists.txt", "arguments": "", "cppFlags": "", "abiFilters": ["x86_64","arm64-v8a"] + }, + // [EndExclude json5_start2] + "arkOptions" : { + "runtimeOnly" : { + "packages": [ + "static_module" + ] + } } }, + // [StartExclude json5_start2] "buildOptionSet": [ { "name": "release", @@ -37,4 +50,6 @@ "name": "ohosTest", } ] -} \ No newline at end of file +} +// [EndExclude json5_start2] +// [End json5_start2] \ No newline at end of file diff --git a/entry/oh_modules/static_module/src/main/cpp/napi_har.h b/entry/oh_modules/static_module/src/main/cpp/napi_har.h new file mode 100644 index 0000000..84d15a7 --- /dev/null +++ b/entry/oh_modules/static_module/src/main/cpp/napi_har.h @@ -0,0 +1,26 @@ +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// [Start har_start] +// staticModule\src\main\cpp\napi_har.h +#ifndef CROSSMODULEREFERENCE_NAPI_HAR_H +#define CROSSMODULEREFERENCE_NAPI_HAR_H +#include +napi_env g_main_env; +void setHarEnv(napi_env env); +double harNativeAdd(double a, double b); +napi_value harArkTSAdd(double a, double b); +#endif //CROSSMODULEREFERENCE_NAPI_HAR_H +// [End har_start] \ No newline at end of file diff --git a/entry/oh_modules/static_module/src/main/cpp/napi_har1.h b/entry/oh_modules/static_module/src/main/cpp/napi_har1.h new file mode 100644 index 0000000..8c9cf7a --- /dev/null +++ b/entry/oh_modules/static_module/src/main/cpp/napi_har1.h @@ -0,0 +1,23 @@ +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// [Start napi_har_start] +// staticModule\src\main\cpp\napi_har.h +#ifndef CROSSMODULEREFERENCE_NAPI_HAR_H +#define CROSSMODULEREFERENCE_NAPI_HAR_H +#include +double harNativeAdd(double a, double b); +#endif //CROSSMODULEREFERENCE_NAPI_HAR_H +// [End napi_har_start] \ No newline at end of file diff --git a/staticModule/build-profile.json5 b/staticModule/build-profile.json5 index 0ff9b0d..0b4401e 100644 --- a/staticModule/build-profile.json5 +++ b/staticModule/build-profile.json5 @@ -1,4 +1,5 @@ // [Start json5_start] +// [Start json5_start1] { "apiType": "stageMode", "buildOption": { @@ -12,6 +13,7 @@ "nativeLib": { "headerPath": "./src/main/cpp" }, + // [StartExclude json5_start1] // [EndExclude json5_start] "arkOptions" : { "runtimeOnly" : { @@ -54,6 +56,10 @@ "name": "ohosTest" } ], + // [EndExclude json5_start1] // [EndExclude json5_start] } +// [End json5_start1] // [End json5_start] + + -- Gitee