Description: provide runtime-core snapshot converting tool

IssueNo:I43RE7
Feature or Bugfix: Feature
Binary Source:No

Signed-off-by: jiadexiang <jiadexiang@huawei.com>
This commit is contained in:
jiadexiang
2021-08-03 21:45:49 +08:00
parent faebf8b698
commit ad4eb49392
4 changed files with 72 additions and 38 deletions
+1
View File
@@ -9,3 +9,4 @@ node_modules/
frameworks/tools/qt/build-simulator*
frameworks/tools/qt/simulator/font/
frameworks/tools/qt/simulator/simulator.pro.user
frameworks/packages/runtime-core/jerryscript
@@ -0,0 +1,45 @@
#!/bin/bash
#Copyright (c) 2020-2021 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.
set -e
echo "=================================================="
echo "== this tool is just for linux host environment =="
echo "== prerequires: node.js and python3 installed =="
echo "=================================================="
# step 1: npm install and build
npm install
npm run build
# step 2: clone jerryscript repo
rm -rf jerryscript
git clone git@gitee.com:openharmony/third_party_jerryscript.git jerryscript
# step 3: reset the commit to the 2.1.0 tag
pushd ./jerryscript
git reset --hard e8bc7a2b93a6edfa463458c8bb69fac2a36feb9e
# step 4: compile jerry snapshot tool
python tools/build.py --mem-heap=64 --snapshot-exec=ON --snapshot-save=ON \
--profile=es5.1 --error-messages=ON --logging=ON --mem-stats=ON \
--jerry-cmdline-snapshot=ON
# step 5: convert framework.min.js to byte code file
popd
./jerryscript/build/bin/jerry-snapshot generate -o ./build/framework.min.bc ./build/framework.min.js
echo "snapshot generating done."
# step 6: convert framework.min.js and framework.min.bc into C files
python3 ./../../tools/snapshot/framework2char.py
@@ -1,36 +1,24 @@
/*
* Copyright (c) 2020 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.
*/
# How to contribute to the runtime-core of JS framework
## 1. Modify code
## 2. Compile the framework itself
> npm install
> npm run build
you will get the **framework.min.js** output under `runtime-core/build` folder
## 3. Prepare the snapshot tool
run `ace_lite_jsfwk/tools/snapshot/jerry-bin/build_jerry.sh`, the `jerry-snapshot` tool will be generated into `ace_lite_jsfwk/tools/snapshot/jerry-bin/linux/`.
## 4. Generate framework.min.bc
> cd packages/runtime-core/build/
> ./../../../tools/snapshot/jerry_bin/linux/jerry-snapshot generate -o framework.min.bc ./framework.min.js
## 5. Update the JS and snapshot array in C++ code
> cd tools/snapshot/
> python framework2char.py
## 6. add changed file to git
> git add src/core/base/framework_min_js.h
> git add src/core/base/framework_min_bc.h
/*
* Copyright (c) 2020-2021 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.
*/
# How to contribute to the runtime-core of JS framework
## 1. Modify code
## 2. run the build-core.sh file
> cd ace_engine_lite/frameworks/packages/runtime-core/
> ./build_core.sh
## 3. add following two C header files to git and upload them to your PR
> git add src/core/base/framework_min_js.h
> git add src/core/base/framework_min_bc.h
+2 -2
View File
@@ -33,7 +33,7 @@ JS_OUTPUT_C_FILE_PATH = os.path.join(
def output_copyright(output):
output.write("/*\n")
output.write(" * Copyright (c) 2020 Huawei Device Co., Ltd.\n")
output.write(" * Copyright (c) 2020-2021 Huawei Device Co., Ltd.\n")
output.write(" * Licensed under the Apache License, Version 2.0")
output.write(" (the \"License\");\n")
output.write(" * you may not use this file except in compliance ")
@@ -57,7 +57,7 @@ def output_copyright(output):
def output_check_notes(output):
output.write("// AUTO GENERATED, PLEASE DO NOT EDIT DIRECTLY\n")
output.write("#include <stdint.h>\n\n")
output.write("#include <cstdint>\n\n")
output.write("#ifndef ACELITE_FRAMEWORK_RAW_BUFFER\n")
output.write("#error THIS FILE CAN ONLY BE INCLUDED BY RAW BUFFER CPP\n")
output.write("#endif\n\n")