[NTLK] BasiliskII script controlled: run Newton tools on OS X...

From: matthiasm <mm_at_matthiasm.com>
Date: Sat Sep 20 2008 - 16:50:55 EDT

Serious geek alert. Long explenation follows ;-)

If anyone is interested in this, please send me a PM and I will send
you the source or binaries of my BasiliskII version.

I have been torturing my head to find a way to run the Newton cross
assembler, compiler, and other MPW toosl on OS X. Of course they are
written for MacOS, so my Intel Mac can not run any of those natively.

Since I wanted to use the ARM C-compiler right from the Unix command
line, I considered loading the programm somehow and emulating the
MacOS environment. I gave up when I saw the complexity of MacOS
binaries.

So what I created is a pretty bad crutch, but it nevertheless works
well enough to integrate the Norcroft Compiler into my Unix build
chain: I added a handfull of simple script commands to BasiliskII
which emulate a keyboard and mouse and some other little trickery.

This is how it works:

- configure BasiliskII to launch MacOS, opening MPW as the last
application on start

- use the new "mactype" AppleScript command to simulate a user typing
on the keyboard, for example:
> osascript -e 'tell application "BasiliskII" to mactype "armCpp -h\\r"
   this will run the compiler (\\r send the 'Enter' key)

- Basilisk allows access to a drive named "Unix" which maps the Unix
file system. Use that to compile files in your developer directory.
Just send the full path (in my config, "Unix" points to my home
directory):
> "armCpp -oUnix:dev:test:main.o Unix:dev:test:main.cpp\\r"

- but how can we get the error messages from armCpp into the Unix
world? Well, we can use a fifo for that (\\o simlates pressing the
Option key, \\O releases it again, so we can create a ∑ symbol which
pipes all output to a file):
> mkfifo ~/myFifo
> osascript -e 'tell application "BasiliskII" to \
> "armCpp -oUnix:dev:test:main.o Unix:dev:test:main.cpp \\ow\
\OUnix:myFifo\\r"' &
> cat ~/myFifo
The cat command will wait until armCpp is done and closes the fifo.

- with these tricks it is easy to write a Unix script named "armCpp"
that calls the above sequence of commands, making this immense off-
route through a whole emulated machine almost entirely transparent to
a Unix script. Tadaa.

To things are missing:
1: you can't get a return value from the MacOS armCpp
2: all input and output uses \r instead of the Unix \n, so handling
text is annoying and might need another filter.

I hope that this is useful to someone else as well.

  Matthias

----
http://robowerk.com/
==================================================================== 
The NewtonTalk Mailing List - http://www.newtontalk.net/
The Official Newton FAQ     - http://www.splorp.com/newton/faq/
The Newton Glossary         - http://www.splorp.com/newton/glossary/
WikiWikiNewt                - http://tools.unna.org/wikiwikinewt/
====================================================================
Received on Sat Sep 20 17:24:57 2008

This archive was generated by hypermail 2.1.8 : Mon Sep 22 2008 - 00:30:00 EDT