cmake: Give descriptive error to user when cloned with core.autocrlf
Windows users have on multiple occasions cloned Zephyr using a Windows
git client. It seems that the windows git client defaults to
converting line endings from LF to CRLF when cloning repo's. This
breaks at least one of Zephyr's tools (Kconfig).
This patch introduces a sanity check of the environment for MSYS
users.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
diff --git a/scripts/check_host_is_ok.py b/scripts/check_host_is_ok.py
new file mode 100644
index 0000000..89dc48f
--- /dev/null
+++ b/scripts/check_host_is_ok.py
@@ -0,0 +1,16 @@
+import os
+
+
+def crash_if_zephyr_was_cloned_with_wrong_line_endings():
+ f = open('{}/Kconfig'.format(os.environ["ZEPHYR_BASE"]), 'U')
+ f.readline()
+
+ error_msg = "Re-clone with autocrlf false. $ git config --global core.autocrlf false"
+
+ assert f.newlines == '\n', error_msg
+
+def main():
+ crash_if_zephyr_was_cloned_with_wrong_line_endings()
+
+if __name__ == "__main__":
+ main()