OK, there has been a lot of discussion about building projects from the command line. I whipped up a little script that will do just that, but it works on OS X only, sorry Windows/Linux guys… Bear with me, I had to hack the Apple Script because for some reason click menu item “blah” of menu item “blah” wasn’t working for me on sub menus, maybe some AppleScript Guru’s can solve that problem?
Anyway, first what you need to do is create a new IDE script containing:
[code]Dim projectToOpen As String = Clipboard
OpenFile(projectToOpen)
DoCommand “BuildApp”
DoCommand “CloseWindow”
[/code]
You want to name this so that it will always be at the top of your IDE Scripts menu because of my silly menu hacks. I named mine “1 - Build Script from Command Line”
Now, create a shell script, I named mine: xojo_build
[code]#!/bin/sh
echo “Building $1”
osascript -e "set the clipboard to “$1"”
osascript -e ’
tell application “Xojo” to activate
tell application “System Events”
tell process “Xojo”
tell menu bar 1
tell menu 3
click
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 124
key code 125
keystroke return
end tell
end tell
end tell
end tell’
[/code]
You can then compile from the command line:
$ ./xojo_compile /Users/jeremy/Projects/MyXojoProject/MyXojoProject.xojo_project
What this does…
- Sets the clipboard contents to the project you wish to open
- Clicks the File Menu
- Down arrow key 11 times to the IDE Scripts menu (hack!)
- Right arrow key 1 time to go into the IDE Scripts menu (hack!)
- Down arrow key 1 time to go to the 1st item inour IDE Scripts menu which should be “1 - Build Script from Command Line”
The Build Script from the command line:
- Opens the project as stated from the command line
- Calls the command DoBuild to build the project. I do this instead of using the command BuildApp so that it will build the application and platforms you previously had set. You could modify this to use BuildApp if you’d like
- Closes the project
One could modify the clipboard set/get commands to include additional information, such as:
[code]Xojo -project -analyse -outputfile
Xojo -project -compile -rundebug
Xojo -project -compile -runremote
Xojo -project -buildTargets[/code]
Parsing the command line would be a trivial addition if you made your command line arguments simple like above.