106f6ba60Sopenharmony_ci#!/bin/bash 206f6ba60Sopenharmony_ci 306f6ba60Sopenharmony_ci# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. 406f6ba60Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 506f6ba60Sopenharmony_ci# you may not use this file except in compliance with the License. 606f6ba60Sopenharmony_ci# You may obtain a copy of the License at 706f6ba60Sopenharmony_ci# 806f6ba60Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 906f6ba60Sopenharmony_ci# 1006f6ba60Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 1106f6ba60Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 1206f6ba60Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1306f6ba60Sopenharmony_ci# See the License for the specific language governing permissions and 1406f6ba60Sopenharmony_ci# limitations under the License 1506f6ba60Sopenharmony_ci 1606f6ba60Sopenharmony_ciset -e 1706f6ba60Sopenharmony_ci 1806f6ba60Sopenharmony_ciBPFTOOL_DIR=${1} 1906f6ba60Sopenharmony_ciBASE_DIR=${2} 2006f6ba60Sopenharmony_ciDEST_DIR=${3} 2106f6ba60Sopenharmony_ci 2206f6ba60Sopenharmony_ciecho "BPFTOOL_DIR:"${BPFTOOL_DIR} 2306f6ba60Sopenharmony_ciecho "BASE_DIR:"${BASE_DIR} 2406f6ba60Sopenharmony_ciecho "DEST_DIR:"${DEST_DIR} 2506f6ba60Sopenharmony_ci 2606f6ba60Sopenharmony_ciif [[ ! -d "${BASE_DIR}" ]] 2706f6ba60Sopenharmony_cithen 2806f6ba60Sopenharmony_ci echo ${BASE_DIR}": no such directory" 2906f6ba60Sopenharmony_ci exit -1 3006f6ba60Sopenharmony_cifi 3106f6ba60Sopenharmony_ci 3206f6ba60Sopenharmony_ciif [[ ! -d "${DEST_DIR}" ]] 3306f6ba60Sopenharmony_cithen 3406f6ba60Sopenharmony_ci echo ${DEST_DIR}": no such directory" 3506f6ba60Sopenharmony_ci exit -1 3606f6ba60Sopenharmony_cifi 3706f6ba60Sopenharmony_ci 3806f6ba60Sopenharmony_ciBPF_OBJ_SETS=$(ls ${BASE_DIR} | grep '\.bpf') 3906f6ba60Sopenharmony_ciecho "bpf object directories: "${BPF_OBJ_SETS} 4006f6ba60Sopenharmony_ci 4106f6ba60Sopenharmony_cifor obj_set in ${BPF_OBJ_SETS} 4206f6ba60Sopenharmony_cido 4306f6ba60Sopenharmony_ci echo "current bpf object directory name: "${obj_set} 4406f6ba60Sopenharmony_ci BPF_OBJ_DIR=${BASE_DIR}"/"${obj_set} 4506f6ba60Sopenharmony_ci echo "current bpf object directory path: "${BPF_OBJ_DIR} 4606f6ba60Sopenharmony_ci BPF_OBJECTS=$(ls ${BPF_OBJ_DIR} | grep '\.bpf\.o') 4706f6ba60Sopenharmony_ci echo "bpf object file names: "${BPF_OBJECTS} 4806f6ba60Sopenharmony_ci for obj in ${BPF_OBJECTS} 4906f6ba60Sopenharmony_ci do 5006f6ba60Sopenharmony_ci echo "current bpf object file name: "${obj} 5106f6ba60Sopenharmony_ci OBJ_PATH=${BPF_OBJ_DIR}"/"${obj} 5206f6ba60Sopenharmony_ci echo "current bpf object file path: "${OBJ_PATH} 5306f6ba60Sopenharmony_ci SKEL_NAME=${obj/bpf.o/skel.h} 5406f6ba60Sopenharmony_ci echo "current skeleton name: "${SKEL_NAME} 5506f6ba60Sopenharmony_ci SKEL_PATH=${DEST_DIR}"/"${SKEL_NAME} 5606f6ba60Sopenharmony_ci echo "current skeleton path: "${SKEL_PATH} 5706f6ba60Sopenharmony_ci ${BPFTOOL_DIR} gen skeleton ${OBJ_PATH} > ${SKEL_PATH} 5806f6ba60Sopenharmony_ci if [ ! -s "${SKEL_PATH}" ] 5906f6ba60Sopenharmony_ci then 6006f6ba60Sopenharmony_ci echo ${SKEL_PATH}" is empty" 6106f6ba60Sopenharmony_ci rm -rf ${SKEL_PATH} 6206f6ba60Sopenharmony_ci exit -1 6306f6ba60Sopenharmony_ci fi 6406f6ba60Sopenharmony_ci 6506f6ba60Sopenharmony_ci replacement="#include \"libbpf.h\"" 6606f6ba60Sopenharmony_ci sed -i "s/#include <bpf\/libbpf.h>/${replacement}/g" ${SKEL_PATH} 6706f6ba60Sopenharmony_ci done 6806f6ba60Sopenharmony_cidone