diff --git a/arkoala-arkts/arkui/src/generated/PeerNode.ts b/arkoala-arkts/arkui/src/generated/PeerNode.ts index 6e4dbee13c81a7107f575ed0848b2ebc6195beea..fe1aacfdfac828975552fbd68200e0d48de35ad0 100644 --- a/arkoala-arkts/arkui/src/generated/PeerNode.ts +++ b/arkoala-arkts/arkui/src/generated/PeerNode.ts @@ -31,9 +31,9 @@ export class PeerNode extends IncrementalNode { if (node!.isKind(PeerNodeType)) { sibling = node as PeerNode break + } } - } - this.peer.insertChildAfter(peer.peer, sibling?.peer) + this.peer.insertChildAfter(peer.peer, sibling?.peer) } } this.onChildRemoved = (child: IncrementalNode) => { diff --git a/arkoala-arkts/arkui/src/generated/arkts/NativeModule.ts b/arkoala-arkts/arkui/src/generated/arkts/NativeModule.ts index b9b6f4fb7b725efecc49bfbd895510cd5eb8c9e6..ec1730d34d7a5a12c95e4a674ca4c54f9e875339 100644 --- a/arkoala-arkts/arkui/src/generated/arkts/NativeModule.ts +++ b/arkoala-arkts/arkui/src/generated/arkts/NativeModule.ts @@ -2371,4 +2371,7 @@ export class NativeModule { native static _TestGetManagedCaller(kind: int32): KPointer native static _TestGetManagedHolder(): KPointer native static _TestGetManagedReleaser(): KPointer + native static _MatchMediaSync(condition: string): boolean + native static _MediaQueryListener_onChange(thisArray: KUint8ArrayPtr, thisLength: int32): void + native static _MediaQueryListener_offChange(thisArray: KUint8ArrayPtr, thisLength: int32): void } diff --git a/arkoala-arkts/arkui/src/generated/mediaquery.ts b/arkoala-arkts/arkui/src/generated/mediaquery.ts new file mode 100644 index 0000000000000000000000000000000000000000..c39e1f5fb16d800d13f6beb7fdd4c87d35aa335c --- /dev/null +++ b/arkoala-arkts/arkui/src/generated/mediaquery.ts @@ -0,0 +1,52 @@ +import { KPointer, pointer } from "@koalaui/interop" +import { RuntimeType, runtimeType } from "./peers/SerializerBase" +import { NativeModule } from "#components" +import { Serializer } from "./peers/Serializer" + +export interface MediaQueryResult { + matches: boolean + condition: string +} +export interface MediaQueryListenerInterface extends MediaQueryResult { + on(type: "change", callback: ((parameter: MediaQueryResult) => void)): void + off(type: "change", callback?: ((parameter: MediaQueryResult) => void)): void +} +export class MediaQueryListener implements MediaQueryListenerInterface { + public _matches: boolean = false + public _condition: string = "" + constructor(matches: boolean, condition: string) { + this._matches = matches + this._condition = condition + } + get matches(): boolean { + return this._matches + } + set matches(matches:boolean) { + this._matches = matches + } + get condition(): string { + return this._condition + } + set condition(condition:string) { + this._condition = condition + } + on(type: "change", callback: ((parameter: MediaQueryResult) => void)): void { + const thisSerializer: Serializer = Serializer.hold() + thisSerializer.holdAndWriteCallback(callback) + NativeModule._MediaQueryListener_onChange(thisSerializer.asArray(), thisSerializer.length()) + thisSerializer.release() + } + off(type: "change", callback?: ((parameter: MediaQueryResult) => void)): void { + const thisSerializer: Serializer = Serializer.hold() + thisSerializer.holdAndWriteCallback(callback!) + NativeModule._MediaQueryListener_offChange(thisSerializer.asArray(), thisSerializer.length()) + thisSerializer.release() + } +} +export class mediaquery { + static matchMediaSync(condition: string): MediaQueryListener { + let matches = NativeModule._MatchMediaSync(condition) + let mediaQueryListener = new MediaQueryListener(matches, condition) + return mediaQueryListener + } +} \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/generated/peers/CallbackDeserializeCall.ts b/arkoala-arkts/arkui/src/generated/peers/CallbackDeserializeCall.ts index 5b7dc8f8ec2e73d9478af7b6b6277c009e4243b1..45045b506bdfac96ded9cbc13c8b67bbecf5755b 100644 --- a/arkoala-arkts/arkui/src/generated/peers/CallbackDeserializeCall.ts +++ b/arkoala-arkts/arkui/src/generated/peers/CallbackDeserializeCall.ts @@ -217,6 +217,9 @@ import { CustomDialogControllerOptions } from "./../ArkCustomDialogControllerInt import { IPropertySubscriber } from "./../ArkIPropertySubscriberMaterialized" import { Matrix2D } from "./../ArkMatrix2DMaterialized" import { Path2D } from "./../ArkPath2DMaterialized" +import { MediaQueryResult } from "./../mediaquery" + +import { NativeModule } from "#components" export function deserializeAndCallAccessibilityCallback(thisDeserializer: Deserializer) { const _resourceId : int32 = thisDeserializer.readInt32() @@ -2021,6 +2024,12 @@ export function deserializeAndCallWithThemeInterface(thisDeserializer: Deseriali let _continuation : Function1 = thisDeserializer.readCallback_WithThemeAttribute_Void() _continuation(_call(options)) } +export function deserializeAndCallCallback_MediaQuery(thisDeserializer: Deserializer) { + const _resourceId : int32 = thisDeserializer.readInt32() + const _call = (ResourceHolder.instance().get(_resourceId) as Function1) + let result : MediaQueryResult = thisDeserializer.readMediaQueryResult(); + _call(result) +} export function deserializeAndCallCallback(thisDeserializer: Deserializer) { const kind : int32 = thisDeserializer.readInt32() switch (kind) { @@ -2258,6 +2267,7 @@ export function deserializeAndCallCallback(thisDeserializer: Deserializer) { case 231/*CallbackKind.Kind_VoidCallback*/: return deserializeAndCallVoidCallback(thisDeserializer); case 232/*CallbackKind.Kind_WebKeyboardCallback*/: return deserializeAndCallWebKeyboardCallback(thisDeserializer); case 233/*CallbackKind.Kind_WithThemeInterface*/: return deserializeAndCallWithThemeInterface(thisDeserializer); + case 234/*CallbackKind.Kind_Callback_MeidaQuery*/: return deserializeAndCallCallback_MediaQuery(thisDeserializer); } throw new Error("Unknown callback kind") } \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/generated/peers/Deserializer.ts b/arkoala-arkts/arkui/src/generated/peers/Deserializer.ts index d0b88f036276ea8034863009a64757dfecec3f58..7991c5542e3b74015aef7de8e796a42605caa0ed 100644 --- a/arkoala-arkts/arkui/src/generated/peers/Deserializer.ts +++ b/arkoala-arkts/arkui/src/generated/peers/Deserializer.ts @@ -250,6 +250,7 @@ import { TextPickerDialogInternal } from "./../ArkTextPickerDialogMaterialized" import { TimePickerDialogInternal } from "./../ArkTimePickerDialogMaterialized" import { WebCookieInternal } from "./../ArkWebCookieMaterialized" import { MutableStyledStringInternal } from "./../ArkMutableStyledStringMaterialized" +import { MediaQueryResult } from "./../mediaquery" export class Deserializer extends DeserializerBase { constructor(data: KUint8ArrayPtr, length: int32) { @@ -19250,4 +19251,10 @@ export class Deserializer extends DeserializerBase { const _call : KPointer = this.readPointer() return (error?: Array | undefined): void => { const _argsSerializer : Serializer = Serializer.hold(); _argsSerializer.writeInt32(_resource.resourceId); _argsSerializer.writePointer(_call); let error_type : int32 = RuntimeType.UNDEFINED; error_type = runtimeType(error); _argsSerializer.writeInt8(error_type as int32); if ((RuntimeType.UNDEFINED) != (error_type)) {; const error_value = error!; _argsSerializer.writeInt32(error_value.length as int32); for (let i = 0; i < error_value.length; i++) {; const error_value_element = error_value[i]; _argsSerializer.writeString(error_value_element); } } NativeModule._CallCallback(CallbackKind.Kind_Callback_Opt_Array_String_Void.ordinal, _argsSerializer.asArray(), _argsSerializer.length()); _argsSerializer.release(); return; } } + readMediaQueryResult(): MediaQueryResult { + let valueDeserializer : Deserializer = this + const matches : boolean = valueDeserializer.readBoolean() + const condition : string = (valueDeserializer.readString() as string) + return {matches: matches, condition: condition} + } } diff --git a/arkoala-arkts/har/arkoala-har-bundle/load_page.mjs b/arkoala-arkts/har/arkoala-har-bundle/load_page.mjs index e3721683f7590650a634dc90a20d965032d38102..13d44c8557591ec1a90f21a3e4fe30f146ed63d3 100644 --- a/arkoala-arkts/har/arkoala-har-bundle/load_page.mjs +++ b/arkoala-arkts/har/arkoala-har-bundle/load_page.mjs @@ -1,4 +1,4 @@ -let loader = () => { throw new Error("Page laoder was not set") } +let loader = () => { throw new Error("Page loader was not set") } export function __setPageLoader(fn) { loader = fn; diff --git a/arkoala-arkts/har/arkoala-har-bundle/loader.js b/arkoala-arkts/har/arkoala-har-bundle/loader.js index a8bda75ed9d5a7ad61ad0cfc7bbc8de4e0b95f0d..eae927a69b2119bff436f85bd38aa3875c0d074f 100644 --- a/arkoala-arkts/har/arkoala-har-bundle/loader.js +++ b/arkoala-arkts/har/arkoala-har-bundle/loader.js @@ -94,8 +94,8 @@ export async function runEventLoop() { } export function checkLoader(variant) { let vm = -1; - let classPath = "/data/storage/el1/bundle/libs/arm" - let nativePath = "/data/storage/el1/bundle/libs/arm" + let classPath = `/data/storage/el1/bundle/libs/__ARCH__` + let nativePath = `/data/storage/el1/bundle/libs/__ARCH__` switch (variant) { case 'panda': { vm = 2; diff --git a/arkoala-arkts/har/arkoala-har-bundle/rollup.config.mjs b/arkoala-arkts/har/arkoala-har-bundle/rollup.config.mjs index 09de10efa8d44e13b5aa3773d8c655a1be81527a..0c3d3115197befce374098359063df51cfa1b084 100644 --- a/arkoala-arkts/har/arkoala-har-bundle/rollup.config.mjs +++ b/arkoala-arkts/har/arkoala-har-bundle/rollup.config.mjs @@ -31,7 +31,7 @@ const DEBUG = true; //const implementedPackagesEntries = implementedPackages.map((name) => `@koalaui/arkoala-arkui/${name}`) /** @type {import("rollup").RollupOptions[]} */ -export default [{ +export default cliOptions => [{ input: ["./bundle.mjs" /*, ...implementedPackagesEntries*/], output: { format: "module", @@ -59,6 +59,7 @@ export default [{ preventAssignment: true, values: { __ARKOALA_HAR__: 'true', + __ARCH__: cliOptions.arch } }), inject({ diff --git a/arkoala-arkts/har/package.json b/arkoala-arkts/har/package.json index 3683f493f7f14b0fddb3a6ff2495cc90d1f8e19a..61716d278a9e74411698d215c6abcb2f079b0573 100644 --- a/arkoala-arkts/har/package.json +++ b/arkoala-arkts/har/package.json @@ -18,16 +18,9 @@ }, "scripts": { "clean": "rimraf app/arkoala/build app/arkoala/libs app/arkoala/bundle.js arkoala-har-bundle/dist", - "compile:arkoala-arkts": "npm run --prefix ../arkui compile:arkts:unmemoized && npm run build:incremental:components --prefix ../../incremental/runtime && npm run link:arkts --prefix ../arkui", - "native:clean": "npm run --prefix ../../arkoala/framework clean", - "native:build": "npm run --prefix ../../arkoala/framework compile:native-panda-with-hzvm-ohos-arm64", - "native:build-arm32": "npm run --prefix ../../arkoala/framework compile:native-panda-with-hzvm-ohos-arm32", - "bundle": "node scripts/build-arkoala-har.mjs --arch arm", - "build": "npm run cli-tools:check && cd app && DEVECO_SDK_HOME=../../../arkoala/ohos-sdk/ohos-sdk ../command-line-tools/hvigor/bin/hvigorw --no-daemon --mode module -p product=default -p module=arkoala@default assembleHar", - "arkoala:har": "npm run --prefix ../../arkoala/ohos-sdk download && npm run bundle && npm run build", - "arkoala:har-arm32": "npm run --prefix ../../arkoala/ohos-sdk download && npm run bundle && npm run build", - "all": "npm run native:clean && npm run compile:arkoala && npm run native:build && npm run arkoala:har", - "all-arm32": "npm run native:clean && npm run compile:arkoala-arkts && npm run native:build-arm32 && npm run arkoala:har-arm32", + "pack": "npm run cli-tools:check && cd app && DEVECO_SDK_HOME=../../../arkoala/ohos-sdk/ohos-sdk ../command-line-tools/hvigor/bin/hvigorw --no-daemon --mode module -p product=default -p module=arkoala@default assembleHar", + "har-arm32": "npm run --prefix ../../arkoala/ohos-sdk download && node scripts/build-arkoala-har.mjs --arch arm32 && npm run pack", + "har-arm64": "npm run --prefix ../../arkoala/ohos-sdk download && node scripts/build-arkoala-har.mjs --arch arm64 && npm run pack", "cli-tools:chmod:bz": "node ../../arkoala/ohos-sdk/scripts/openlab-cli.mjs chmod -p ./command-line-tools/ohpm/bin -b 755 && node ../../arkoala/ohos-sdk/scripts/openlab-cli.mjs chmod -p ./command-line-tools/hvigor/bin -b 755", "cli-tools:chmod:yz": "node ../../../sdk/scripts/gitlab/gitlab-cli.mjs chmod -p ./command-line-tools/ohpm/bin -b 755 && node ../../../sdk/scripts/gitlab/gitlab-cli.mjs chmod -p ./command-line-tools/hvigor/bin -b 755", "cli-tools:download:bz": "node ../../arkoala/ohos-sdk/scripts/openlab-cli.mjs download -p command-line-tools -v 5.0.3502 -f command-line-tools.5.0.3502.zip -d command-line-tools && npm run cli-tools:chmod:bz", diff --git a/arkoala-arkts/har/scripts/build-arkoala-har.mjs b/arkoala-arkts/har/scripts/build-arkoala-har.mjs index a7279c2a26a6cc879b591a7522a04895636a46ec..7b0e82ef78e94766bc2a53298afaa1e73c9f74bf 100644 --- a/arkoala-arkts/har/scripts/build-arkoala-har.mjs +++ b/arkoala-arkts/har/scripts/build-arkoala-har.mjs @@ -15,12 +15,16 @@ const CWD = process.cwd() const BUNDLE_PATH = path.join(CWD, "arkoala-har-bundle") const HAR_PATH = path.join(CWD, "app/arkoala") -function rollupLaunch() { +function execCmdSync(cmd, options) { + return execSync(cmd, options).toString().trim().replace("\n", " ") +} + +function rollupLaunch(loaderArch) { console.log(`> Run rollup`) - execCmdSync("npx rollup -c") + execCmdSync(`npx rollup -c --arch ${loaderArch}`) } -function copyFilesToHar(from, to) { +function copyFileToHar(from, to) { if (!fs.existsSync(from)) { throw new Error(`file ${from} does not exist`) } @@ -29,22 +33,37 @@ function copyFilesToHar(from, to) { fs.cpSync(from, to, { recursive: true, force: true }) } +function copySoLibs(from, to) { + fs.readdirSync(from, {withFileTypes: true}) + .filter(file => file.name.endsWith(".so")) + .forEach(file => { + console.log(`> Copy from: ${from}/${file.name} to ${to}/${file.name}`) + fs.cpSync(`${from}/${file.name}`, `${to}/${file.name}`, { recursive: true, force: true }) + }) +} -function main() { +function main(targetLibDir, loaderArch) { process.chdir(BUNDLE_PATH) - rollupLaunch() + rollupLaunch(loaderArch) /* we don't yet know which files should be in har */ - copyFilesToHar(path.join(_dirname, `../../../arkoala/framework/build/libc++.so`), path.join(HAR_PATH, `libs/armeabi-v7a/libc++.so`)) - copyFilesToHar(path.join(_dirname, `../../../arkoala/framework/native/build-hzvm-ohos-arm32-vmloader/libArkoalaLoader.so`), path.join(HAR_PATH, `libs/armeabi-v7a/libArkoalaLoader.so`)) - copyFilesToHar(path.join(_dirname, `../../../arkoala/framework/native/build-hzvm-ohos-arm32-vmloader/libvmloader.so`), path.join(HAR_PATH, `libs/armeabi-v7a/libvmloader.so`)) - copyFilesToHar(path.join(_dirname, `../../../arkoala/framework/native/build-panda-ohos-arm32/libArkoalaNative_ark.so`), path.join(HAR_PATH, `libs/armeabi-v7a/libArkoalaNative_ark.so`)) - copyFilesToHar(path.join(_dirname, `../../build/arkoala.abc`), path.join(HAR_PATH, `libs/armeabi-v7a/arkoala.abc.so`)) + copyFileToHar(path.join(_dirname, `../../../arkoala/framework/build/libc++.so`), path.join(HAR_PATH, `libs/${targetLibDir}/libc++.so`)) + copyFileToHar(path.join(_dirname, `../../../arkoala/framework/build/libArkoalaLoader.so`), path.join(HAR_PATH, `libs/${targetLibDir}/libArkoalaLoader.so`)) + copyFileToHar(path.join(_dirname, `../../../arkoala/framework/build/libvmloader.so`), path.join(HAR_PATH, `libs/${targetLibDir}/libvmloader.so`)) + copyFileToHar(path.join(_dirname, `../../../arkoala/framework/build/libArkoalaNative_ark.so`), path.join(HAR_PATH, `libs/${targetLibDir}/libArkoalaNative_ark.so`)) + copyFileToHar(path.join(_dirname, `../../build/arkoala.abc`), path.join(HAR_PATH, `libs/${targetLibDir}/arkoala.abc.so`)) } -main() - -function execCmdSync(cmd, options) { - return execSync(cmd, options).toString().trim().replace("\n", " ") +const arch = args["arch"] +if (arch == "arm32") { + main("armeabi-v7a", "arm") +} else if (arch == "arm64") { + main("arm64-v8a", arch) + copyFileToHar(path.join(_dirname, `../../../arkoala/framework/build/libace_compatible_mock.so`), path.join(HAR_PATH, `libs/arm64-v8a/libace_compatible_mock.so`)) + copyFileToHar(path.join(_dirname, `../../../incremental/tools/panda/node_modules/@panda/sdk/ets/etsstdlib.abc`), path.join(HAR_PATH, `libs/arm64-v8a/etsstdlib.abc.so`)) + copySoLibs(path.join(_dirname, `../../../incremental/tools/panda/node_modules/@panda/sdk/ohos_arm64/lib`), path.join(HAR_PATH, `libs/arm64-v8a`)) +} else { + console.log("Unsupported architecture: ", arch) + exit(1) } diff --git a/arkoala-arkts/package.json b/arkoala-arkts/package.json index 6935e6acee855bac1890a62148d37a5ea63352f0..aa9c40cbc13fafdfc54d78d62e45f4bf1ee7652d 100644 --- a/arkoala-arkts/package.json +++ b/arkoala-arkts/package.json @@ -35,8 +35,8 @@ "panda:sdk:install": "PANDA_SDK_VERSION=1.5.0-dev.9440 npm run panda:sdk:install --prefix ../incremental/tools/panda", "compile:native:node-host": "npm run compile:native-panda-with-node-host --prefix ../arkoala/framework", "compile:native:hzvm-ohos-arm32": "npm run compile:native-panda-with-hzvm-ohos-arm32 --prefix ../arkoala/framework", + "compile:native:hzvm-ohos-arm64": "npm run compile:native-panda-with-hzvm-ohos-arm64 --prefix ../arkoala/framework", "build:loader:node": "npm run build:loader:node --prefix loader", - "build:loader:hzvm-ohos-arm32": "npm run build:loader:ohos-arm32 --prefix loader", "build:incremental": "npm run build:incremental --prefix ../incremental/runtime", "build:incremental:inc": "npm run build:incremental:inc --prefix ../incremental/runtime", "clean:incremental": "npm run clean:incremental --prefix ../incremental/runtime", @@ -60,9 +60,12 @@ "trivial:all:node": "npm run compile:native:node-host && npm run build:arkoala && npm run build:user && npm run build:loader:node && npm run run:node", "trivial:node": "npm run build:user && npm run build:loader:node && npm run run:node", "trivial:all:node:ci": "npm run compile:native:node-host && npm run build:arkoala && npm run build:user && npm run build:loader:node && npm run run:node:ci", - "trivial:all:har-arm32": "npm run compile:native:hzvm-ohos-arm32 && npm run build:arkoala && npm run arkoala:har-arm32 --prefix har", - "clean": "rimraf build user/build", + "arkoala:har-arm32": "npm run compile:native:hzvm-ohos-arm32 && npm run build:arkoala && npm run har-arm32 --prefix har", + "arkoala:har-arm64": "npm run compile:native:hzvm-ohos-arm64 && npm run build:arkoala && npm run har-arm64 --prefix har", + "user:har-arm32": "npm run har-arm32 --prefix user", + "user:har-arm64": "npm run har-arm64 --prefix user", + "clean": "rimraf build", "clean:native": "npm run clean --prefix ../arkoala/framework", - "clean:all": "npm run clean && npm run clean:incremental && npm run clean:interop && npm run clean:arkui-common && npm run clean:arkui-no-common && npm run clean:native" + "clean:all": "npm run clean && npm run clean:incremental && npm run clean:interop && npm run clean:arkui-common && npm run clean:arkui-no-common && npm run clean:native && npm run clean --prefix har && npm run clean --prefix user" } } diff --git a/arkoala-arkts/user/package.json b/arkoala-arkts/user/package.json index 3884c8279b230d829d5888cd7faca71dff52f520..6ea9c64e85e92becea73f04fe243b25468ffe732 100644 --- a/arkoala-arkts/user/package.json +++ b/arkoala-arkts/user/package.json @@ -3,7 +3,7 @@ "version": "1.4.1", "description": "", "scripts": { - "clean": "rimraf build generated unmemoized js_output abc lib ", + "clean": "rimraf build generated unmemoized js_output abc lib app/user/build", "compile:plugin": "cd ../../arkoala/ets-plugin && npm run compile", "compile:ets": "npm run compile:plugin && cd src/ets && ets-tsc -p ./etsconfig.json", "unmemoize": "npm run compile:ets && memo-tsc -p tsconfig-unmemoize.json", @@ -14,10 +14,9 @@ "compile:user": "npm run unmemoize:all && bash ../../incremental/tools/panda/arkts/arktsc --arktsconfig arktsconfig-run-unmemoized.json --ets-module", "build:user": "npm run compile:user && bash ../../incremental/tools/panda/arkts/arklink --output build/user.abc -- $(find build/abc -name '*.abc' ! -name 'index.abc')", - "bundle": "node scripts/build-user-har.mjs --arch arm", - "build": "npm run cli-tools:check && cd app && DEVECO_SDK_HOME=../../../arkoala/ohos-sdk/ohos-sdk ../command-line-tools/hvigor/bin/hvigorw --no-daemon --mode module -p product=default -p module=user@default assembleHar", - "user:har": "npm run build:user && npm run --prefix ../../arkoala/ohos-sdk download && npm run bundle && npm run build", - "user:har-arm32": "npm run user:har", + "pack": "npm run cli-tools:check && cd app && DEVECO_SDK_HOME=../../../arkoala/ohos-sdk/ohos-sdk ../command-line-tools/hvigor/bin/hvigorw --no-daemon --mode module -p product=default -p module=user@default assembleHar", + "har-arm32": "npm run build:user && npm run --prefix ../../arkoala/ohos-sdk download && node scripts/build-user-har.mjs --arch arm32 && npm run pack", + "har-arm64": "npm run build:user && npm run --prefix ../../arkoala/ohos-sdk download && node scripts/build-user-har.mjs --arch arm64 && npm run pack", "cli-tools:chmod:bz": "node ../../arkoala/ohos-sdk/scripts/openlab-cli.mjs chmod -p ./command-line-tools/ohpm/bin -b 755 && node ../../arkoala/ohos-sdk/scripts/openlab-cli.mjs chmod -p ./command-line-tools/hvigor/bin -b 755", "cli-tools:chmod:yz": "node ../../../sdk/scripts/gitlab/gitlab-cli.mjs chmod -p ./command-line-tools/ohpm/bin -b 755 && node ../../../sdk/scripts/gitlab/gitlab-cli.mjs chmod -p ./command-line-tools/hvigor/bin -b 755", diff --git a/arkoala-arkts/user/scripts/build-user-har.mjs b/arkoala-arkts/user/scripts/build-user-har.mjs index 54d293afbb87b6660657d258e8188a0bd0acffa5..82c4b71b480948a6d812ad9bc47c104fd93e32cc 100644 --- a/arkoala-arkts/user/scripts/build-user-har.mjs +++ b/arkoala-arkts/user/scripts/build-user-har.mjs @@ -15,6 +15,10 @@ const CWD = process.cwd() // const BUNDLE_PATH = path.join(CWD, "arkoala-har-bundle") const HAR_PATH = path.join(CWD, "app/user") +function execCmdSync(cmd, options) { + return execSync(cmd, options).toString().trim().replace("\n", " ") +} + function rollupLaunch() { console.log(`> Run rollup`) execCmdSync("npx rollup -c") @@ -30,17 +34,21 @@ function copyFilesToHar(from, to) { } -function main() { +function main(targetLibDir) { // process.chdir(BUNDLE_PATH) // rollupLaunch() /* we don't yet know which files should be in har */ - copyFilesToHar(path.join(_dirname, `../build/user.abc`), path.join(HAR_PATH, `libs/armeabi-v7a/user.abc.so`)) + copyFilesToHar(path.join(_dirname, `../build/user.abc`), path.join(HAR_PATH, `libs/${targetLibDir}/user.abc.so`)) } -main() - -function execCmdSync(cmd, options) { - return execSync(cmd, options).toString().trim().replace("\n", " ") +const arch = args["arch"] +if (arch == "arm32") { + main("armeabi-v7a", arch) +} else if (arch == "arm64") { + main("arm64-v8a", arch) +} else { + console.log("Unsupported architecture: ", arch) + exit(1) } diff --git a/arkoala/framework/native/meson.build b/arkoala/framework/native/meson.build index 83b4cf9140c3d40e9d5ad89158ccaaf1479c508f..7129467aa3d4c537c02c4a1f3e02638a331f2aff 100644 --- a/arkoala/framework/native/meson.build +++ b/arkoala/framework/native/meson.build @@ -24,6 +24,7 @@ libace_sources = [ arkoala_sources = [ './src/events.cc', + './src/vsync.cc', './src/generated/all_events.cc', './src/generated/bridge_generated.cc', './src/generated/callback_deserialize_call.cc', @@ -111,7 +112,7 @@ if os == 'linux' platform_suffix = 'so' endif if os == 'macos' - cflags += ['-DKOALA_MACOS', '-mmacosx-version-min=13.0'] + cflags += ['-DKOALA_MACOS', '-mmacosx-version-min=13.3'] platform_prefix = 'lib' platform_suffix = 'dylib' endif @@ -179,6 +180,9 @@ if is_jni if jni_os_dir == 'windows' jni_os_dir = 'win32' endif + if jni_os_dir == 'macos' + jni_os_dir = 'darwin' + endif include_dirs += [ interop_src / 'jni', interop_src / 'types', @@ -230,8 +234,6 @@ endif if get_option('arkoala') sources += arkoala_sources -else - library_use_name = 'ArkoalaLoader' endif if is_msvc @@ -240,7 +242,8 @@ else cflags += ['-Wno-parentheses-equality', '-Wno-extern-c-compat'] endif -if get_option('arkoala') and not is_ohos +if get_option('arkoala') and (not is_ohos or arch == 'arm64') + cflags += ['-DLIBACE_' + os.to_upper() + '_' + arch.to_upper()] shared_library(libace_name, libace_sources, override_options: [ @@ -314,4 +317,34 @@ if get_option('vmloader') == true cpp_args: vmloader_cflags, link_args: vmloader_ldflags, ) + + loader_sources = [ + './src/generated/library.cc', + './src/vsync.cc', + interop_src / 'common-interop.cc', + interop_src / 'interop-logging.cc', + ] + + if is_napi + loader_sources += [ + interop_src / 'napi/convertors-napi.cc', + ] + endif + + cflags += ['-DLIBACE_' + os.to_upper() + '_' + arch.to_upper()] + shared_library('ArkoalaLoader', + loader_sources, + override_options: [ + # So that we can refer NAPI symbols. + 'b_lundef=false', + ], + install: true, + name_prefix: module_prefix, + name_suffix: module_suffix, + include_directories: include_dirs, + install_dir: source_dir / '..' / 'build', + cpp_args: cflags, + link_args: ldflags, + dependencies: deps + ) endif diff --git a/arkoala/framework/native/src/SerializerBase.h b/arkoala/framework/native/src/SerializerBase.h index ab9bd8fcc6261608303afb48dfafb187dc4dc7da..a5ebbca173afa3a7b1d57f70ff6243838fceef1d 100644 --- a/arkoala/framework/native/src/SerializerBase.h +++ b/arkoala/framework/native/src/SerializerBase.h @@ -190,6 +190,11 @@ public: writeInt64((Ark_Int64)buffer.data); writeInt64(buffer.length); } + + void writeMediaQueryResult(Ark_MediaQueryResult result) { + writeBoolean(result.matches); + writeString(result.media); + } }; #endif // _SERIALIZER_BASE_H \ No newline at end of file diff --git a/arkoala/framework/native/src/generated/arkoala_api_generated.h b/arkoala/framework/native/src/generated/arkoala_api_generated.h index 292b317ae97c56029647c2111b4a6bfbd2e7e7fa..25b9e2d760fc942722bddeac026f7b740f43d5f2 100644 --- a/arkoala/framework/native/src/generated/arkoala_api_generated.h +++ b/arkoala/framework/native/src/generated/arkoala_api_generated.h @@ -23,7 +23,7 @@ // The only include allowed in this file! Do not add anything else ever. #include -#define GENERATED_ARKUI_FULL_API_VERSION 104 +#define GENERATED_ARKUI_FULL_API_VERSION 105 #define GENERATED_ARKUI_NODE_API_VERSION GENERATED_ARKUI_FULL_API_VERSION #define GENERATED_ARKUI_BASIC_NODE_API_VERSION 1 @@ -20740,7 +20740,15 @@ typedef struct GENERATED_ArkUIAnyAPI { Ark_Int32 version; } GENERATED_ArkUIAnyAPI; +typedef struct Ark_MediaQueryResult{ + Ark_Boolean matches; + Ark_String media; +}Ark_MediaQueryResult; +typedef struct Callback_MediaQuery_Void { + Ark_CallbackResource resource; + void (*call)(const Ark_Int32 resourceId, const Ark_MediaQueryResult result); +} Callback_MediaQuery_Void; struct Ark_AnyAPI { diff --git a/arkoala/framework/native/src/generated/bridge_custom.cc b/arkoala/framework/native/src/generated/bridge_custom.cc index 1e9263e4354711ff17a17d7dedaaf3493d7b5795..18a71a343a7660930cbe1b4f9aa495b84cd303cc 100644 --- a/arkoala/framework/native/src/generated/bridge_custom.cc +++ b/arkoala/framework/native/src/generated/bridge_custom.cc @@ -26,19 +26,8 @@ #include "arkoala_api_generated.h" #include "Serializers.h" -const GENERATED_ArkUIAnyAPI* GetAnyImpl(int kind, int version, std::string* result = nullptr); - -const GENERATED_ArkUIBasicNodeAPI* GetArkUIBasicNodeAPI() { - return reinterpret_cast( - GetAnyImpl(static_cast(GENERATED_Ark_APIVariantKind::GENERATED_BASIC), - GENERATED_ARKUI_BASIC_NODE_API_VERSION, nullptr)); -} - -const GENERATED_ArkUIExtendedNodeAPI* GetArkUIExtendedNodeAPI() { - return reinterpret_cast( - GetAnyImpl(static_cast(GENERATED_Ark_APIVariantKind::GENERATED_EXTENDED), - GENERATED_ARKUI_EXTENDED_NODE_API_VERSION, nullptr)); -} +const GENERATED_ArkUIBasicNodeAPI* GetArkUIBasicNodeAPI(); +const GENERATED_ArkUIExtendedNodeAPI* GetArkUIExtendedNodeAPI(); CustomDeserializer* DeserializerBase::customDeserializers = nullptr; @@ -343,46 +332,6 @@ void impl_SetLazyItemIndexer(KVMContext vmContext, Ark_NativePointer nodePtr, Ar } KOALA_INTEROP_CTX_V2(SetLazyItemIndexer, Ark_NativePointer, Ark_Int32) -// TODO: map if multiple pipeline contexts. -static KVMDeferred* currentVsyncDeferred = nullptr; - -void vsyncCallback(Ark_PipelineContext context) { - if (currentVsyncDeferred) { - currentVsyncDeferred->resolve(currentVsyncDeferred, nullptr, 0); - currentVsyncDeferred = nullptr; - } -} - -void impl_SetVsyncCallback(Ark_NativePointer pipelineContext) -{ - Ark_PipelineContext pipelineContextCast = (Ark_PipelineContext) pipelineContext; - GetArkUIExtendedNodeAPI()->setVsyncCallback(pipelineContextCast, vsyncCallback); -} -KOALA_INTEROP_V1(SetVsyncCallback, Ark_NativePointer) - -KVMObjectHandle impl_VSyncAwait(KVMContext vmContext, Ark_NativePointer pipelineContext) -{ - Ark_PipelineContext pipelineContextCast = (Ark_PipelineContext)pipelineContext; - KVMObjectHandle result = nullptr; - KVMDeferred* deferred = CreateDeferred(vmContext, &result); - if (currentVsyncDeferred) { - LOGE("%s", "Multiple unresolved vsync deferred"); - currentVsyncDeferred->reject(currentVsyncDeferred, "Wrong"); - } - currentVsyncDeferred = deferred; - return result; -} -KOALA_INTEROP_CTX_1(VSyncAwait, KVMObjectHandle, Ark_NativePointer) - -void impl_UnblockVsyncWait(Ark_NativePointer pipelineContext) -{ - if (currentVsyncDeferred) { - currentVsyncDeferred->resolve(currentVsyncDeferred, nullptr, 0); - currentVsyncDeferred = nullptr; - } -} -KOALA_INTEROP_V1(UnblockVsyncWait, Ark_NativePointer) - void impl_SetCustomCallback(KVMContext vmContext, Ark_NativePointer nodePtr, Ark_Int32 updaterId) { Ark_VMContext vmContextCast = (Ark_VMContext) vmContext; @@ -468,13 +417,6 @@ void impl_SetRangeUpdater(Ark_NativePointer nodePtr, Ark_Int32 updaterId) } KOALA_INTEROP_V2(SetRangeUpdater, Ark_NativePointer, Ark_Int32) -Ark_NativePointer impl_GetPipelineContext(Ark_NativePointer nodePtr) -{ - Ark_NodeHandle nodePtrCast = (Ark_NodeHandle) nodePtr; - return GetArkUIExtendedNodeAPI()->getPipelineContext(nodePtrCast); -} -KOALA_INTEROP_1(GetPipelineContext, Ark_NativePointer, Ark_NativePointer) - void impl_SetChildTotalCount(Ark_NativePointer nodePtr, Ark_Int32 totalCount) { Ark_NodeHandle nodePtrCast = (Ark_NodeHandle) nodePtr; @@ -529,8 +471,9 @@ KVMObjectHandle impl_LoadUserView(KVMContext vm, const KStringPtr& viewClass, co EtsEnv* env = reinterpret_cast(vm); std:: string className(viewClass.c_str()); // TODO: hack, fix it! - if (className == "ViewLoaderApp") className = "Page.App"; + if (className == "ViewLoaderApp") className = "Page.ViewShoppingApp"; std::replace(className.begin(), className.end(), '.', '/'); + LOGI("testtest ##### env->FindClass %" LOG_PUBLIC "s", className.c_str()); ets_class viewClassClass = env->FindClass(className.c_str()); if (!viewClassClass) { LOGI("##### Cannot find user class %" LOG_PUBLIC "s", viewClass.c_str()); diff --git a/arkoala/framework/native/src/generated/callback_kind.h b/arkoala/framework/native/src/generated/callback_kind.h index 3ef343f5125527e468b1b8ae344baa78bbfb5838..38d2fb7c59e091045e9db6812251a53be534aa2d 100644 --- a/arkoala/framework/native/src/generated/callback_kind.h +++ b/arkoala/framework/native/src/generated/callback_kind.h @@ -237,6 +237,7 @@ typedef enum CallbackKind { Kind_VoidCallback = 231, Kind_WebKeyboardCallback = 232, Kind_WithThemeInterface = 233, + Kind_Callback_MeidaQuery = 234, } CallbackKind; #endif diff --git a/arkoala/framework/native/src/generated/callback_managed_caller.cc b/arkoala/framework/native/src/generated/callback_managed_caller.cc index b121707c771c8dae41e92c8ff71abb61685a708b..05c004124653959eec102cce6bb58c6f992abb2e 100644 --- a/arkoala/framework/native/src/generated/callback_managed_caller.cc +++ b/arkoala/framework/native/src/generated/callback_managed_caller.cc @@ -3052,6 +3052,17 @@ void callManagedWithThemeInterface(Ark_Int32 resourceId, Ark_WithThemeOptions op argsSerializer.writePointer(reinterpret_cast(continuation.call)); enqueueArkoalaCallback(&__buffer); } +void callManagedMeidaQuery(Ark_Int32 resourceId, Ark_MediaQueryResult result) +{ + CallbackBuffer __buffer = {{}, {}}; + const Ark_CallbackResource __callbackResource = {resourceId, holdManagedCallbackResource, releaseManagedCallbackResource}; + __buffer.resourceHolder.holdCallbackResource(&__callbackResource); + Serializer argsSerializer = Serializer(__buffer.buffer, &(__buffer.resourceHolder)); + argsSerializer.writeInt32(Kind_Callback_ClickEvent_Void); + argsSerializer.writeInt32(resourceId); + argsSerializer.writeMediaQueryResult(result); + enqueueArkoalaCallback(&__buffer); +} void* getManagedCallbackCaller(CallbackKind kind) { switch (kind) { @@ -3289,6 +3300,7 @@ void* getManagedCallbackCaller(CallbackKind kind) case Kind_VoidCallback: return reinterpret_cast(callManagedVoidCallback); case Kind_WebKeyboardCallback: return reinterpret_cast(callManagedWebKeyboardCallback); case Kind_WithThemeInterface: return reinterpret_cast(callManagedWithThemeInterface); + case Kind_Callback_MeidaQuery: return reinterpret_cast(callManagedMeidaQuery); } return nullptr; } \ No newline at end of file diff --git a/arkoala/framework/native/src/generated/library.cc b/arkoala/framework/native/src/generated/library.cc index 84c857d939169e479c1d36ee8775a94b3dd35316..58e7067de9f8bb036dccd5e487f3b9c2cb2105af 100644 --- a/arkoala/framework/native/src/generated/library.cc +++ b/arkoala/framework/native/src/generated/library.cc @@ -25,14 +25,21 @@ // TODO: rework for generic OHOS case. void* FindModule(int kind) { std::tuple candidates[] = { +#ifndef LIBACE_OHOS_ARM64 { "ace_compatible", true}, { "ace", true }, +#endif { "ace_compatible_mock", true}, { nullptr, false } }; +#ifndef LIBACE_OHOS_ARM64 char* envValue = getenv("ACE_LIBRARY_PATH"); std::string prefix = envValue ? std::string(envValue) : ""; - LOGE("Search ACE in \"%s\" (env ACE_LIBRARY_PATH) for API %d", prefix.c_str(), kind); +#else + std::string prefix = "/data/storage/el1/bundle/libs/arm64"; +#endif + + LOGE("Search ACE in \"%" LOG_PUBLIC "s\" for API %" LOG_PUBLIC "d", prefix.c_str(), kind); for (auto* candidate = candidates; std::get<0>(*candidate); candidate++) { std::string name = std::get<0>(*candidate); if (std::get<1>(*candidate)) { @@ -41,12 +48,11 @@ void* FindModule(int kind) { std::string libraryName = prefix + "/" + name; void* module = loadLibrary(libraryName); if (module) { - LOGE("ACE module at: %s", libraryName.c_str()); + LOGE("ACE module at: %" LOG_PUBLIC "s module = %" LOG_PUBLIC "p", libraryName.c_str(), module); return module; - } else { - // LOGE("Cannot find ACE module: %s %s", libraryName.c_str(), libraryError()); } } + LOGE("Cannot find ACE module: %" LOG_PUBLIC "s", libraryError()); return nullptr; } @@ -62,6 +68,7 @@ const GENERATED_ArkUIAnyAPI* GetAnyImpl(int kind, int version, std::string* resu typedef GENERATED_ArkUIAnyAPI* (*GetAPI_t)(int, int); static GetAPI_t getAPI = nullptr; +#ifdef LIBACE_OHOS_ARM64 char* envValue = getenv("__LIBACE_ENTRY_POINT"); if (envValue) { long long value = strtoll(envValue, NULL, 16); @@ -69,6 +76,7 @@ const GENERATED_ArkUIAnyAPI* GetAnyImpl(int kind, int version, std::string* resu getAPI = reinterpret_cast(static_cast(value)); } } +#endif if (getAPI == nullptr) { void* module = FindModule(kind); if (!module) { @@ -83,7 +91,7 @@ const GENERATED_ArkUIAnyAPI* GetAnyImpl(int kind, int version, std::string* resu if (result) *result = std::string("Cannot find ") + getArkAnyAPIFuncName; else - LOGE("Cannot find %s", getArkAnyAPIFuncName); + LOGE("Cannot find %" LOG_PUBLIC "s", getArkAnyAPIFuncName); return nullptr; } } @@ -98,7 +106,7 @@ const GENERATED_ArkUIAnyAPI* GetAnyImpl(int kind, int version, std::string* resu if (result) *result = "getAPI() returned null"; else - LOG("getAPI() returned null") + LOGE("getAPI() returned null for kind=%" LOG_PUBLIC "d, version=%" LOG_PUBLIC "d", kind, version); return nullptr; } if (impl->version != version) { @@ -115,4 +123,16 @@ const GENERATED_ArkUIAnyAPI* GetAnyImpl(int kind, int version, std::string* resu impls[kind] = impl; } return impls[kind]; -} \ No newline at end of file +} + +const GENERATED_ArkUIBasicNodeAPI* GetArkUIBasicNodeAPI() { + return reinterpret_cast( + GetAnyImpl(static_cast(GENERATED_Ark_APIVariantKind::GENERATED_BASIC), + GENERATED_ARKUI_BASIC_NODE_API_VERSION, nullptr)); +} + +const GENERATED_ArkUIExtendedNodeAPI* GetArkUIExtendedNodeAPI() { + return reinterpret_cast( + GetAnyImpl(static_cast(GENERATED_Ark_APIVariantKind::GENERATED_EXTENDED), + GENERATED_ARKUI_EXTENDED_NODE_API_VERSION, nullptr)); +} diff --git a/arkoala/framework/native/src/generated/mediaquery.cc b/arkoala/framework/native/src/generated/mediaquery.cc new file mode 100644 index 0000000000000000000000000000000000000000..b03eb67b3605909000b7d9bf45cb025ca9b9f2d9 --- /dev/null +++ b/arkoala/framework/native/src/generated/mediaquery.cc @@ -0,0 +1,54 @@ +/* + * 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. + */ + +#include "mediaquery.h" + +#include "common-interop.h" +#include "SerializerBase.h" +#include "DeserializerBase.h" +#include + + + + +Ark_Boolean impl_MatchMediaSync(Ark_String condition) { + return GetAnyImpl(static_cast((GENERATED_Ark_APIVariantKind::GENERATED_MQ), + GENERATED_ARKUI_MQ_API_VERSION, nullptr))->MatchMediaSync(condition); +} +KOALA_INTEROP_V1(MatchMediaSync, Ark_Boolean, string) + + +void impl_MediaQueryListener_onChange(uint8_t* thisArray, int32_t thisLength) { + Ark_NodeHandle self = reinterpret_cast(thisPtr); + Deserializer thisDeserializer(thisArray, thisLength); + Callback_MediaQuery_Void value_value = {thisDeserializer.readCallbackResource(), + reinterpret_cast + (thisDeserializer.readPointerOrDefault(reinterpret_cast(getManagedCallbackCaller(Kind_Callback_MeidaQuery))))};; + GetAnyImpl(static_cast((GENERATED_Ark_APIVariantKind::GENERATED_MQ), + GENERATED_ARKUI_MQ_API_VERSION, nullptr))->OnChange((const Callback_MediaQuery_Void*)&value_value); +} +KOALA_INTEROP_V2(MediaQueryListener_onChange, uint8_t*, int32_t) + +void impl_MediaQueryListener_offChange(uint8_t* thisArray, int32_t thisLength) { + Ark_NodeHandle self = reinterpret_cast(thisPtr); + Deserializer thisDeserializer(thisArray, thisLength); + Callback_MediaQuery_Void value_value = {thisDeserializer.readCallbackResource(), + reinterpret_cast + (thisDeserializer.readPointerOrDefault(reinterpret_cast(getManagedCallbackCaller(Kind_Callback_MeidaQuery))))};; + GetAnyImpl(static_cast((GENERATED_Ark_APIVariantKind::GENERATED_MQ), + GENERATED_ARKUI_MQ_API_VERSION, nullptr))->OffChange((const Callback_MediaQuery_Void*)&value_value); +} +KOALA_INTEROP_V2(MediaQueryListener_offChange, uint8_t*, int32_t) + diff --git a/arkoala/framework/native/src/vsync.cc b/arkoala/framework/native/src/vsync.cc new file mode 100644 index 0000000000000000000000000000000000000000..6e977e726c78bd365815e4e7d9bde57c80dcb0c0 --- /dev/null +++ b/arkoala/framework/native/src/vsync.cc @@ -0,0 +1,52 @@ +#include "common-interop.h" +#include "interop-logging.h" + +#include "arkoala_api_generated.h" + +const GENERATED_ArkUIExtendedNodeAPI* GetArkUIExtendedNodeAPI(); + +// TODO: map if multiple pipeline contexts. +static KVMDeferred* currentVsyncDeferred = nullptr; + +void vsyncCallback(Ark_PipelineContext context) { + if (currentVsyncDeferred) { + currentVsyncDeferred->resolve(currentVsyncDeferred, nullptr, 0); + currentVsyncDeferred = nullptr; + } +} + +void impl_SetVsyncCallback(Ark_NativePointer pipelineContext) { + Ark_PipelineContext pipelineContextCast = (Ark_PipelineContext) pipelineContext; + GetArkUIExtendedNodeAPI()->setVsyncCallback(pipelineContextCast, vsyncCallback); +} +KOALA_INTEROP_V1(SetVsyncCallback, Ark_NativePointer) + +KVMObjectHandle impl_VSyncAwait(KVMContext vmContext, Ark_NativePointer pipelineContext) +{ + Ark_PipelineContext pipelineContextCast = (Ark_PipelineContext)pipelineContext; + KVMObjectHandle result = nullptr; + KVMDeferred* deferred = CreateDeferred(vmContext, &result); + if (currentVsyncDeferred) { + LOGE("%s", "Multiple unresolved vsync deferred"); + currentVsyncDeferred->reject(currentVsyncDeferred, "Wrong"); + } + currentVsyncDeferred = deferred; + return result; +} +KOALA_INTEROP_CTX_1(VSyncAwait, KVMObjectHandle, Ark_NativePointer) + +void impl_UnblockVsyncWait(Ark_NativePointer pipelineContext) +{ + if (currentVsyncDeferred) { + currentVsyncDeferred->resolve(currentVsyncDeferred, nullptr, 0); + currentVsyncDeferred = nullptr; + } +} +KOALA_INTEROP_V1(UnblockVsyncWait, Ark_NativePointer) + +Ark_NativePointer impl_GetPipelineContext(Ark_NativePointer nodePtr) +{ + Ark_NodeHandle nodePtrCast = (Ark_NodeHandle) nodePtr; + return GetArkUIExtendedNodeAPI()->getPipelineContext(nodePtrCast); +} +KOALA_INTEROP_1(GetPipelineContext, Ark_NativePointer, Ark_NativePointer) diff --git a/arkoala/framework/package.json b/arkoala/framework/package.json index 9b7843d47716a9ca58f1ff384802ea3bf82721d8..11410c073f5618ba85d2e1656f3473fb9e1cdc19 100644 --- a/arkoala/framework/package.json +++ b/arkoala/framework/package.json @@ -33,7 +33,7 @@ "compile:native-hzvm-host": "npm run configure:native-hzvm-host && cd native && meson compile -C build-hzvm-host && meson install -C build-hzvm-host", "configure:native-panda-host": "cd native && meson setup -D vm_kind=panda build-panda-host", "compile:native-panda-host": "npm run configure:native-panda-host && cd native && meson compile -C build-panda-host && meson install -C build-panda-host", - "configure:native-jvm-host": "cd native && meson setup -D vm_kind=jvm build-jvm-host -D jdk_dir=$JAVA_HOME", + "configure:native-jvm-host": "cd native && meson setup -D vm_kind=jvm build-jvm-host -D vmloader=true -D jdk_dir=$JAVA_HOME", "compile:native-jvm-host": "npm run configure:native-jvm-host && cd native && meson compile -C build-jvm-host && meson install -C build-jvm-host", "configure:native-hzvm-ohos-arm64": "npm run prepare:arm64 && cd native && node ../scripts/configure.mjs hzvm-ohos-arm64", "compile:native-hzvm-ohos-arm64": "npm run configure:native-hzvm-ohos-arm64 && cd native && meson compile -C build-hzvm-ohos-arm64 && meson install -C build-hzvm-ohos-arm64", diff --git a/interop/src/cpp/vmloader.cc b/interop/src/cpp/vmloader.cc index 8430ab5a522ed370ff2ab695c9885b698f146326..29b4c802f82a68b93b959db851e03c63ba4b6552 100644 --- a/interop/src/cpp/vmloader.cc +++ b/interop/src/cpp/vmloader.cc @@ -63,38 +63,48 @@ const VMLibInfo javaVMLib = { #ifdef KOALA_ETS_NAPI const VMLibInfo pandaVMLib = { + // sdkPath #if defined(KOALA_OHOS) - #if defined(__arm) - "/system" - #else - "/data/storage/el1/bundle/libs/arm64" - #endif + #if defined(__arm) + "/system" + #else + "/data/storage/el1/bundle/libs" + #endif #else - getenv("PANDA_HOME") + getenv("PANDA_HOME") #endif , + + // platform #ifdef KOALA_LINUX - #ifdef KOALA_LINUX_ARM64 - "linux_arm64_host_tools/lib" - #else - "linux_host_tools/lib" - #endif + #ifdef KOALA_LINUX_ARM64 + "linux_arm64_host_tools/lib" + #else + "linux_host_tools/lib" + #endif #elif KOALA_MACOS - "macos_host_tools/lib" + "macos_host_tools/lib" #elif KOALA_WINDOWS - "_host_tools/lib" - #elif KOALA_OHOS - "ohos_arm64/lib" + "_host_tools/lib" + #elif KOALA_OHOS_ARM64 + "arm64" + #elif KOALA_OHOS_ARM32 + "arm" #else - #error "Unknown platform" + #error "Unknown platform" #endif , + + // lib #if defined(__arm) - "etsnative.z", + "etsnative.z" #else - "arkruntime", + "arkruntime" #endif - "ETS_CreateVM", + , + + // createVM + "ETS_CreateVM" }; #endif @@ -159,9 +169,9 @@ extern "C" DLL_EXPORT KInt LoadVirtualMachine(KInt vmKind, const char* appClassP LOGI("Starting VM %" LOG_PUBLIC "d with classpath=%" LOG_PUBLIC "s native=%" LOG_PUBLIC "s", vmKind, appClassPath, appLibPath); std::string libPath = -#if defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_WINDOWS) +#if defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_WINDOWS) || defined (KOALA_OHOS_ARM64) std::string(thisVM->sdkPath) + "/" + std::string(thisVM->platform) + "/" + libName(thisVM->lib) -#elif defined(KOALA_OHOS) +#elif defined(KOALA_OHOS_ARM32) libName(thisVM->lib) #else #error "Library path not specified for this platform" @@ -211,15 +221,12 @@ extern "C" DLL_EXPORT KInt LoadVirtualMachine(KInt vmKind, const char* appClassP traverseDir(std::string(appClassPath), files); std::sort(files.begin(), files.end()); etsVMOptions = { -#if defined(KOALA_LINUX) +#if defined(KOALA_LINUX) || defined(KOALA_OHOS_ARM32) {EtsOptionType::ETS_BOOT_FILE, (char*)strdup((std::string(thisVM->sdkPath) + "/ets/etsstdlib.abc").c_str())}, -#endif -#if defined(KOALA_OHOS) -#if defined(__arm) || defined(__aarch64__) - {EtsOptionType::ETS_BOOT_FILE, (char*)strdup((std::string(thisVM->sdkPath) + "/etc/etsstdlib.abc").c_str())}, -#endif #endif }; + etsVMOptions.push_back({EtsOptionType::ETS_NO_JIT, nullptr}); + etsVMOptions.push_back({EtsOptionType::ETS_LOG_LEVEL, "debug"}); for (const std::string& path : files) { etsVMOptions.push_back({EtsOptionType::ETS_BOOT_FILE, (char*)strdup(path.c_str())}); } @@ -294,7 +301,7 @@ extern "C" DLL_EXPORT KNativePointer StartApplication(const char* appUrl, const return nullptr; } - LOGI("#### Starting app %" LOG_PUBLIC "s with params %" LOG_PUBLIC "s", appUrl, appParams); + LOGI("Starting app %" LOG_PUBLIC "s with params %" LOG_PUBLIC "s", appUrl, appParams); #ifdef KOALA_JNI if (g_vmEntry.vmKind == JAVA_VM_KIND) { @@ -428,6 +435,10 @@ extern "C" DLL_EXPORT void EmitEvent(const KInt type, const KInt target, const K #ifdef KOALA_JNI if (g_vmEntry.vmKind == JAVA_VM_KIND) { JNIEnv* jEnv = (JNIEnv*)(g_vmEntry.env); + if (!g_vmEntry.emitEvent) { + LOG("#### Cannot find emitEvent method"); + return; + } jEnv->CallVoidMethod( (jobject)(g_vmEntry.app), (jmethodID)(g_vmEntry.emitEvent), @@ -493,6 +504,7 @@ void traverseDir(std::string root, std::vector& paths, int depth) { int rv = stat(filepath.c_str(), &statbuf); if (rv < 0) continue; if (filepath.size() >= suffix.size() && filepath.substr(filepath.size() - suffix.size()) == suffix && (statbuf.st_mode & S_IFMT) == S_IFREG) { + LOGE("testtest find %" LOG_PUBLIC "s", filepath.c_str()); paths.push_back(filepath); } if ((statbuf.st_mode & S_IFMT) == S_IFDIR) {