check_cppbuild.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. # exit if any command fails
  3. set -e
  4. # Check header files in NMSIS/Core/Include is compatible with C++
  5. # arg1 is the cpu arch
  6. # arg2 is the abi
  7. # arg3 and later are extra build flags. Cause some APIs in header file may protected
  8. # by macros, so you can provide extra macros to test these APIs.
  9. check_cpp_build ()
  10. {
  11. local arch=${1-rv32imac}
  12. local abi=${2-ilp32}
  13. # provide extra build flags if any
  14. local extra_flags=${@:3}
  15. riscv64-unknown-elf-g++ -march=${arch} -mabi=${abi} -INMSIS/Core/Include -ISoC/evalsoc/Common/Include -Werror -c -o /tmp/test.o -x c++ ${extra_flags} - <<< $'#include "nuclei_sdk_soc.h"\n int main(){return 0;}'
  16. echo "Checking arch=${arch} abi=${abi} extra_flags=\"${extra_flags}\" Pass!"
  17. }
  18. SCRIPTDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
  19. pushd ${SCRIPTDIR}/../../../ > /dev/null
  20. echo "Start C++ compatibility check:"
  21. check_cpp_build rv32imafdc_zve32f_xxldspn3x ilp32d
  22. check_cpp_build rv32imafdc_zve32f_xxldspn3x ilp32d -DCFG_HAS_IOCC=1
  23. check_cpp_build rv32imafdc_zve32f_xxldspn3x ilp32d -DCFG_HAS_SMP=1
  24. check_cpp_build rv32imafdc_zve32f_xxldspn3x ilp32d -DCFG_HAS_HPM=1
  25. check_cpp_build rv64imafdcv_xxldsp lp64d
  26. check_cpp_build rv64imafdcv_xxldsp lp64d -DCFG_HAS_IOCC=1
  27. check_cpp_build rv64imafdcv_xxldsp lp64d -DCFG_HAS_SMP=1
  28. check_cpp_build rv64imafdcv_xxldsp lp64d -DCFG_HAS_HPM=1
  29. popd > /dev/null
  30. exit 0