• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# Copyright (c) 2023-2024 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 -eux
15set -o pipefail
16root_path=$1
17pack_build_out_jar_path=$2
18pack_build_out_path=$3
19toolchain=$4
20compile_java=$5
21fastjson_jar=$6
22final_path=$(pwd)
23
24jar_dir="jar"
25pack_jar_file="app_check_tool.jar"
26fastjson_jar_file="fastjson-1.2.83.jar"
27jar_directory="${root_path}/jar"
28pack_jar_path="${root_path}/${jar_dir}/${pack_jar_file}"
29manifest_path="${root_path}/META-INF/check_tool/MANIFEST.MF"
30css_path="${root_path}/adapter/ohos/scan_template.css"
31html_path="${root_path}/adapter/ohos/scan_template.html"
32
33out_dir="${root_path}/out/${toolchain}/check_tool"
34if [ -d "${out_dir}/ohos" ]
35    then
36        echo "${out_dir}/ohos exist"
37    else
38        mkdir -p "${out_dir}/ohos"
39fi
40
41compile_command="javac -source 1.8 -target 1.8 -cp ${fastjson_jar} -d ${out_dir} ${compile_java}"
42eval ${compile_command}
43
44temp_dir="$root_path/jar/check_temp_${toolchain}"
45if [ -d "${temp_dir}" ]
46    then
47        echo "${temp_dir} exit"
48    else
49        mkdir ${temp_dir}
50fi
51
52cd ${out_dir}
53cp ${css_path} ./ohos
54cp ${html_path} ./ohos
55product_pack_jar_command="jar -cvfm ${temp_dir}/${pack_jar_file} ${manifest_path} ./ohos"
56eval ${product_pack_jar_command}
57
58# merge app_packing_tool.jar and fastjson
59cp ${fastjson_jar} "${temp_dir}/${fastjson_jar_file}"
60detach_pack_jar_command="jar -xvf ${pack_jar_file}"
61detach_fastjson_jar_command="jar -xvf ${fastjson_jar_file}"
62cd ${temp_dir}
63eval ${detach_pack_jar_command}
64eval ${detach_fastjson_jar_command}
65rm ${pack_jar_file}
66rm ${fastjson_jar_file}
67
68cd ${jar_directory}
69temp_pack_jar_dir="${root_path}/jar/checktool_${toolchain}"
70temp_pack_jar_path="${root_path}/jar/checktool_${toolchain}/${pack_jar_file}"
71merge_pack_fast_jar_command="jar -cvfm ${temp_pack_jar_path} ${manifest_path} -C ${temp_dir} ."
72if [ -d "${temp_pack_jar_dir}" ]
73    then
74        echo "${temp_pack_jar_dir} exist"
75    else
76        mkdir -p ${temp_pack_jar_dir}
77fi
78eval ${merge_pack_fast_jar_command}
79
80# make out dir
81final_pack_out_path="${final_path}/${pack_build_out_path}"
82final_pack_jar_path="${final_path}/${pack_build_out_jar_path}"
83if [ -d "$final_pack_out_path" ]
84    then
85        echo "${final_pack_out_path} exist"
86    else
87        mkdir -p ${final_pack_out_path}
88fi
89copy_command="cp ${temp_pack_jar_path} ${final_pack_jar_path}"
90eval ${copy_command}
91if [ -f "${pack_jar_file}"]
92    then
93        echo "${pack_jar_file} exist"
94    else
95        cp ${temp_pack_jar_path} ${pack_jar_file}
96fi
97rm -rf ${temp_pack_jar_dir}
98rm -rf ${temp_dir}
99rm -rf ${out_dir}
100