1#!/bin/bash 2# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 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 16THIS_DIR=$(dirname ${BASH_SOURCE[0]}) 17PROJECT_TOP=$(realpath $THIS_DIR/..) 18TAIL_DIR="." 19SUBSYS_DIR="." 20if [[ "$3" == *"developtools"* ]]; then 21 TAIL_DIR="thirdparty/protobuf" 22 SUBSYS_DIR="developtools/smartperf_host" 23 PROJECT_TOP=$(realpath $THIS_DIR/../../../..) 24fi 25 26OHOS_X64_OUT=$PROJECT_TOP/$2/ 27LIBCXX_X64_OUT=$PROJECT_TOP/$1/ndk/libcxx/linux_x86_64 28SUBSYS_X64_OUT=$PROJECT_TOP/$2/$TAIL_DIR 29 30PROTOC_DIR=$PROJECT_TOP/$2/$TAIL_DIR 31PROTOC=$PROJECT_TOP/$2/$TAIL_DIR/protoc 32OPT_PLUGIN_PROTOREADER_PATH=$PROJECT_TOP/$2/$SUBSYS_DIR/protoreader_plugin 33OPT_PLUGIN_PROTOREADER="--plugin=protoc-gen-plugin=$PROJECT_TOP/$2/$SUBSYS_DIR/protoreader_plugin --plugin_out=wrapper_namespace=ProtoReader" 34OPT_OUT=--opt_out 35OPT_PROTOREADER_OUT=--cpp_out 36TMP=$2 37PROTO_OUT_DIR="$PROJECT_TOP/${TMP%/*}/$3" # path of the new proto file 38 39echo "PROTOC_DIR = $PROTOC_DIR" 40if ls "$PROTOC_DIR"/*.dylib 1>/dev/null 2>&1; then 41 cp $PROTOC_DIR/*.dylib $PROJECT_TOP/$2/$SUBSYS_DIR/ 42else 43 echo "*.dylib Not Found!" 44fi 45 46PARAMS=$* 47echo "PARAMS = $PARAMS" 48PARAMS_FILTER="$1 $2 $3" 49 50# creat pb file 51PARAMS_SRC=${PARAMS:${#PARAMS_FILTER}} 52 53# avoid conflict, param4=--plugin* means ipc plugin, generate encode file if opt plugin exist 54if [[ "$4" != --plugin* ]]; then 55 if [ -f "$OPT_PLUGIN_PROTOREADER_PATH" ]; then 56 echo "generate protobuf optimize code OPT_PLUGIN_PROTOREADER = $OPT_PLUGIN_PROTOREADER" 57 LD_LIBRARY_PATH=$LIBCXX_X64_OUT:$SUBSYS_X64_OUT exec $PROTOC $OPT_PLUGIN_PROTOREADER:$5 $PARAMS_SRC 58 fi 59fi 60echo "EXEC: LD_LIBRARY_PATH=$LIBCXX_X64_OUT:$SUBSYS_X64_OUT $PROTOC $PARAMS_SRC" 61LD_LIBRARY_PATH=$LIBCXX_X64_OUT:$SUBSYS_X64_OUT exec $PROTOC $PARAMS_SRC 62