AndroidMK-check.cmake 1.2 KB

123456789101112131415161718192021222324252627282930
  1. # This file does a regex file compare on the generated
  2. # Android.mk files from the AndroidMK test
  3. macro(compare_file_to_expected file expected_file)
  4. file(READ "${file}" ANDROID_MK)
  5. # clean up new lines
  6. string(REGEX REPLACE "\r\n" "\n" ANDROID_MK "${ANDROID_MK}")
  7. string(REGEX REPLACE "\n+$" "" ANDROID_MK "${ANDROID_MK}")
  8. # read in the expected regex file
  9. file(READ "${expected_file}" expected)
  10. # clean up new lines
  11. string(REGEX REPLACE "\r\n" "\n" expected "${expected}")
  12. string(REGEX REPLACE "\n+$" "" expected "${expected}")
  13. # compare the file to the expected regex and if there is not a match
  14. # put an error message in RunCMake_TEST_FAILED
  15. if(NOT "${ANDROID_MK}" MATCHES "${expected}")
  16. set(RunCMake_TEST_FAILED
  17. "${file} does not match ${expected_file}:
  18. Android.mk contents = [\n${ANDROID_MK}\n]
  19. Expected = [\n${expected}\n]")
  20. endif()
  21. endmacro()
  22. compare_file_to_expected(
  23. "${RunCMake_BINARY_DIR}/AndroidMK-build/Android.mk"
  24. "${RunCMake_TEST_SOURCE_DIR}/expectedBuildAndroidMK.txt")
  25. compare_file_to_expected(
  26. "${RunCMake_BINARY_DIR}/AndroidMK-build/CMakeFiles/Export/share/ndk-modules/Android.mk"
  27. "${RunCMake_TEST_SOURCE_DIR}/expectedInstallAndroidMK.txt")