diff --git a/arkoala-cj/doc/LANGUAGE.md b/arkoala-cj/doc/LANGUAGE.md index 0e0527a36874153a5998425e598834c651493dca..21ccd98151f13f7cd69d992e4abfec4b203d527d 100644 --- a/arkoala-cj/doc/LANGUAGE.md +++ b/arkoala-cj/doc/LANGUAGE.md @@ -112,4 +112,75 @@ Variant `ui2()` is very straightforward for users, but requires the following la Coloring detection for the declaration side can be inferred from the signature (presence of first parameter of type `UI` for variant 1, requires AST-only interface), or by traversing from usage to declaration (requires type-checker interface) for variant 2. -TODO: define how to provide styling parameter! Must be thought in conjunction with literals functionality in CJ. \ No newline at end of file +## Proposal as per discussion with CJ team + +### Suggested DSL shape + +```rust +open class Style { + Style(let width: ?Int) {} +} + +class ButtonStyle <: Style { + ButtonStyle(width: ?Int, let border!: ?Int = None, let corners!: ?Int) { + // TODO: how to construct super() properly? + super(width = width) + } +} + +class ColumnStyle <: Style { + ColumnStyle(width: ?Int, let gap!: ?Int) { + super(width = width) + } +} + +@Memo +func Button(title: String, style: ?ButtonStyle, content!: () -> Unit) { +} + +@Memo +func Column(style: ?ColumnStyle, content!: () -> Unit) { +} + +// Invocation. +Column(style = ColumnStyle(gap = 5)) { + // Would be great to remove empty `{}` + Button("One") {} + Button("Two", style: ButtonStyle(corners: 3, border: 1)) { + Button("Inner") {} + } +} +``` + +### Suggested implementation + + Until late macros are available, we use `@Memo` as coloring macro, and use external type +inference mechanism relying upon CJ parser library or CJ LSP to map usage to declaration, +to decide if rewrite shall happen. This data is present in memory-only, and no explicit unmemoization step happens. + + If sufficiently functional late macro will be provided, we can switch to that mechanism +to detect if rewrite shall happen and avoid intermediate source code. + + We also need explicit `func callerId(): Int` intrinsic, with the property that + + ```rust +func a(): Unit { + println(callerId()) +} + +func b() { + // Different values are printed. + a() + a() +} + +func c() { + for (i in 0..2) { + // Same value printed on each iteration. + a() + } +} +``` + +If some improved syntax (a la JSON) for instatiation of style object instances is provided - +that would make DSL prettier, but even with current language features it's OKish. \ No newline at end of file diff --git a/arkoala/framework/native/meson.build b/arkoala/framework/native/meson.build index 9008c3fcf94284abc967b79cd13cfdbe45e2c06c..7124d766595a55528534281985dacd828f34d08c 100644 --- a/arkoala/framework/native/meson.build +++ b/arkoala/framework/native/meson.build @@ -6,7 +6,7 @@ project('ArkoalaNative', 'c', 'cpp', source_dir = meson.current_source_dir() interop_src = '../../../interop/src/cpp' -oses = { 'emscripten': 'wasm', 'darwin': 'macos' } # rename meson default names to convenient ones +oses = { 'darwin': 'macos' } # rename meson default names to convenient ones archs = { 'x86_64': 'x64', 'aarch64': 'arm64', 'wasm32': 'wasm' } fs = import('fs') @@ -33,24 +33,19 @@ include_dirs = [ ] fs = import('fs') -node_headers = '../../node_modules' -if not fs.is_dir(node_headers / 'node-addon-api') - node_headers = '../../../../node_modules' +napi_headers = '../../node_modules' +if not fs.is_dir(napi_headers / 'node-addon-api') + napi_headers = '../../../../node_modules' endif -node_include_dirs = [ - node_headers / 'node-api-headers/include', - node_headers / 'node-addon-api' -] - -is_msvc = meson.get_compiler('cpp').get_id() == 'msvc' -is_napi = get_option('vm_kind') == 'node' or get_option('vm_kind') == 'arkjs' -is_etsapi = get_option('vm_kind') == 'arkts' -is_jni = get_option('vm_kind') == 'jvm' is_node = get_option('vm_kind') == 'node' -is_ark_js = get_option('vm_kind') == 'arkjs' -is_ark_ets = get_option('vm_kind') == 'arkts' +is_hzvm = get_option('vm_kind') == 'hzvm' +is_panda = get_option('vm_kind') == 'panda' is_jvm = get_option('vm_kind') == 'jvm' +is_msvc = meson.get_compiler('cpp').get_id() == 'msvc' +is_napi = is_node or is_hzvm +is_etsapi = is_panda +is_jni = is_jvm # To control if we use dummy or libace based implementation is_dummy_impl = is_node is_ohos = os == 'ohos' @@ -69,7 +64,7 @@ else if is_jni library_use_name += '_jni' endif - if is_ark_ets + if is_etsapi library_use_name += '_ark' endif interop_library_name = library_use_name @@ -88,7 +83,7 @@ if os == 'windows' if is_msvc and is_node # apply node.exe symbol loading hook sources += [ - interop_src / 'node' / 'win-dynamic-node.cc' + interop_src / 'napi' / 'win-dynamic-node.cc' ] endif # Strange, but true @@ -110,11 +105,6 @@ if os == 'macos' platform_suffix = 'dylib' endif if is_ohos - if is_napi - sources += [ - interop_src / 'arkts/napi-ark-stubs.cc' - ] - endif clang_flags = [ '-Wno-non-virtual-dtor', '-fno-rtti', @@ -142,59 +132,34 @@ if is_ohos platform_prefix = 'lib' platform_suffix = 'so' endif -if is_node + +if is_napi sources += [ - interop_src / 'node/convertors-node.cc', + interop_src / 'napi/convertors-napi.cc', ] include_dirs += [ - interop_src / 'node', + interop_src / 'napi', + napi_headers / 'node-api-headers/include', + napi_headers / 'node-addon-api' ] - include_dirs += node_include_dirs cflags += [ - '-DKOALA_USE_NODE_VM', '-DKOALA_NAPI', ] - module_prefix = '' - module_suffix = 'node' -endif -if is_ark_js - sources += [ - interop_src / 'node/convertors-node.cc', - interop_src / 'arkts/napi-ark-stubs.cc', - ] - include_dirs += [ - interop_src / 'node', - interop_src / 'arkts', - ] + node_include_dirs - cflags += [ - '-DKOALA_NAPI', - '-DKOALA_USE_ARK_VM=1', - '-DKOALA_USE_ARK_VM_WITH_JS=1', - ] - module_prefix = platform_prefix - module_suffix = platform_suffix endif -if is_ark_ets +if is_etsapi sources += [ - interop_src / 'arkts/convertors-ets.cc', + interop_src / 'ets/convertors-ets.cc', interop_src / 'types/signatures.cc', ] include_dirs += [ - interop_src / 'arkts', + interop_src / 'ets', interop_src / 'types', ] cflags += [ '-DKOALA_ETS_NAPI', - '-DKOALA_USE_ARK_VM', - '-DKOALA_USE_ARK_VM_WITH_ETS', ] - module_prefix = platform_prefix - module_suffix = platform_suffix endif if is_jni - cflags += [ - '-DKOALA_USE_JAVA_VM' - ] sources += [ interop_src / 'jni/convertors-jni.cc', interop_src / 'types/signatures.cc', @@ -211,11 +176,38 @@ if is_jni ] cflags += [ '-DKOALA_JNI', + ] +endif + +if is_node + cflags += [ + '-DKOALA_USE_NODE_VM', + ] + module_prefix = '' + module_suffix = 'node' +endif +if is_hzvm + cflags += [ + '-DKOALA_USE_HZ_VM', + ] + module_prefix = platform_prefix + module_suffix = platform_suffix +endif +if is_panda + cflags += [ + '-DKOALA_USE_PANDA_VM', + ] + module_prefix = platform_prefix + module_suffix = platform_suffix +endif +if is_jni + cflags += [ '-DKOALA_USE_JAVA_VM', ] module_prefix = platform_prefix module_suffix = platform_suffix endif + if is_dummy_impl cflags += [ '-DUSE_DUMMY_IMPL', diff --git a/arkoala/framework/native/meson_options.txt b/arkoala/framework/native/meson_options.txt index 45395e879ab3741374240dfe992b214903bcf063..d43e4b3024caeba9e21b7c74d1f8b89edc37649f 100644 --- a/arkoala/framework/native/meson_options.txt +++ b/arkoala/framework/native/meson_options.txt @@ -1,4 +1,4 @@ -option('vm_kind', type : 'string', value : 'node', +option('vm_kind', type : 'string', value : '', description : 'VM type') option('jdk_dir', type : 'string', value : '', description : 'A path to JDK root') diff --git a/arkoala/framework/native/src/arkoala-logging.h b/arkoala/framework/native/src/arkoala-logging.h index 2bde58b62ae2e59f8f3bdd8055d2ceddb5cc3bca..46b4300f703543939d369e8119a693ce8ec22053 100644 --- a/arkoala/framework/native/src/arkoala-logging.h +++ b/arkoala/framework/native/src/arkoala-logging.h @@ -3,7 +3,7 @@ #include #include -#if defined(KOALA_USE_ARK_VM) && defined(KOALA_OHOS) +#if defined(KOALA_USE_HZ_VM) && defined(KOALA_OHOS) #include "oh_sk_log.h" #define LOG(msg) OH_SK_LOG_INFO(msg); #define LOGI(msg, ...) OH_SK_LOG_INFO_A(msg, ##__VA_ARGS__); diff --git a/arkoala/framework/package.json b/arkoala/framework/package.json index c7cb0b3120f21e9f93ce2c398d3125369db783ed..a329fdfcf14ced8b7cbc30ed496785a4ac0adde3 100644 --- a/arkoala/framework/package.json +++ b/arkoala/framework/package.json @@ -24,24 +24,23 @@ }, "scripts": { "clean": "tsc -b . --clean && rimraf build dist lib generated native/build-* native/*.ini", - "configure:native-node-host": "cd native && meson setup build-node-host", + "configure:native-node-host": "cd native && meson setup -D vm_kind=node build-node-host", "compile:native-node-host": "npm run configure:native-node-host && cd native && meson compile -C build-node-host && meson install -C build-node-host", - "configure:native-arkts-host": "cd native && meson setup -D vm_kind=arkts build-arkts-host", - "compile:native-arkts-host": "npm run configure:native-arkts-host && cd native && meson compile -C build-arkts-host && meson install -C build-arkts-host", - "configure:native-jni-host": "cd native && meson setup -D vm_kind=jvm build-jni-host -D jdk_dir=$JAVA_HOME", - "compile:native-jni-host": "npm run configure:native-jni-host && cd native && meson compile -C build-jni-host && meson install -C build-jni-host", - "configure:native-arkjs-host": "cd native && meson setup -D vm_kind=arkjs build-arkjs-host", - "compile:native-arkjs-host": "npm run configure:native-arkjs-host && cd native && meson compile -C build-arkjs-host && meson install -C build-arkjs-host", - "configure:native-arkjs-ohos-arm64": "npm run --prefix ../../../ohos-sdk download && cd native && node ../../../../skoala-bridges/scripts/configure.mjs arkjs-ohos-arm64 --reconfigure --vm_kind=arkjs", - "compile:native-arkjs-ohos-arm64": "npm run configure:native-arkjs-ohos-arm64 && cd native && meson compile -C build-arkjs-ohos-arm64 && meson install -C build-arkjs-ohos-arm64", - "configure:native-arkjs-ohos-arm32": "npm run --prefix ../ohos-sdk download && cd native && node ../scripts/configure.mjs arkjs-ohos-arm32 --reconfigure --vm_kind=arkjs", - "compile:native-arkjs-ohos-arm32": "npm run configure:native-arkjs-ohos-arm32 && cd native && meson compile -C build-arkjs-ohos-arm32 && meson install -C build-arkjs-ohos-arm32", - "configure:native-arkjs-ohos": "npm run configure:native-arkjs-ohos-arm64", - "compile:native-arkjs-ohos": "tsc -b . && npm run compile:native-arkjs-ohos-arm64", + "configure:native-hzvm-host": "cd native && meson setup -D vm_kind=hzvm build-hzvm-host", + "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", + "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 --prefix ../ohos-sdk download && 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", + "configure:native-hzvm-ohos-arm32": "npm run --prefix ../ohos-sdk download && cd native && node ../scripts/configure.mjs hzvm-ohos-arm64", + "compile:native-hzvm-ohos-arm32": "npm run configure:native-hzvm-ohos-arm32 && cd native && meson compile -C build-hzvm-ohos-arm32 && meson install -C build-hzvm-ohos-arm32", + "configure:native-hzvm-ohos": "npm run configure:native-hzvm-ohos-arm64", + "compile:native-hzvm-ohos": "tsc -b . && npm run compile:native-hzvm-ohos-arm64", "compile:node-host": "tsc -b . && npm run compile:native-node-host", "compile": "npm run compile:node-host", - "compile:arkjs-host": "tsc -b . && npm run compile:native-arkjs-host", - "compile:arkjs-ohos": "tsc -b . && npm run compile:native-arkjs-ohos", - "compile:arkts": "bash ../../../tools/panda/arkts/arktsc --arktsconfig arktsconfig.json" + "compile:hzvm-host": "tsc -b . && npm run compile:native-hzvm-host", + "compile:hzvm-ohos": "tsc -b . && npm run compile:native-hzvm-ohos" } } diff --git a/arkoala/framework/scripts/configure.mjs b/arkoala/framework/scripts/configure.mjs index ce9464e81a35a108712af66a389e7baf8c22503a..2335a14a1ae06d571d976392defa3b79f1895790 100644 --- a/arkoala/framework/scripts/configure.mjs +++ b/arkoala/framework/scripts/configure.mjs @@ -1,3 +1,6 @@ +// This is a simplified version of the original configure.mjs script, with only targers +// "hzvm-ohos-arm32" and "hzvm-ohos-arm64" + import fs from "fs"; import { exit, platform } from "process"; import chalk from "chalk"; @@ -19,22 +22,19 @@ const OHCONF = ohConf(path.join(__dirname, "../../ohos-sdk/.ohconf.json")) let cliOptions = minimist(process.argv.slice(2)) let targets = cliOptions._; -let help = cliOptions.h ||cliOptions.help || false; -let verbose = cliOptions.v ||cliOptions.verbose || false; -let reconfigure = cliOptions.reconfigure || false; -let wipe = cliOptions.wipe || false; +let help = cliOptions.h || cliOptions.help; +let verbose = cliOptions.v || cliOptions.verbose; +let reconfigure = cliOptions.reconfigure; +let wipe = cliOptions.wipe; let clean = cliOptions.clean; -let skiaDir = cliOptions["skia-dir"] || process.env.SKIA_DIR || ''; +let dryRun = cliOptions.n || cliOptions["dry-run"]; +let root = cliOptions.root || path.join(__dirname, "..") + let nodeDir = cliOptions["node-dir"] || process.env.NODE_DIR || ''; let nodeBuildType = cliOptions["node-buildtype"] || process.env.NODE_BUILDTYPE || "release"; -let skiaVersion = cliOptions["skia-version"] || process.env.SKIA_VERSION || ''; -let skiaDebug = cliOptions["skia-debug"] || !!process.env.SKIA_DEBUG || false; -let dryRun = !!(cliOptions.n || cliOptions["dry-run"]); -let vmKind = cliOptions.vm_kind || undefined -let root = cliOptions.root || path.join(__dirname, "..") -let arkBuildType = process.env.ARK_BUILDTYPE || "Release"; -let arkRuntimeOptions = process.env.ARK_RUNTIME_OPTIONS || "jit:aot"; +let pandaBuildType = process.env.PANDA_BUILDTYPE || "Release"; +let pandaRuntimeOptions = process.env.PANDA_RUNTIME_OPTIONS || "jit:aot"; if (targets.length === 0 || help) { usage(); @@ -43,20 +43,13 @@ if (targets.length === 0 || help) { const meson = findMeson(); -if (skiaDir && !path.isAbsolute(skiaDir)) { - console.log("SKIA_DIR must be an absolute path") - exit(1); -} - if (nodeDir && !path.isAbsolute(nodeDir)) { console.log("NODE_DIR must be an absolute path") exit(1); } -skiaDir && console.log(`SKIA_DIR: ${chalk.green(skiaDir)}`); nodeDir && console.log(`NODE_DIR: ${chalk.green(nodeDir)}`); console.log(`NODE_BUILDTYPE: ${chalk.green(nodeBuildType)}`); -skiaDebug && console.log(`SKIA_DEBUG: ${chalk.green('true')}`); targets.forEach(target => configure(target)); @@ -73,15 +66,6 @@ function getJdkRoot() { throw new Error("Cannot find JAVA_HOME") } -function getArkRuntime() { - if (process.env["ARK_RUNTIME"]) return process.env["ARK_RUNTIME"] - return "ets" -} - -function getPandaOhosSdkDir() { - return path.join(path.dirname(require.resolve("@panda/sdk")), 'ohos_arm64') -} - export function configure(target) { let buildDirName = `build-${target}`; @@ -103,13 +87,13 @@ export function configure(target) { let destDir = target; let binDir = target == "wasm" ? destDir : void 0; // Wasm output can be an executable only let libDir = target == "wasm" ? void 0 : destDir; + let vmKind = target.split('-')[0] const vsenv = process.platform === "win32" && target === "node-host" - const doConfigure = (isAndroid, isJvm, isEts, isOhos, ...crossFiles) => { + const doConfigure = (isJvm, ...crossFiles) => { verbose && console.log(`Configuring target ${chalk.bold(target)}\n`); try { - const isNode = !isJvm && !target.startsWith("jsc-"); meson.configure({ builddir: "build-" + target, prefix: path.resolve("../.runtime-prebuilt"), @@ -122,19 +106,8 @@ export function configure(target) { dryRun, vsenv, options: { - "ndk_dir": isAndroid ? getNdkRoot() : null, + "vm_kind": vmKind || undefined, "jdk_dir": isJvm ? getJdkRoot() : null, - "ark_runtime": isEts ? getArkRuntime() : null, - "ark_sdk_dir" : isEts ? getPandaOhosSdkDir() : null, - "ark_build_type" : isEts ? arkBuildType : null, - "ark_runtime_options": isEts ? arkRuntimeOptions : null, - "oh_sk_log_to_file": isOhos && !!process.env.KOALAUI_OHOS_LOG_TO_FILE ? "true" : null, - "skia:skia_dir": skiaDir && relativeToSourceRoot(skiaDir), - "skia:version": skiaVersion, - "skia:build_type": skiaDebug ? "Debug" : "Release", - "node:node_dir": isNode ? (nodeDir && relativeToSourceRoot(nodeDir)) : null, - "node:build_type": nodeBuildType, - "vm_kind": vmKind || undefined } }); verbose && console.log(); @@ -146,37 +119,9 @@ export function configure(target) { } switch (target) { - case "wasm": - doConfigure(false, false, false, false, createWasmCrossFile()); - break; - case "node-host": - doConfigure(false, false, false, false); - break; - case "jsc-ios-arm64": - case "jsc-ios-x64": - doConfigure(false, false, false, false, createIosCrossFile(target)); - break; - case "node-macos-arm64": - case "node-macos-x64": - doConfigure(false, false, false, false, createMacosCrossFile(target)); - break; - case "node-windows-clang-x64": - doConfigure(false, false, false, false, createWindowsClangCrossFile("x64")); - break; - case "node-android-x64": - case "node-android-arm64": - doConfigure(true, false, false, false, createAndroidCrossFile(target.substring(5))); - break; - case "arkjs-ohos-arm32": - case "ark-ohos-arm64": - case "arkjs-ohos-arm64": - doConfigure(false, false, false, true, createOhosCrossFile(target)); - break; - case "ets-ark-ohos-arm64": - doConfigure(false, false, true, true, createOhosCrossFile(target)); - break; - case "jni-host": - doConfigure(false, true); + case "hzvm-ohos-arm32": + case "hzvm-ohos-arm64": + doConfigure(false, createOhosCrossFile(target)); break; default: console.log(chalk.yellow("unsupported target '" + target + "'")); @@ -205,7 +150,7 @@ function createWasmCrossFile() { cpp: empp, ar: emar, }) - .section("host_machine", { + .section("target_machine", { system: 'emscripten', cpu_family: 'wasm32', cpu: 'wasm32', @@ -270,7 +215,7 @@ function createWindowsClangCrossFile(arch) { c_link_args: [...link_args], cpp_link_args: [...link_args], }) - .section("host_machine", { + .section("target_machine", { system: "windows", cpu_family: cpu, cpu: cpu, @@ -306,7 +251,7 @@ function createAndroidCrossFile(target) { cpp: path.join(compilersPath, cpu + "-linux-android28-clang++" + suffix), ar: path.join(compilersPath, "llvm-ar"), }) - .section("host_machine", { + .section("target_machine", { system: 'android', cpu_family: cpu, cpu: cpu, @@ -331,13 +276,13 @@ function createOhosCrossFile(target) { '--sysroot=' + path.resolve(path.join(sdkNativePath, 'sysroot')) ] let cpu = 'unknown' - if (target == 'ark-ohos-arm64' || target == 'arkjs-ohos-arm64' || target == 'ets-ark-ohos-arm64') { + if (target == 'hzvm-ohos-arm64') { cpu = 'aarch64' cflags = [ ...cflags, '--target=aarch64-linux-ohos' ] - } else if (target == 'arkjs-ohos-arm32') { + } else if (target == 'hzvm-ohos-arm32') { cpu = 'arm' cflags = [ ...cflags, @@ -360,7 +305,7 @@ function createOhosCrossFile(target) { cpp_args: cflags, cpp_link_args: cflags }) - .section("host_machine", { + .section("target_machine", { system: 'ohos', cpu_family: cpu, cpu: cpu, @@ -410,7 +355,7 @@ function createIosCrossFile(target) { objcpp_args: cflags, objcpp_link_args: cflags, }) - .section("host_machine", { + .section("target_machine", { system: 'ios', cpu_family: cpu, cpu: cpu, @@ -458,7 +403,7 @@ function createMacosCrossFile(target) { objcpp_args: cflags, objcpp_link_args: cflags, }) - .section("host_machine", { + .section("target_machine", { system: 'darwin', cpu_family: cpu, cpu: cpu, @@ -472,7 +417,7 @@ function createMacosCrossFile(target) { function usage() { console.log(`USAGE: node configure.mjs [OPTION]... TARGET [TARGET]... -TARGET = wasm | node-android-x64 | node-android-arm64 | jni-host | node-host | ark-ohos-arm64 | ark-ohos-arm32 | jsc-ios-arm64 | jsc-ios-x64 | node-macos-x64 | node-macos-arm64 compilation target +TARGET = wasm | node-android-x64 | node-android-arm64 | jni-host | node-host | hzvm-ohos-arm64 | hzvm-ohos-arm32 | jsc-ios-arm64 | jsc-ios-x64 | node-macos-x64 | node-macos-arm64 compilation target OPTIONS: -h, --help show this help and exit @@ -480,9 +425,6 @@ OPTIONS: -n, --dry-run do not emit files and do not perform meson configuring --wipe wipe build directory and reconfigure --reconfigure reconfigure build directory (use if options were changed) - --clean rmove build directory before configuring - --skia-dir=PATH use specific Skia root directory - --skia-version=VERSION download and link with specific Skia version - --skia-debug use Debug Skia version instead of release + --clean remove build directory before configuring `) } diff --git a/arkoala/framework/scripts/utils.mjs b/arkoala/framework/scripts/utils.mjs index b6be77f7abd383e372c936dd7d1754d16ff3f56f..a18455261f842f4de2ee8e4425f1396f151774bb 100644 --- a/arkoala/framework/scripts/utils.mjs +++ b/arkoala/framework/scripts/utils.mjs @@ -15,10 +15,6 @@ class Version { this.patch = patch; } - valueOf() { - return this.major * 1000 + this.minor * 1000 + this.patch; - } - toString() { return `${this.major}.${this.minor}.${this.patch}`; } @@ -120,9 +116,8 @@ class Meson { if (options.vm_kind) { args.push(`-Dvm_kind=${options.vm_kind}`); } - if (dryRun) { - console.log(`> meson ${args.join(' ')}`); - } else { + console.log(`> meson ${args.join(' ')}`); + if (!dryRun) { let stdio = options.verbose ? ['inherit', 'inherit', 'inherit'] : void 0; let env = process.env let meson = spawnSync("meson", args, { encoding: "utf8", stdio, env }); @@ -213,9 +208,7 @@ class CMake { } } console.log(`> cmake ${args.join(' ')}`); - if (dryRun) { - console.log(`> cmake ${args.join(' ')}`); - } else { + if (!dryRun) { let stdio = options.verbose ? ['inherit', 'inherit', 'inherit'] : void 0; let cmake = spawnSync("cmake", args, { encoding: "utf8", diff --git a/arkoala/har/package.json b/arkoala/har/package.json index dfa2adb1c07f1ea88ca8d8e038a0d4d82219b5b0..fa3f1b2011ca0d342da5276e8849c1f7e5d700b8 100644 --- a/arkoala/har/package.json +++ b/arkoala/har/package.json @@ -18,12 +18,12 @@ }, "scripts": { "clean": "rimraf app/arkoala/build app/arkoala/libs arkoala-har-bundle/dist ../arkui/build ../framework/build", - "copy": "mkdir -p app/arkoala/libs/arm64-v8a && cp ../framework/native/build-arkjs-ohos-arm64/libArkoalaNative.so app/arkoala/libs/arm64-v8a", - "copy:arm32": "mkdir -p app/arkoala/libs/armeabi-v7a && cp ../framework/native/build-arkjs-ohos-arm32/libArkoalaNative.so app/arkoala/libs/armeabi-v7a", + "copy": "mkdir -p app/arkoala/libs/arm64-v8a && cp ../framework/native/build-hzvm-ohos-arm64/libArkoalaNative.so app/arkoala/libs/arm64-v8a", + "copy:arm32": "mkdir -p app/arkoala/libs/armeabi-v7a && cp ../framework/native/build-hzvm-ohos-arm32/libArkoalaNative.so app/arkoala/libs/armeabi-v7a", "compile:arkoala": "npm run --prefix ../arkui compile && npm run --prefix ../../incremental/compat compile:ohos", "native:clean": "npm run --prefix ../framework clean", - "native:build": "npm run --prefix ../framework compile:native-arkjs-ohos", - "native:build-arm32": "npm run --prefix ../framework compile:native-arkjs-ohos-arm32", + "native:build": "npm run --prefix ../framework compile:native-hzvm-ohos", + "native:build-arm32": "npm run --prefix ../framework compile:native-hzvm-ohos-arm32", "bundle": "node scripts/build-arkoala-har.mjs", "build": "cd app && ./hvigorw --no-daemon --mode module -p product=default -p module=arkoala@default assembleHar", "arkoala:har": "npm run copy && npm run bundle && npm run build", diff --git a/interop/src/cpp/arkoala-logging.h b/interop/src/cpp/arkoala-logging.h index d0a4879525e163f56a2f5099eb46e0c39c5d428c..bec7aefda16e1af85d3b7baa1b197e824b091496 100644 --- a/interop/src/cpp/arkoala-logging.h +++ b/interop/src/cpp/arkoala-logging.h @@ -3,7 +3,7 @@ #include #include -#if defined(KOALA_USE_ARK_VM) && defined(KOALA_OHOS) +#if defined(KOALA_USE_HZ_VM) && defined(KOALA_OHOS) #include "oh_sk_log.h" #define LOG(msg) OH_SK_LOG_INFO(msg); #define LOGI(msg, ...) OH_SK_LOG_INFO_A(msg, ##__VA_ARGS__); diff --git a/interop/src/cpp/arkts/convertors-ark.h b/interop/src/cpp/arkts/convertors-ark.h deleted file mode 100644 index bd77074d77c05cd0c9c3c702a8d3119d9f8d692a..0000000000000000000000000000000000000000 --- a/interop/src/cpp/arkts/convertors-ark.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#pragma once - -#ifdef KOALA_USE_ARK_VM_WITH_JS -#include "convertors-node.h" - -#elif KOALA_USE_ARK_VM_WITH_ETS // !KOALA_USE_ARK_VM_WITH_JS - -#include "convertors-ets.h" - -#endif // KOALA_USE_ARK_VM_WITH_ETS diff --git a/interop/src/cpp/arkts/napi-ark-stubs.cc b/interop/src/cpp/arkts/napi-ark-stubs.cc deleted file mode 100644 index ba4c30e9a384eecad7cb5c4d5f3dc130ad0c6fdd..0000000000000000000000000000000000000000 --- a/interop/src/cpp/arkts/napi-ark-stubs.cc +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2022-2023 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 "napi.h" - -// ************************************************************** -// Deprecated (and not exported) functions in in libace_napi.z.so -// ************************************************************** - - -napi_status napi_close_callback_scope(napi_env env, napi_callback_scope scope) { - throw Napi::Error::New(env, "deprecated"); -} - -napi_status napi_async_destroy(napi_env env, napi_async_context async_context) { - throw Napi::Error::New(env, "deprecated"); -} - -napi_status napi_add_finalizer( - napi_env env, napi_value js_object, void* native_object, - napi_finalize finalize_cb, void* finalize_hint, napi_ref* result) -{ - throw Napi::Error::New(env, "deprecated"); -} diff --git a/interop/src/cpp/common-interop.h b/interop/src/cpp/common-interop.h index 21d1364c3f446a9a402f429e396eb2324d27baea..c37bdfb849fc98c97e033d9c2cde4b99d045c6a3 100644 --- a/interop/src/cpp/common-interop.h +++ b/interop/src/cpp/common-interop.h @@ -51,12 +51,12 @@ void appendGroupedLog(KInt kind, const std::string& str); const std::string& getGroupedLog(KInt kind); const KBoolean needGroupedLog(KInt kind); -#if defined KOALA_USE_NODE_VM -#include "convertors-node.h" -#elif defined KOALA_USE_JSC_VM +#if KOALA_USE_NODE_VM || KOALA_USE_HZ_VM +#include "convertors-napi.h" +#elif KOALA_USE_JSC_VM #include "convertors-jsc.h" -#elif KOALA_USE_ARK_VM -#include "convertors-ark.h" +#elif KOALA_USE_PANDA_VM +#include "convertors-ets.h" #elif KOALA_USE_JAVA_VM #include "convertors-jni.h" #elif KOALA_WASM diff --git a/interop/src/cpp/arkts/convertors-ets.cc b/interop/src/cpp/ets/convertors-ets.cc similarity index 100% rename from interop/src/cpp/arkts/convertors-ets.cc rename to interop/src/cpp/ets/convertors-ets.cc diff --git a/interop/src/cpp/arkts/convertors-ets.h b/interop/src/cpp/ets/convertors-ets.h similarity index 100% rename from interop/src/cpp/arkts/convertors-ets.h rename to interop/src/cpp/ets/convertors-ets.h diff --git a/interop/src/cpp/arkts/etsapi.h b/interop/src/cpp/ets/etsapi.h similarity index 100% rename from interop/src/cpp/arkts/etsapi.h rename to interop/src/cpp/ets/etsapi.h diff --git a/interop/src/cpp/node/convertors-node.cc b/interop/src/cpp/napi/convertors-napi.cc similarity index 99% rename from interop/src/cpp/node/convertors-node.cc rename to interop/src/cpp/napi/convertors-napi.cc index 19d445418de108c4443debf34fafd477d1bb4ff1..9406aac143eded0ae55f02a792335eb09f225d32 100644 --- a/interop/src/cpp/node/convertors-node.cc +++ b/interop/src/cpp/napi/convertors-napi.cc @@ -13,8 +13,7 @@ * limitations under the License. */ -#include "convertors-node.h" -#include "init-exports-cb.h" +#include "convertors-napi.h" #include // Adapter for NAPI_MODULE diff --git a/interop/src/cpp/node/convertors-node.h b/interop/src/cpp/napi/convertors-napi.h similarity index 100% rename from interop/src/cpp/node/convertors-node.h rename to interop/src/cpp/napi/convertors-napi.h diff --git a/interop/src/cpp/node/win-dynamic-node.cc b/interop/src/cpp/napi/win-dynamic-node.cc similarity index 99% rename from interop/src/cpp/node/win-dynamic-node.cc rename to interop/src/cpp/napi/win-dynamic-node.cc index 30e8b447a76613d782a324c16ce88fe48bb058c0..ca84143b497acff52b32cc5ae1c5c294e3daea01 100644 --- a/interop/src/cpp/node/win-dynamic-node.cc +++ b/interop/src/cpp/napi/win-dynamic-node.cc @@ -13,6 +13,7 @@ * limitations under the License. */ #include +#include #include #include "node_api.h" diff --git a/interop/src/cpp/node/init-exports-cb.h b/interop/src/cpp/node/init-exports-cb.h deleted file mode 100644 index 832f204a69a4fddf7a994ca6e6102f3d550bc735..0000000000000000000000000000000000000000 --- a/interop/src/cpp/node/init-exports-cb.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#ifndef _INIT_EXPORTS_CB_H_ -#define _INIT_EXPORTS_CB_H_ - -#include - -typedef void (*InitExportsCallback)(Napi::Env env, Napi::Object exports); -InitExportsCallback ProvideInitExportsCallback(InitExportsCallback cb); - -#endif // _INIT_EXPORTS_CB_H_ \ No newline at end of file diff --git a/interop/src/cpp/node/win-dll-hook.cc b/interop/src/cpp/node/win-dll-hook.cc deleted file mode 100644 index 8ac1a2dca01b77f7197d91fd3fb66616194b87d5..0000000000000000000000000000000000000000 --- a/interop/src/cpp/node/win-dll-hook.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ - -// Heavily inspired by node-gyp - -/* - * When this file is linked to a DLL, it sets up a delay-load hook that - * intervenes when the DLL is trying to load the host executable - * dynamically. Instead of trying to locate the .exe file it'll just - * return a handle to the process image. - * - * This allows compiled addons to work when the host executable is renamed. - */ - -#ifdef _MSC_VER - -#pragma managed(push, off) - -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#include - -#include -#include - - -static FARPROC WINAPI load_exe_hook(unsigned int event, PDelayLoadInfo info) { - if (event != dliNotePreLoadLibrary) { - return NULL; - } - - if (_stricmp(info->szDll, "node.exe") != 0) { - // Case-insensitive comparision is necessary - return NULL; - } - - HMODULE thisModule = GetModuleHandle(NULL); - return reinterpret_cast(thisModule); -} - -ExternC const PfnDliHook __pfnDliNotifyHook2 = load_exe_hook; - -#pragma managed(pop) - -#endif \ No newline at end of file diff --git a/interop/src/cpp/types/signatures.cc b/interop/src/cpp/types/signatures.cc index 9b10ba09759a6b933ed1bc98b5e576f615ca3e8f..0bbfc09a4faef520c7bd4e26107bb2f0bcd881db 100644 --- a/interop/src/cpp/types/signatures.cc +++ b/interop/src/cpp/types/signatures.cc @@ -56,7 +56,7 @@ KOALA_INTEROP_TYPEDEF_LS(func, lang, "KLength", "Lstd/core/String;", "String", "Ljava/lang/String;", "String") std::string sigType(const std::string &type) { -#if KOALA_USE_ARK_VM +#if KOALA_USE_PANDA_VM KOALA_INTEROP_TYPEDEFS("sigType", "ets") #elif KOALA_USE_JAVA_VM KOALA_INTEROP_TYPEDEFS("sigType", "jni") @@ -66,7 +66,7 @@ std::string sigType(const std::string &type) { } std::string codeType(const std::string &type) { -#if KOALA_USE_ARK_VM +#if KOALA_USE_PANDA_VM KOALA_INTEROP_TYPEDEFS("codeType", "ets") #elif KOALA_USE_JAVA_VM KOALA_INTEROP_TYPEDEFS("codeType", "jni") @@ -88,7 +88,7 @@ std::string convertType(const char* name, const char* koalaType) { } tokens.push_back(input.substr(last, input.length() - last)); -#if KOALA_USE_ARK_VM +#if KOALA_USE_PANDA_VM for (int i = 1; i < (int)tokens.size(); i++) { @@ -109,7 +109,7 @@ std::string convertType(const char* name, const char* koalaType) { #endif -#ifdef KOALA_USE_ARK_VM +#ifdef KOALA_USE_PANDA_VM if (false) { std::string params;