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    do_install   > ${out_dir}/log.do_install
56    do_strip
57}
58
59do_opt_process() {
60    while [[ $# -gt 0 ]]; do
61        case "$1" in
62        -h|--help)
63            usage
64            ;;
65        --sysroot)
66            export SYSROOT=$2
67            shift
68            ;;
69        --node_path)
70            export NODE_PATH=$2
71            shift
72            ;;
73        --prefix)
74            export PREFIX=$2
75            shift
76            ;;
77        --target_cpu)
78            export TARGET_CPU=$2
79            shift
80            ;;
81        --target_gen_dir)
82            export TARGET_GEN_DIR=$2
83            shift
84            ;;
85        --target_clang_coverage)
86            export TARGET_CLANG_COVERAGE=$2
87            shift
88            ;;
89        *)
90            ;;
91        esac
92        shift
93    done
94}
95
96do_man_process $@
97