Repository: godot
Issue: Export cache can linger across export attempts, making macOS exports larger than expected
Labels: bug,platform:macos,topic:editor,topic:porting

**Godot version:** 3.2.3


**OS/device including version:** linux(docker) / macos


**Issue description:**

I am trying to export a very simple game (just a sprite that changes colour) and I am getting a very weird issue.

I am building Godot from source but I have no modifications, just using the `scons` command as described in the docs. I have built the linux headless version with `platform=server tool=yes`, etc. Then I export using the command line with the `--export` argument.

This all works perfectly fine when exporting for Linux and Windows (both 64 and 32 bit). However, there is some weird issue when I try to export for MacOS.

When I export using the linux headless executable on my linux machine, everything works fine - the exported game looks just fine and when tested on a MacOS works perfectly fine.

However, my goal is to not run this manually but to set up automated builds using Buildbot. I am doing that using the official docker images of buildbot. And when the export process is run by the buildbot worker, the final `.zip` file is missing the whole `osx.app/` directory (where the release/debug executables should be) and is unusable. The export process itself completes fine with no errors but the result is a broken `.app` that cannot be run.

I have also tested building a headless godot build on the MacOS, and then using that directly on the mac's Terminal to export the game. The result is absolutely the same broken `.zip` file. Which proves that this is not buildbot-related. It is also very weird that a macos headless build cannot export for macos.

I have tested using both the official templates, and ones built by me. There is no difference.

Here are the contents of the final `.zip` file when exported by the linux headless build (using either official or self-built template):

    Archive:  ../output/macos/macos.zip
      Length      Date    Time    Name
    ---------  ---------- -----   ----
         1434  2021-03-06 10:48   project.app/osx.app/Contents/Info.plist
        67500  2021-03-06 10:48   project.app/osx.app/Contents/Resources/icon.icns
            9  2021-03-06 10:48   project.app/osx.app/Contents/PkgInfo
    112300312  2021-03-06 10:48   project.app/osx.app/Contents/MacOS/godot_osx_debug.universal
    112300312  2021-03-06 10:48   project.app/osx.app/Contents/MacOS/godot_osx_debug.64
     72105344  2021-03-06 10:48   project.app/osx.app/Contents/MacOS/godot_osx_release.64
     72105344  2021-03-06 10:48   project.app/osx.app/Contents/MacOS/godot_osx_release.universal
         1353  2021-03-06 10:48   project.app/Contents/Info.plist
         6272  2021-03-06 10:48   project.app/Contents/Resources/project.pck
        67500  2021-03-06 10:48   project.app/Contents/Resources/icon.icns
            9  2021-03-06 10:48   project.app/Contents/PkgInfo
     40271580  2021-03-06 10:48   project.app/Contents/MacOS/project
    ---------                     -------
    409226969                     12 files

And here is what it looks like when built by buildbot or MacOS:

    Archive:  ../output/macos/macos.zip
      Length      Date    Time    Name
    ---------  ---------- -----   ----
         1353  2021-03-06 08:51   project.app/Contents/Info.plist
         6272  2021-03-06 08:51   project.app/Contents/Resources/project.pck
        67500  2021-03-06 08:51   project.app/Contents/Resources/icon.icns
            9  2021-03-06 08:51   project.app/Contents/PkgInfo
     40271580  2021-03-06 08:51   project.app/Contents/MacOS/project
    ---------                     -------
     40346714                     5 files


I really have no idea what might be causing this issue and I think I'm doing everything correcly so I'd appreciate if someone could help.

---
This is all related to my effort of setting up an easy to use template project for people who want to develop a game using C++ and Godot, or simply need a custom module (like for mobile ads). It can be found here: https://gitlab.com/bluabito/godot-cpp-template


**Steps to reproduce:**
1. Build godot headless on macos
2. Try to export a simple project on the command line