C++ SDK: Add a script the builds and uploads a tarball of the SDK to GCS.
R=vardhan@google.com
Review URL: https://codereview.chromium.org/1766093003 .
diff --git a/sdk_build/build_sdk.py b/sdk_build/build_sdk.py
index 340bfee..74c46fd 100755
--- a/sdk_build/build_sdk.py
+++ b/sdk_build/build_sdk.py
@@ -24,6 +24,17 @@
pass
+def _CopyHelper(source_file, dest_file):
+ """Copies |source_file| to |dest_file|. If |source_file| is user-executable,
+ it will set |dest_file|'s mode to 0755 (user: rwx, group/other: rx);
+ otherwise, it will set it to 0644 (user: rw, group/other: r)."""
+ shutil.copy(source_file, dest_file)
+ if os.stat(source_file).st_mode & 0100:
+ os.chmod(dest_file, 0755)
+ else:
+ os.chmod(dest_file, 0644)
+
+
def _CopyDir(source_path, dest_path, **kwargs):
"""Copies directories from the source git repository (the current working
directory should be the root of this repository) to the destination path.
@@ -39,7 +50,7 @@
rel_path = source_file[len(source_path) + 1:]
dest_file = os.path.join(dest_path, rel_path)
_MakeDirs(os.path.dirname(dest_file))
- shutil.copy(source_file, dest_file)
+ _CopyHelper(source_file, dest_file)
def _CopyFiles(source_files, dest_path):
@@ -54,7 +65,7 @@
source_files = [source_files]
_MakeDirs(dest_path)
for source_file in source_files:
- shutil.copy(source_file,
+ _CopyHelper(source_file,
os.path.join(dest_path, os.path.basename(source_file)))
@@ -106,6 +117,10 @@
if not args.allow_dirty_tree and IsGitTreeDirty():
FatalError("tree appears to be dirty")
+ # Set the umask, so that files/directories we create will be world- (and
+ # group-) readable (and executable, for directories).
+ os.umask(0022)
+
try:
os.mkdir(target_dir)
except OSError: