mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 01:03:08 +00:00
uicontext.abc fix
Signed-off-by: fangzhiyuan <fangzhiyuan5@huawei.com> Change-Id: I87c7e9f934666ed2079b0ecab56c03247fe359f2
This commit is contained in:
parent
90d32f7b5e
commit
d6a94ed92d
@ -106,6 +106,7 @@ if (is_ohos_standard_system) {
|
||||
deps = [
|
||||
"$ace_root/frameworks/bridge/declarative_frontend:ark_modifier",
|
||||
"$ace_root/frameworks/bridge/declarative_frontend:ark_theme_control",
|
||||
"$ace_root/frameworks/bridge/declarative_frontend:uicontext",
|
||||
"$ace_root/frameworks/bridge/declarative_frontend:x_node",
|
||||
]
|
||||
out_path = get_label_info(
|
||||
@ -115,6 +116,7 @@ if (is_ohos_standard_system) {
|
||||
"${out_path}/arkui/ace_engine/modifier.abc",
|
||||
"${out_path}/arkui/ace_engine/node.abc",
|
||||
"${out_path}/arkui/ace_engine/theme.abc",
|
||||
"${out_path}/arkui/ace_engine/uicontext.abc",
|
||||
]
|
||||
|
||||
outputs = [ target_out_dir +
|
||||
|
52
build/tools/gen_uicontext_ohos.py
Executable file
52
build/tools/gen_uicontext_ohos.py
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# 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.
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def main(input_path, output_path):
|
||||
with open(output_path, "w", encoding="utf-8") as ohos:
|
||||
export_content = "export default { "
|
||||
with open(input_path, "r", encoding="utf-8") as f:
|
||||
line = f.readline()
|
||||
isFirstClass = True
|
||||
class_num = 0
|
||||
while (line):
|
||||
ohos.write(line)
|
||||
if (line.startswith("class ")):
|
||||
class_num += 1
|
||||
if class_num % 5 == 0:
|
||||
class_num = 0
|
||||
isFirstClass = True
|
||||
export_content += ",\n\t"
|
||||
|
||||
class_name = re.match(r"class\s+(\w+)", line).group(1)
|
||||
if isFirstClass:
|
||||
isFirstClass = False
|
||||
else:
|
||||
export_content += ", "
|
||||
export_content += class_name
|
||||
line = f.readline()
|
||||
ohos.write("\n")
|
||||
export_content += " };\n"
|
||||
export_content += "globalThis.__getUIContext__ = __getUIContext__;\n"
|
||||
export_content += "globalThis.__getFrameNodeByNodeId__ = __getFrameNodeByNodeId__;\n"
|
||||
export_content += "globalThis.__checkRegexValid__ = __checkRegexValid__;"
|
||||
ohos.write("\n" + export_content)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1], sys.argv[2])
|
@ -181,7 +181,6 @@ template("declarative_js_engine") {
|
||||
":gen_obj_src_ark_theme",
|
||||
":gen_obj_src_js_enum_style",
|
||||
":gen_obj_src_js_proxyclass",
|
||||
":gen_obj_src_js_uicontext",
|
||||
":mock",
|
||||
":prefetcher",
|
||||
":shape",
|
||||
@ -190,6 +189,12 @@ template("declarative_js_engine") {
|
||||
"engine/$engine_path:declarative_js_engine_bridge_${engine_name}_$platform",
|
||||
]
|
||||
|
||||
if (!is_arkui_x) {
|
||||
deps += [ ":uicontext" ]
|
||||
} else {
|
||||
deps += [ ":gen_obj_src_js_uicontext" ]
|
||||
}
|
||||
|
||||
configs = [ "$ace_root:ace_config" ]
|
||||
if (ace_engine_feature_enable_point_light) {
|
||||
defines += [ "POINT_LIGHT_ENABLE" ]
|
||||
@ -709,7 +714,6 @@ template("declarative_js_engine_ng") {
|
||||
":gen_obj_src_ark_theme",
|
||||
":gen_obj_src_js_enum_style",
|
||||
":gen_obj_src_js_proxyclass",
|
||||
":gen_obj_src_js_uicontext",
|
||||
":mock",
|
||||
":prefetcher",
|
||||
":shape",
|
||||
@ -718,6 +722,12 @@ template("declarative_js_engine_ng") {
|
||||
"engine/$engine_path:declarative_js_engine_bridge_${engine_name}_$platform",
|
||||
]
|
||||
|
||||
if (!is_arkui_x) {
|
||||
deps += [ ":uicontext" ]
|
||||
} else {
|
||||
deps += [ ":gen_obj_src_js_uicontext" ]
|
||||
}
|
||||
|
||||
configs = [ "$ace_root:ace_config" ]
|
||||
|
||||
sources = [
|
||||
@ -1163,6 +1173,28 @@ ohos_abc("prefetcher") {
|
||||
part_name = ace_engine_part
|
||||
}
|
||||
|
||||
action("gen_uicontext_ohos") {
|
||||
script = "$ace_root/build/tools/gen_uicontext_ohos.py"
|
||||
inputs = [
|
||||
"$ace_root/frameworks/bridge/declarative_frontend/engine/jsUIContext.js",
|
||||
]
|
||||
outputs = [ "$base_output_path/jsUIContext_ohos.js" ]
|
||||
args = [
|
||||
rebase_path(inputs[0]),
|
||||
rebase_path(outputs[0]),
|
||||
]
|
||||
}
|
||||
|
||||
ohos_abc("uicontext") {
|
||||
sources = [ "$base_output_path/jsUIContext_ohos.js" ]
|
||||
output_name = "uicontext"
|
||||
deps = [ ":gen_uicontext_ohos" ]
|
||||
install_images = [ "system" ]
|
||||
module_install_dir = "etc/abc/arkui"
|
||||
subsystem_name = ace_engine_subsystem
|
||||
part_name = ace_engine_part
|
||||
}
|
||||
|
||||
ohos_abc("ark_theme_control") {
|
||||
sources = [ "engine/arkThemeControl.js" ]
|
||||
output_name = "theme"
|
||||
|
20
frameworks/bridge/declarative_frontend/engine/jsPreload.js
Normal file
20
frameworks/bridge/declarative_frontend/engine/jsPreload.js
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
if (globalThis.requireNapi === undefined) {
|
||||
const UIContext = globalThis.requireNapiPreview('arkui.uicontext');
|
||||
} else {
|
||||
const UIContext = globalThis.requireNapi('arkui.uicontext');
|
||||
}
|
@ -21,6 +21,7 @@ base_output_path = get_label_info(":gen_abc_proxyclass", "target_out_dir")
|
||||
abcproxyclass_obj_path = base_output_path + "/abc_proxy_class.o"
|
||||
abcenumstyle_obj_path = base_output_path + "/abc_enum_style.o"
|
||||
abcuicontext_obj_path = base_output_path + "/abc_uicontext.o"
|
||||
abcpreload_obj_path = base_output_path + "/abc_preload.o"
|
||||
jsmocksystemplugin_obj_path = base_output_path + "/abc_js_mock_system_plugin.o"
|
||||
arkTheme_obj_path = base_output_path + "/abc_ark_theme.o"
|
||||
arkcomponent_obj_path = base_output_path + "/abc_ark_component.o"
|
||||
@ -65,6 +66,16 @@ es2abc_gen_abc("gen_jsUIContext_abc") {
|
||||
out_puts = [ base_output_path + "/jsUIContext.abc" ]
|
||||
}
|
||||
|
||||
es2abc_gen_abc("gen_jsPreload_abc") {
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(
|
||||
"//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsPreload.js")
|
||||
dst_file = rebase_path(base_output_path + "/jsPreload.abc")
|
||||
|
||||
in_puts = [ "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsPreload.js" ]
|
||||
out_puts = [ base_output_path + "/jsPreload.abc" ]
|
||||
}
|
||||
|
||||
es2abc_gen_abc("gen_arkComponent_abc") {
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(
|
||||
@ -126,6 +137,15 @@ gen_obj("abc_uicontext") {
|
||||
snapshot_dep = [ ":gen_jsUIContext_abc" ]
|
||||
}
|
||||
|
||||
gen_obj("abc_preload") {
|
||||
input = base_output_path + "/jsPreload.abc"
|
||||
if (use_mac || use_mingw_win || use_linux || use_ios) {
|
||||
abcpreload_obj_path = base_output_path + "/jsPreload.c"
|
||||
}
|
||||
output = abcpreload_obj_path
|
||||
snapshot_dep = [ ":gen_jsPreload_abc" ]
|
||||
}
|
||||
|
||||
gen_obj("abc_ark_component") {
|
||||
input = base_output_path + "/arkComponent.abc"
|
||||
if (use_mac || use_mingw_win || use_ios || use_linux) {
|
||||
@ -428,9 +448,14 @@ template("declarative_js_engine_ark") {
|
||||
":gen_obj_src_abc_ark_theme",
|
||||
":gen_obj_src_abc_enum_style",
|
||||
":gen_obj_src_abc_proxyclass",
|
||||
":gen_obj_src_abc_uicontext",
|
||||
]
|
||||
|
||||
if (is_arkui_x) {
|
||||
deps += [ ":gen_obj_src_abc_uicontext" ]
|
||||
} else {
|
||||
deps += [ ":gen_obj_src_abc_preload" ]
|
||||
}
|
||||
|
||||
foreach(item, abc_sources) {
|
||||
deps += [ ":copy_" + item + "_abc" ]
|
||||
}
|
||||
|
@ -84,6 +84,10 @@ extern const char _binary_jsEnumStyle_abc_start[];
|
||||
extern const char _binary_jsUIContext_abc_start[];
|
||||
extern const char _binary_arkComponent_abc_start[];
|
||||
extern const char _binary_arkTheme_abc_start[];
|
||||
#if !defined(ANDROID_PLATFORM) && !defined(IOS_PLATFORM)
|
||||
extern const char _binary_jsPreload_abc_start[];
|
||||
extern const char _binary_jsPreload_abc_end[];
|
||||
#endif
|
||||
#if !defined(IOS_PLATFORM)
|
||||
extern const char _binary_stateMgmt_abc_end[];
|
||||
extern const char _binary_jsEnumStyle_abc_end[];
|
||||
@ -199,8 +203,13 @@ inline bool PreloadStateManagement(const shared_ptr<JsRuntime>& runtime)
|
||||
|
||||
inline bool PreloadUIContent(const shared_ptr<JsRuntime>& runtime)
|
||||
{
|
||||
#if defined(ANDROID_PLATFORM) || defined(IOS_PLATFORM)
|
||||
uint8_t* codeStart = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(_binary_jsUIContext_abc_start));
|
||||
int32_t codeLength = _binary_jsUIContext_abc_end - _binary_jsUIContext_abc_start;
|
||||
#else
|
||||
uint8_t* codeStart = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(_binary_jsPreload_abc_start));
|
||||
int32_t codeLength = _binary_jsPreload_abc_end - _binary_jsPreload_abc_start;
|
||||
#endif
|
||||
return runtime->EvaluateJsCode(codeStart, codeLength);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user