cmake: Add function for checking if a directory is write-able
Added a CMake extention for determining if a directory is write-able
by the build system. To determine this, we attempt to 'touch' a file
in the directory and check the return code of this command.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
diff --git a/scripts/dir_is_writeable.py b/scripts/dir_is_writeable.py
new file mode 100644
index 0000000..b087b0c
--- /dev/null
+++ b/scripts/dir_is_writeable.py
@@ -0,0 +1,10 @@
+import os
+import sys
+
+def main():
+ is_writeable = os.access(sys.argv[1], os.W_OK)
+ return_code = int(not is_writeable)
+ sys.exit(return_code)
+
+if __name__ == "__main__":
+ main()