geirby

replace_o2_flag

Aug 23rd, 2021 (edited)
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.01 KB | None | 0 0
  1. if [[ ${Configuration} == "debug" ]]; then
  2.     echo -e "Current COMPILE_OPTS:
  3.     $( grep '^COMPILE_OPTS.*' ${BUILD_DIR}/config.linux-with-shared-libraries) )"
  4.  
  5.     if [[ $(grep '^COMPILE_OPTS.*-O2' ${BUILD_DIR}/config.linux-with-shared-libraries) != "" ]]; then
  6.         echo -e "FOUND WRONG FLAG; REPLACE"
  7.         sed -i 's+-O2+-O0+g' ${BUILD_DIR}/config.linux-with-shared-libraries
  8.     elif [[ $(grep '^COMPILE_OPTS.*-O0' ${BUILD_DIR}/config.linux-with-shared-libraries) ]]; then
  9.         echo -e "FOUND CORRECT FLAG; DO NOTHING"
  10.     else
  11.         echo -e "ADD FLAG"
  12.         sed -i 's+^COMPILE_OPTS\(.*\)+COMPILE_OPTS\1 -O0+g' ${BUILD_DIR}/config.linux-with-shared-libraries
  13.     fi
  14.        
  15.     COMPILE_OPTS="$(grep '^COMPILE_OPTS.*-g$' ${BUILD_DIR}/config.linux-with-shared-libraries)"
  16.     if [[ ${COMPILE_OPTS} == "" ]]; then
  17.         echo -e "Adding debug flag into COMPILE_OPTS"
  18.         sed -i 's+^COMPILE_OPTS\(.*\)+COMPILE_OPTS\1 -g+g' ${BUILD_DIR}/config.linux-with-shared-libraries
  19.         echo -e $(grep '^COMPILE_OPTS.*-g$' ${BUILD_DIR}/config.linux-with-shared-libraries)
  20.     fi
  21. fi
Add Comment
Please, Sign In to add comment