1#!/usr/bin/env bash 2# Copyright (c) 2022-2025 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 17haptobin_build_jar_path=$2 18out_build_path=$3 19toolchain=$4 20compile_java=$5 21fastjson_jar=$6 22fastjson2_jar=$7 23fastjson2ext_jar=$8 24final_path=$(pwd) 25 26temp_path="." 27jar_dir="jar" 28haptobin_jar_file="haptobin_tool.jar" 29haptobin_jar_path="${final_path}/${out_build_path}" 30haptobin_jar_file_path="${final_path}/${haptobin_build_jar_path}" 31# make out dir 32if [ -d "${haptobin_jar_path}" ] 33 then 34 echo "${haptobin_jar_path} exist" 35 else 36 mkdir -p ${haptobin_jar_path} 37fi 38final_jar_path="${root_path}/jar/${haptobin_jar_file}" 39manifest_path=${root_path}/META-INF/packingbin_tool/MANIFEST.MF 40 41# compile java class 42out_dir="${root_path}/out/${toolchain}/haptobin" 43if [ -d "${out_dir}/ohos" ] 44 then 45 echo "${out_dir}/ohos exist" 46 else 47 mkdir -p "${out_dir}/ohos" 48fi 49 50compile_command="javac -source 1.8 -target 1.8 \ 51-cp ${fastjson_jar}:${fastjson2_jar}:${fastjson2ext_jar} -d ${out_dir} ${compile_java}" 52eval ${compile_command} 53cd ${out_dir} 54temp_jar_path="${root_path}/jar/haptobin_${toolchain}/${haptobin_jar_file}" 55temp_jar_dir="${root_path}/jar/haptobin_${toolchain}" 56pack_command="jar -cvfm ${temp_jar_path}/ ${manifest_path} ./ohos" 57if [ -d "${temp_jar_dir}" ] 58 then 59 echo "${temp_jar_dir} exist" 60 else 61 mkdir -p "${temp_jar_dir}" 62fi 63eval ${pack_command} 64 65copy_command="cp ${temp_jar_path} ${haptobin_jar_file_path}" 66eval ${copy_command} 67# copy to developtoo/packintool/jar 68if [ -f "${final_jar_path}" ] 69 then 70 echo "${final_jar_path} exist" 71 else 72 eval "cp ${temp_jar_path} ${final_jar_path}" 73fi 74rm -rf ${temp_jar_dir}