diff --git a/app/oh-package.json5 b/app/oh-package.json5 index d2b8133..0ddb33b 100644 --- a/app/oh-package.json5 +++ b/app/oh-package.json5 @@ -9,7 +9,7 @@ "@devwiki/common_ui": "file:../common_ui", "@devwiki/base": "file:../base", "@ohos/axios": "^2.2.0", - "@devwiki/native_lib": "file:../native_lib" + "@devwiki/hmcalculate": "file:../hmcalculate" }, "devDependencies": {}, "dynamicDependencies": {} diff --git a/app/src/main/ets/pages/Index.ets b/app/src/main/ets/pages/Index.ets index d75e76a..630288d 100644 --- a/app/src/main/ets/pages/Index.ets +++ b/app/src/main/ets/pages/Index.ets @@ -7,8 +7,7 @@ import { BusinessError } from '@ohos.base'; import { Log } from '@devwiki/base'; import { BaseLocalStorage, ScreenUtil } from '@devwiki/base'; import { HomeItem, HomeItemGroup } from '../model/Home'; -import { common, Want } from '@kit.AbilityKit'; -import { CalculateAdapter } from '@devwiki/native_lib/src/main/cpp/types/libnatvie_lib'; +import { CalculateAdapter } from '@devwiki/hmcalculate'; @Entry diff --git a/build-profile.json5 b/build-profile.json5 index 6a8c7eb..f833d03 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -81,8 +81,8 @@ ] }, { - "name": "native_lib", - "srcPath": "./native_lib", + "name": "hmcalculate", + "srcPath": "./hmcalculate", "targets": [ { "name": "default", diff --git a/cppLib/build.bat b/cppLib/build.bat index 6b97382..1cd002c 100644 --- a/cppLib/build.bat +++ b/cppLib/build.bat @@ -6,6 +6,11 @@ set cmake_root=%native_path%build-tools\cmake\ set cmake_path=%cmake_root%bin\cmake.exe set ninja_path=%cmake_root%bin\ninja.exe set make_path=C:\MinGW\msys\1.0\bin\make.exe +set arch=arm64-v8a + +IF NOT "%~1"=="" ( + set arch=%1 +) if exist build ( del /q /s build @@ -14,16 +19,19 @@ if exist build ( ) if exist dist ( - del /q /s dist + cd dist + if exist "%arch%" ( + del /q /s ""%arch%" + ) ) cd build :: 使用 make 构建 -:: %cmake_path% -G"Unix Makefiles" -DCMAKE_MAKE_PROGRAM="%make_path%" -DOHOS_STL=c++_static -DOHOS_ARCH=arm64-v8a -DOHOS_PLATFORM=OHOS -DCMAKE_TOOLCHAIN_FILE=%toolchain% .. +:: %cmake_path% -G"Unix Makefiles" -DCMAKE_MAKE_PROGRAM="%make_path%" -DOHOS_STL=c++_static -DOHOS_ARCH="%arch%" -DOHOS_PLATFORM=OHOS -DCMAKE_TOOLCHAIN_FILE=%toolchain% .. :: %make_path% :: 使用 ninja 构建 -%cmake_path% -GNinja -DCMAKE_MAKE_PROGRAM="%ninja_path%" -DOHOS_STL=c++_static -DOHOS_ARCH=arm64-v8a -DOHOS_PLATFORM=OHOS -DCMAKE_TOOLCHAIN_FILE=%toolchain% .. +%cmake_path% -GNinja -DCMAKE_MAKE_PROGRAM="%ninja_path%" -DOHOS_STL=c++_static -DOHOS_ARCH="%arch%" -DOHOS_PLATFORM=OHOS -DCMAKE_TOOLCHAIN_FILE=%toolchain% .. %ninja_path% cd ../ diff --git a/cppLib/dist/lib/x86_64/libcalculate.so b/cppLib/dist/lib/x86_64/libcalculate.so new file mode 100644 index 0000000..a05b9bd Binary files /dev/null and b/cppLib/dist/lib/x86_64/libcalculate.so differ diff --git a/native_lib/.gitignore b/hmcalculate/.gitignore similarity index 100% rename from native_lib/.gitignore rename to hmcalculate/.gitignore diff --git a/hmcalculate/Index.ets b/hmcalculate/Index.ets new file mode 100644 index 0000000..bfb9054 --- /dev/null +++ b/hmcalculate/Index.ets @@ -0,0 +1 @@ +export { CalculateAdapter } from './src/main/cpp/types/libhmcalculate/index' \ No newline at end of file diff --git a/native_lib/build-profile.json5 b/hmcalculate/build-profile.json5 similarity index 89% rename from native_lib/build-profile.json5 rename to hmcalculate/build-profile.json5 index bf4ad18..57f6d3e 100644 --- a/native_lib/build-profile.json5 +++ b/hmcalculate/build-profile.json5 @@ -4,7 +4,10 @@ "externalNativeOptions": { "path": "./src/main/cpp/CMakeLists.txt", "arguments": "", - "cppFlags": "" + "cppFlags": "", + "abiFilters": [ + "arm64-v8a" + ] } }, "buildOptionSet": [ diff --git a/native_lib/hvigorfile.ts b/hmcalculate/hvigorfile.ts similarity index 100% rename from native_lib/hvigorfile.ts rename to hmcalculate/hvigorfile.ts diff --git a/native_lib/obfuscation-rules.txt b/hmcalculate/obfuscation-rules.txt similarity index 100% rename from native_lib/obfuscation-rules.txt rename to hmcalculate/obfuscation-rules.txt diff --git a/native_lib/oh-package.json5 b/hmcalculate/oh-package.json5 similarity index 66% rename from native_lib/oh-package.json5 rename to hmcalculate/oh-package.json5 index 37b71eb..2fd1e59 100644 --- a/native_lib/oh-package.json5 +++ b/hmcalculate/oh-package.json5 @@ -1,5 +1,5 @@ { - "name": "@devwiki/native_lib", + "name": "@devwiki/hmcalculate", "version": "1.0.0", "description": "Please describe the basic information.", "main": "Index.ets", @@ -7,6 +7,6 @@ "license": "Apache-2.0", "packageType": "InterfaceHar", "dependencies": { - "native_lib.so": "file:./src/main/cpp/types/libnatvie_lib" + "libhmcalculate.so": "file:./src/main/cpp/types/libhmcalculate" } } \ No newline at end of file diff --git a/native_lib/src/main/cpp/CMakeLists.txt b/hmcalculate/src/main/cpp/CMakeLists.txt similarity index 68% rename from native_lib/src/main/cpp/CMakeLists.txt rename to hmcalculate/src/main/cpp/CMakeLists.txt index e80ee06..87adeaf 100644 --- a/native_lib/src/main/cpp/CMakeLists.txt +++ b/hmcalculate/src/main/cpp/CMakeLists.txt @@ -1,6 +1,6 @@ # the minimum version of CMake. cmake_minimum_required(VERSION 3.4.1) -project(myNpmLib) +project(hmcalculate) set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) @@ -11,9 +11,9 @@ endif() include_directories(${NATIVERENDER_ROOT_PATH} ${NATIVERENDER_ROOT_PATH}/include) -add_library(native_lib SHARED +add_library(hmcalculate SHARED napi_init.cpp CalculateInfo.h CalculateAdaptor.cpp) -target_link_libraries(native_lib PUBLIC ../../../../cppLib/dist/lib/arm64-v8a/libcalculate.so) \ No newline at end of file +target_link_libraries(hmcalculate PUBLIC ${NATIVERENDER_ROOT_PATH}/../../../../cppLib/dist/lib/arm64-v8a/libcalculate.so) \ No newline at end of file diff --git a/native_lib/src/main/cpp/Calculate.h b/hmcalculate/src/main/cpp/Calculate.h similarity index 100% rename from native_lib/src/main/cpp/Calculate.h rename to hmcalculate/src/main/cpp/Calculate.h diff --git a/native_lib/src/main/cpp/CalculateAdaptor.cpp b/hmcalculate/src/main/cpp/CalculateAdaptor.cpp similarity index 100% rename from native_lib/src/main/cpp/CalculateAdaptor.cpp rename to hmcalculate/src/main/cpp/CalculateAdaptor.cpp diff --git a/native_lib/src/main/cpp/CalculateAdaptor.h b/hmcalculate/src/main/cpp/CalculateAdaptor.h similarity index 100% rename from native_lib/src/main/cpp/CalculateAdaptor.h rename to hmcalculate/src/main/cpp/CalculateAdaptor.h diff --git a/native_lib/src/main/cpp/CalculateInfo.h b/hmcalculate/src/main/cpp/CalculateInfo.h similarity index 100% rename from native_lib/src/main/cpp/CalculateInfo.h rename to hmcalculate/src/main/cpp/CalculateInfo.h diff --git a/native_lib/src/main/cpp/napi_init.cpp b/hmcalculate/src/main/cpp/napi_init.cpp similarity index 98% rename from native_lib/src/main/cpp/napi_init.cpp rename to hmcalculate/src/main/cpp/napi_init.cpp index 517aeff..12844ff 100644 --- a/native_lib/src/main/cpp/napi_init.cpp +++ b/hmcalculate/src/main/cpp/napi_init.cpp @@ -18,9 +18,6 @@ napi_value JS_Constructor(napi_env env, napi_callback_info info) { return thisVar; } -EXTERN_C_START - - napi_value Init(napi_env env, napi_value exports) { const char className[] = "CalculateAdaptor"; @@ -35,7 +32,6 @@ napi_value Init(napi_env env, napi_value exports) napi_set_named_property(env, exports, "CalculateAdaptor", result); return exports; } -EXTERN_C_END static napi_module demoModule = { .nm_version = 1, diff --git a/native_lib/src/main/cpp/types/libnatvie_lib/index.d.ts b/hmcalculate/src/main/cpp/types/libhmcalculate/index.d.ts similarity index 100% rename from native_lib/src/main/cpp/types/libnatvie_lib/index.d.ts rename to hmcalculate/src/main/cpp/types/libhmcalculate/index.d.ts diff --git a/native_lib/src/main/cpp/types/libnatvie_lib/oh-package.json5 b/hmcalculate/src/main/cpp/types/libhmcalculate/oh-package.json5 similarity index 77% rename from native_lib/src/main/cpp/types/libnatvie_lib/oh-package.json5 rename to hmcalculate/src/main/cpp/types/libhmcalculate/oh-package.json5 index 7e8247b..f9d2701 100644 --- a/native_lib/src/main/cpp/types/libnatvie_lib/oh-package.json5 +++ b/hmcalculate/src/main/cpp/types/libhmcalculate/oh-package.json5 @@ -1,5 +1,5 @@ { - "name": "native_lib.so", + "name": "libhmcalculate.so", "types": "./index.d.ts", "version": "", "description": "Please describe the basic information." diff --git a/native_lib/src/main/ets/CalculateInfo.ets b/hmcalculate/src/main/ets/CalculateInfo.ets similarity index 100% rename from native_lib/src/main/ets/CalculateInfo.ets rename to hmcalculate/src/main/ets/CalculateInfo.ets diff --git a/native_lib/src/main/ets/Calculator.ets b/hmcalculate/src/main/ets/Calculator.ets similarity index 100% rename from native_lib/src/main/ets/Calculator.ets rename to hmcalculate/src/main/ets/Calculator.ets diff --git a/native_lib/src/main/ets/pages/Index.ets b/hmcalculate/src/main/ets/pages/Index.ets similarity index 100% rename from native_lib/src/main/ets/pages/Index.ets rename to hmcalculate/src/main/ets/pages/Index.ets diff --git a/native_lib/src/main/module.json5 b/hmcalculate/src/main/module.json5 similarity index 89% rename from native_lib/src/main/module.json5 rename to hmcalculate/src/main/module.json5 index 85006cf..e9fd641 100644 --- a/native_lib/src/main/module.json5 +++ b/hmcalculate/src/main/module.json5 @@ -1,6 +1,6 @@ { "module": { - "name": "native_lib", + "name": "hmcalculate", "type": "shared", "description": "$string:shared_desc", "deviceTypes": [ diff --git a/native_lib/src/main/resources/base/element/color.json b/hmcalculate/src/main/resources/base/element/color.json similarity index 100% rename from native_lib/src/main/resources/base/element/color.json rename to hmcalculate/src/main/resources/base/element/color.json diff --git a/native_lib/src/main/resources/base/element/string.json b/hmcalculate/src/main/resources/base/element/string.json similarity index 100% rename from native_lib/src/main/resources/base/element/string.json rename to hmcalculate/src/main/resources/base/element/string.json diff --git a/native_lib/src/main/resources/base/profile/main_pages.json b/hmcalculate/src/main/resources/base/profile/main_pages.json similarity index 100% rename from native_lib/src/main/resources/base/profile/main_pages.json rename to hmcalculate/src/main/resources/base/profile/main_pages.json diff --git a/native_lib/src/test/List.test.ets b/hmcalculate/src/test/List.test.ets similarity index 100% rename from native_lib/src/test/List.test.ets rename to hmcalculate/src/test/List.test.ets diff --git a/native_lib/src/test/LocalUnit.test.ets b/hmcalculate/src/test/LocalUnit.test.ets similarity index 100% rename from native_lib/src/test/LocalUnit.test.ets rename to hmcalculate/src/test/LocalUnit.test.ets diff --git a/native_lib/Index.ets b/native_lib/Index.ets deleted file mode 100644 index 25a2644..0000000 --- a/native_lib/Index.ets +++ /dev/null @@ -1 +0,0 @@ -export { CalculateAdapter } from './src/main/cpp/types/libnatvie_lib/index' \ No newline at end of file