A First
Yesterday I sent a customer of mine the very first Windows executable I've produced. I mean honest to goodness .exe - it wasn't a web app, script or Java App. It's what Shira likes to call real software.
I was really impressed how easily PLT Scheme made it to build a completely stand alone executable. I whipped up a quick Makefile with these rules:
MZC = "c:/Program Files/PLT/mzc.exe" DESKTOP = ~/dt foo.exe : ui.ss $(MZC) --gui-exe foo ui.ss dist : foo.exe $(MZC) --exe-dir app foo.exe rm -f app.zip zip -r app.zip app rm -rf app deploy cp app.zip $(DESKTOP) mkdir deploy cp app.zip deploy rm app.zip
This script not only builds the .exe but packages it up in a zip file so I can send it off easily. I told my client to unzip the file and run the .exe - it worked painlessly.
In the past I've built stand alone Java apps and it was always a pain - for starters, you need to make sure the user has the JVM on their machine. And then you have to deal with the fact that Swing used to be (maybe still is?) soooo slow. And don't even get me started on packing up all the right Jar files and dependencies. (Certainly over the years things have gotten much better, right?)
All I know is that I didn't have to worry about dependencies, and the entire zip file with run time environment was about 4meg.
The Catch
One gotcha that bit me, was that my first attempt to build an application succeeded, but when I ran the app, nothing would happen. Turns out, when you say:
$(MZC) --gui-exe foo ui.ss
your asking to build foo.exe that will invoke the module in ui.ss. I was thinking Java/C and was expecting to call the foo function on the ui module. But that's not what it does (as clearly stated in the docs) -- it simply runs the module. So instead of:
(module foo mzscheme ...code... (define (foo) ...code to execute... ) )
I needed to have:
(module foo mzscheme ...code... (define (foo) ...code to execute... ) ;; Make sure to call our initial function at run time. (foo) )
I guess now I really can comfortably call myself Ideas2Executables. Whew, that was a close one.
No comments:
Post a Comment