I am just wondering how the upload script works for the arduino. It seems in platform.txt there are global variables which are passed to the upload script. I'm just wondering how are they passed and who calls the script. Basically the flow of files used when the user clicks upload.
Enable verbose mode when compiling and linking, using File + Preferences. You can see all the commands that the IDE uses.
I think this is the closest to an official reference.