Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the app bundle's access and modified times to match the build time on macOS #102003

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

Meorge
Copy link
Contributor

@Meorge Meorge commented Jan 25, 2025

(Mostly) closes #102001 .

This adds a step to the bundle-generation script that updates the access and modification times for the macOS Godot editor .app bundle, so that it appears in the filesystem as having been last accessed and modified when the bundle was built, rather than when the original app template was created back in March 2024.

CleanShot 2025-01-24 at 16 02 26@2x

In the orange box here, the executable and app bundle were both just built, while the top two app bundles were built a while time ago. You can see that with this PR, the new app bundle has an accurate "Date Modified" time.

Changing the "Date Created" date appears to be less trivial - I think the easiest way to go about that would be to create the .app directory itself from scratch, then copy all subdirectories from the template bundle into this newly-created directory. If you think that'd be a good idea to pursue, I can update my branch to try to implement that.

@Meorge Meorge requested a review from a team as a code owner January 25, 2025 00:06
@AThousandShips AThousandShips added this to the 4.4 milestone Jan 25, 2025
@AThousandShips AThousandShips requested a review from a team January 25, 2025 09:05
Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the "Date Created" date appears to be less trivial - I think the easiest way to go about that would be to create the .app directory itself from scratch, then copy all subdirectories from the template bundle into this newly-created directory.

This seems to be the easiest way to do it, and since .app bundle always contain only a single Content folder should be as easy as:

diff --git a/platform/macos/SCsub b/platform/macos/SCsub
index 429cec2234..cdeb02675e 100644
--- a/platform/macos/SCsub
+++ b/platform/macos/SCsub
@@ -33,7 +33,8 @@ def generate_bundle(target, source, env):
         templ = Dir("#misc/dist/macos_tools.app").abspath
         if os.path.exists(app_dir):
             shutil.rmtree(app_dir)
-        shutil.copytree(templ, app_dir, ignore=shutil.ignore_patterns("Contents/Info.plist"))
+        os.mkdir(app_dir)
+        shutil.copytree(templ + "/Contents", app_dir + "/Contents")
         if not os.path.isdir(app_dir + "/Contents/MacOS"):
             os.mkdir(app_dir + "/Contents/MacOS")
         if target_bin != "":

@Meorge
Copy link
Contributor Author

Meorge commented Jan 25, 2025

It did occur to me last night that the structure of the app bundle, with the sole "Contents" folder, would make it a lot easier to do. I presume we'd want to keep the original shutil.copytree's exclusion of Info.plist, though, like so?

shutil.copytree(templ + "/Contents", app_dir + "/Contents", ignore=shutil.ignore_patterns("Info.plist"))

Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
@Meorge
Copy link
Contributor Author

Meorge commented Jan 26, 2025

I've made the changes now, so that it creates the app directory itself and copies over the Contents directory!

@Meorge Meorge requested a review from bruvzg January 28, 2025 05:12
Copy link
Contributor

@Repiteo Repiteo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably a more SCons-specific way of doing this, but that's not a dealbreaker

@Repiteo Repiteo merged commit 55c9dbc into godotengine:master Jan 28, 2025
19 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jan 28, 2025

Thanks!

@Meorge Meorge deleted the app-bundle-date branch January 28, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macOS editor app bundle uses old and constant "Date Created" and "Date Modified" values
4 participants