1#!/bin/bash 2# SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com> 3# 4# SPDX-License-Identifier: Apache-2.0 5# 6# Licensed under the Apache License, Version 2.0 (the License); you may 7# not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an AS IS BASIS, WITHOUT 14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17 18# Version: 2.3 19# Date: 2022-09-28 20# This bash script generates a CMSIS Software Pack: 21# 22 23set -o pipefail 24 25# Set version of gen pack library 26REQUIRED_GEN_PACK_LIB="0.5.1" 27 28# Set default command line arguments 29DEFAULT_ARGS=(-c "v") 30 31# Pack warehouse directory - destination 32PACK_OUTPUT=./output 33 34# Temporary pack build directory 35PACK_BUILD=./build 36 37# Specify directory names to be added to pack base directory 38PACK_DIRS=" 39 Documentation 40 Include 41 Source 42" 43 44# Specify file names to be added to pack base directory 45PACK_BASE_FILES=" 46 LICENSE.txt 47 README.md 48" 49 50# Specify file names to be deleted from pack build directory 51PACK_DELETE_FILES="" 52 53# Specify patches to be applied 54PACK_PATCH_FILES="" 55 56# Specify addition argument to packchk 57PACKCHK_ARGS=() 58 59# Specify additional dependencies for packchk 60PACKCHK_DEPS=" 61 ARM.CMSIS.pdsc 62" 63 64# custom pre-processing steps 65function preprocess() { 66 ./DoxyGen/gen_doc.sh 67} 68 69# custom post-processing steps 70function postprocess() { 71 # Set component version to match pack version 72 VERSION=$(git_describe "${CHANGELOG}" | sed -e "s/+g.*$//") 73 sed -i -e "s/Cgroup=\"NN Lib\" Cversion=\"[^\"]*\"/Cgroup=\"NN Lib\" Cversion=\"${VERSION}\"/" ${PACK_BUILD}/ARM.CMSIS-NN.pdsc 74} 75 76############ DO NOT EDIT BELOW ########### 77 78function install_lib() { 79 local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz" 80 echo "Downloading gen-pack lib to '$2'" 81 mkdir -p "$2" 82 curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1 83} 84 85function load_lib() { 86 if [[ -d ${GEN_PACK_LIB} ]]; then 87 . "${GEN_PACK_LIB}/gen-pack" 88 return 0 89 fi 90 local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}" 91 local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}" 92 if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then 93 echo "Required gen_pack lib not found!" >&2 94 install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}" 95 fi 96 97 if [[ -d "${GLOBAL_LIB}" ]]; then 98 . "${GLOBAL_LIB}/gen-pack" 99 elif [[ -d "${USER_LIB}" ]]; then 100 . "${USER_LIB}/gen-pack" 101 else 102 echo "Required gen-pack lib is not installed!" >&2 103 exit 1 104 fi 105} 106 107load_lib 108gen_pack "${DEFAULT_ARGS[@]}" "$@" 109 110exit 0 111