Brian Waters | 13d9601 | 2017-12-08 16:53:31 -0600 | [diff] [blame] | 1 | #Copyright (c) 2017 Sprint |
| 2 | # |
| 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 | |
| 15 | #!/bin/sh |
| 16 | |
| 17 | usage () |
| 18 | { |
| 19 | echo "Used to configure cmake files to turn on/off building a specific dictionary " |
| 20 | echo "Usage: $0 <dictionary name> <ON|OFF> <make file>" |
| 21 | } |
| 22 | |
| 23 | if [ "$#" -ne 3 ]; then |
| 24 | usage |
| 25 | exit 0 |
| 26 | fi |
| 27 | |
| 28 | if [ "$2" != "ON" ] && [ "$2" != "OFF" ]; then |
| 29 | usage |
| 30 | exit |
| 31 | fi |
| 32 | |
| 33 | DCTDIR=$1 |
| 34 | STATE=$2 |
| 35 | CFGFILE=$3 |
| 36 | |
| 37 | if [ -e $3 ]; then |
| 38 | if [ -d "${DCTDIR}" ]; then |
| 39 | INDIR=`grep -c FD_EXTENSION_SUBDIR\(${DCTDIR} $3` |
| 40 | if [ "$INDIR" -eq 0 ]; then |
| 41 | echo "Adding ${DCTDIR} to file" |
| 42 | echo "FD_EXTENSION_SUBDIR(${DCTDIR} \"${DCTDIR} extension library\" $2)" >> ${CFGFILE} |
| 43 | elif [ "${STATE}" = "ON" ]; then |
| 44 | echo "Turning On" |
| 45 | sed -i.bak -e "s/FD_EXTENSION_SUBDIR(${DCTDIR}\\(.*\\)\"\\(.*\\)\"\\(.*\\)*OFF)/FD_EXTENSION_SUBDIR(${DCTDIR}\\1\"\\2\"\\3ON)/" ${CFGFILE} |
| 46 | else |
| 47 | echo "Turning Off" |
| 48 | sed -i.bak -e "s/FD_EXTENSION_SUBDIR(${DCTDIR}\\(.*\\)\"\\(.*\\)\"\\(.*\\)*ON)/FD_EXTENSION_SUBDIR(${DCTDIR}\\1\"\\2\"\\3OFF)/" ${CFGFILE} |
| 49 | fi |
| 50 | else |
| 51 | echo "Directory ${DCTDIR} doesn't exist\n" |
| 52 | fi |
| 53 | else |
| 54 | echo "File $3 doesn't exist. Please provide valid make file\n" |
| 55 | fi |