Chmod tree artifact output to allow Xcode to write into it.
When copying a tree artifact output from Bazel's output directory, it comes with Bazel's permissions, which are readonly. By adding +w to the attributes of the copied bundle, Tulsi allows Xcode to modify the output bundle, for example, for codesigning and injecting IDE specific dylibs.
PiperOrigin-RevId: 228767293
diff --git a/src/TulsiGenerator/Scripts/bazel_build.py b/src/TulsiGenerator/Scripts/bazel_build.py
index 0bea027..f7353f4 100755
--- a/src/TulsiGenerator/Scripts/bazel_build.py
+++ b/src/TulsiGenerator/Scripts/bazel_build.py
@@ -873,6 +873,20 @@
self._InstallBundle(primary_artifact,
xcode_artifact_path)
+ # When the rules output a tree artifact, Tulsi will copy the bundle as is
+ # into the expected Xcode output location. But because they're copied as
+ # is from the bazel output, they come with bazel's permissions, which are
+ # read only. Here we set them to write as well, so Xcode can modify the
+ # bundle too (for example, for codesigning).
+ chmod_timer = Timer('Modifying permissions of output bundle',
+ 'bundle_chmod').Start()
+
+ self._PrintVerbose('Spawning subprocess to add write permissions to '
+ 'copied bundle...')
+ process = subprocess.Popen(['chmod', '-R', 'uga+w', xcode_artifact_path])
+ process.wait()
+ chmod_timer.End()
+
# No return code check as this is not an essential operation.
self._InstallEmbeddedBundlesIfNecessary(primary_output_data)