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