Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: sdk_build/build_sdk.py

Issue 1766093003: C++ SDK: Add a script the builds and uploads a tarball of the SDK to GCS. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk_build/build_and_upload_cpp_sdk.sh ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk_build/build_sdk.py
diff --git a/sdk_build/build_sdk.py b/sdk_build/build_sdk.py
index 340bfee42c791222111e49d410ba335ede8f108f..74c46fd8476fc15c9c0e7a506c3f425e8292a546 100755
--- a/sdk_build/build_sdk.py
+++ b/sdk_build/build_sdk.py
@@ -24,6 +24,17 @@ def _MakeDirs(*args, **kwargs):
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 @@ def _CopyDir(source_path, dest_path, **kwargs):
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 @@ def _CopyFiles(source_files, dest_path):
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 @@ def main():
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:
« no previous file with comments | « sdk_build/build_and_upload_cpp_sdk.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698