1#!/bin/bash 2# Copyright (c) 2022 Huawei Device Co., Ltd. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14set -e 15clear 16 17echo "++++++++++++++++++++++++++++++++++++++++" 18date +%F' '%H:%M:%S 19echo $@ 20echo "++++++++++++++++++++++++++++++++++++++++" 21echo 22 23source_root_dir=$(cd $(dirname $0);pwd) 24 25if [[ "${source_root_dir}x" == "x" ]]; then 26 echo "Error: source_root_dir cannot be empty." 27 exit 1 28fi 29 30case $(uname -s) in 31 Darwin) 32 HOST_DIR="darwin-x86" 33 HOST_OS="mac" 34 ;; 35 Linux) 36 HOST_DIR="linux-x86" 37 HOST_OS="linux" 38 ;; 39 *) 40 echo "Unsupported host platform: $(uname -s)" 41 RET=1 42 exit $RET 43esac 44 45export PATH=${source_root_dir}/prebuilts/build-tools/${HOST_DIR}/bin:$PATH 46 47tools="${source_root_dir}/prebuilts/build-tools/${HOST_DIR}/bin" 48ark_root="out/ark" 49add_path="out:${source_root_dir}/prebuilts/clang/ohos/linux-x86_64/llvm/lib" 50 51 52if [ "$1" = "c" ] 53then 54 echo "clear out !" 55 rm -rf out *.log test.abc test test.js gen.sh .gn 56elif [ "$1" = "log" ] 57then 58 $tools/gn gen out 59 cd out/ 60 $tools/ninja all -v | tee ../xxx.log 61 cd .. 62elif [ "$1" = "abc" ] 63then 64 export LD_LIBRARY_PATH=$add_path 65 ./$ark_root/ark/es2abc test.js 66elif [ "$1" = "." ] 67then 68 export LD_LIBRARY_PATH=$add_path 69 ./$ark_root/ark_js_runtime/ark_js_vm test.abc 70elif [ "$1" = "all" ] 71then 72 export LD_LIBRARY_PATH=$add_path 73 ./$ark_root/ark/es2abc test.js 74 ./$ark_root/ark_js_runtime/ark_js_vm test.abc 75elif [ "$1" = "ark" ] 76then 77 export SCRIPT_ROOT_DIR=$(cd $(dirname $0);pwd) #获取sh脚本绝对路径 78 cp -r $SCRIPT_ROOT_DIR/* $SCRIPT_ROOT_DIR/.gn ./ 79 echo "cp -r build/compile_script/* ./" 80else 81 $tools/gn gen out 82 cd out/ 83 $tools/ninja all 84 cd .. 85 echo 86 echo -e "\033[32m + c == clear out !\033[0m" 87 echo -e "\033[32m + . == execute test.abc !\033[0m" 88 echo -e "\033[32m + abc == get test.abc !\033[0m" 89 echo -e "\033[32m + all == all !\033[0m" 90 echo -e "\033[32m + ark == cp tools !\033[0m" 91fi 92 93echo 94echo "++++++++++++++++++++++++++++++++++++++++" 95echo -e "\033[32m=====$@ successful=====\033[0m" 96 97date +%F' '%H:%M:%S 98echo "++++++++++++++++++++++++++++++++++++++++"