Hi posting here because I’m running Xojo on a Mac, but it affects all platforms, I think.
I’m a (sometimes) lazy guy and there are too many small apps I have to update from time to time. Some automation might help and I decided to give it a try But it’s a bag of hurts
Is it just me, or is this whole “Build Automation” thing missing useful documentation?
The Framework-User-Guide says: “All the commands are listed in the Language Reference, but some useful ones include: DoCommand and DoShellCommand and Speak.” have you ever searched the Language Reference for “DoShellCommand”? Try it. Nothing.
Here is my question
What is the directory the DoShellCommand is fired in? The example from the docs “DoShellCommand(“codesign MyApplication.app”)” makes me think that it’s the folder where the built app is saved to but I don’t think that is true.
According to this example, a DoShellCommand(“zip -r MyApplication.zip MyApplication.app”) should create a zip file containing the app package (works in terminal). But Xojo just throws an error 31 telling me that something went wrong during the build step.
And this is just the mac part. The windows and linux builds are saved in separate folders by Xojo what’s the directory here? The folder where the exe is located or the parent folder?
I try to automate the ZIP-creation for all platforms to save some time. An external script might do the trick but how to tell this external script which folder to use?
I agree that build automation is a huge time sink because it’s so fiddly. Regarding the documentation there should be something called “IDEScripting.pdf” in the documentation somewhere.
The shell is not Terminal! You need to use the full path for MyApplication.zip and likely for zip, too. You get the full path of the app with currentBuildLocation.
DoShellCommand returns a string (which you must graciously accept, or you get an error) Also, according to the PDF currentBuildLocation is the shell path to the app that was built, so the spaces should already be escaped.
I also don’t think quotes are a normal thing in bash scripts.
dim result as string
result = DoShellCommand("zip -r ~/Desktop/MyApp.zip " + currentBuildLocation)
You’re not going to like the zip structure once you open it (unacceptable for deployment) but hey, it works.
dim result as string
result = DoShellCommand("cd " + currentBuildLocation + " && zip -r MyApp.zip test.app")
Ask Griffenberg: This is an excellent tip. Thanks.
One further optimization is to use the -y option to preserve the symlinks in the zip file so it doesn’t include multiple copies of the same data. Otherwise the decompressed app will be significantly larger than the original copy, and the zip archive will be larger than necessary.
zip -r -y MyApp.zip test.app
Without “zip -y” my 89MB app became 105MB after going in and out of the zip archive. With -y it’s the same size before and after.