1#!/bin/bash 2# Copyright (c) 2023 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. 14 15set -e 16 17declare SCRIPT_PATCH 18declare SYSROOT 19declare PREFIX 20declare TARGET_CPU 21declare TARGET_GEN_DIR 22declare TARGET_PLATFORM 23declare JS_ENGINE_URL 24declare DEPENDENCY_TAG 25 26export SCRIPT_PATCH=$(dirname $(readlink -f "$0")) 27 28source ${SCRIPT_PATCH}/build_jsvm_inter.sh 29 30options="$(getopt -o h "help,sysroot:,jsvm_path:,prefix:,target_cpu:,base_path:" -- "$@")" || usage 31 32eval set -- "$options" 33 34usage() { 35 echo "Tool $(basename "$0") Usage" 36 echo "Options:" 37 echo "-h|--help" 38 echo "--sysroot <path> Sysroot path." 39 echo "--prefix <perfix> Cross-compiler prefix." 40 echo "--target_cpu <arm/arm64> Cross-compile CPU types." 41 echo "--target_gen_dir <output path>" 42 echo " if target_gen_dir not set, will install only to the default path." 43 exit 0 44} 45 46die() { 47 echo $@ 48 exit 0 49} 50 51do_man_process() { 52 do_opt_process $@ 53 if [[ "${IS_ASAN}" = "true" && "${USE_HWASEN}" = "true" ]]; then 54 do_env 1 55 do_fetch > ${out_dir}/log.do_fetch_asan_unstripped 56 do_patch > ${out_dir}/log.do_patch_asan_unstripped 57 do_configure > ${out_dir}/log.do_configure_asan_unstripped 58 do_compile > ${out_dir}/log.do_compile_asan_unstripped 59 do_install_asan > ${out_dir}/log.do_install_asan_unstripped 60 else 61 do_env 0 62 do_fetch > ${out_dir}/log.do_fetch 63 do_patch > ${out_dir}/log.do_patch 64 do_configure > ${out_dir}/log.do_configure 65 do_compile > ${out_dir}/log.do_compile 66 do_install > ${out_dir}/log.do_install 67 do_strip 68 69 do_env 1 70 do_fetch > ${out_dir}/log.do_fetch_unstripped 71 do_patch > ${out_dir}/log.do_patch_unstripped 72 do_configure > ${out_dir}/log.do_configure_unstripped 73 do_compile > ${out_dir}/log.do_compile_unstripped 74 do_unstripped_copy 75 fi 76} 77 78do_opt_process() { 79 while [[ $# -gt 0 ]]; do 80 case "$1" in 81 -h|--help) 82 usage 83 ;; 84 --sysroot) 85 export SYSROOT=$2 86 shift 87 ;; 88 --jsvm_path) 89 export JSVM_PATH=$2 90 shift 91 ;; 92 --prefix) 93 export PREFIX=$2 94 export JS_ENGINE_URL=${PREFIX=}/../.. 95 shift 96 ;; 97 --target_cpu) 98 export TARGET_CPU=$2 99 shift 100 ;; 101 --target_platform) 102 export TARGET_PLATFORM=$2 103 shift 104 ;; 105 --target_gen_dir) 106 export TARGET_GEN_DIR=$2 107 shift 108 ;; 109 --target_clang_coverage) 110 export TARGET_CLANG_COVERAGE=$2 111 shift 112 ;; 113 --is_asan) 114 export IS_ASAN=$2 115 shift 116 ;; 117 --use_hwasan) 118 export USE_HWASEN=$2 119 shift 120 ;; 121 --cmake_path) 122 export CMAKE_PATH=$2 123 shift 124 ;; 125 --target_out_dir) 126 export LIB_ROOT_DIR=$2 127 shift 128 ;; 129 --dependency_tag) 130 export DEPENDENCY_TAG=$2 131 shift 132 ;; 133 -I*) 134 export INCLUDE_DIRS="${INCLUDE_DIRS} -I${LIB_ROOT_DIR}/${1#-I}" 135 ;; 136 *) 137 ;; 138 esac 139 shift 140 done 141} 142 143do_man_process $@ 144