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