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