Cross Generating and Porting
Cross Generating and Porting:
Porting requires some preliminary steps
(detailed below) followed by a cross generation. Cross generation is
possible for any defined platform when you wish to boot-strap
generate the C code from another platform. Since this simpler and is
likely if you are doing cross-platform work, first we will discuss
cross-generation for an already defined platform. On an existing
platform, build for platform that you are moving TO (the from does
not matter):
for Mac:
TWX_StdLib.exe
Gen/buildFiles/build0mc.txt
for Linux:
TWX_StdLib.exe
Gen/buildFiles/build0lc.txt
for Microsoft Windows:
TWX_StdLib.exe
Gen/buildFiles/build0wc.txt
Then, transfer the entire twhome
directory to the target platform where the required development
environment/compiler is installed and functional. The garbage
collector must already be built under twhome/lib/(platform)/gc, if
necessary, build from source contained in twhome/softlib with the
approparite --prefix= argument. These should already be provided with
a binary distribution and are probably easiest to get that way...
From the twhome/tw/current directory execute "make -f
buildtw0/emit/c/Twilight/Gen/TWX_Build.make"
(for windows, first edit the
TWX_Build.make and globally replace / with \ to address the differing
file path delimiter on the platform, this is only necessary during
cross-generation. Then use nmake, "nmake -f
buildtw0\.....\TWX_Build.make) copy the resulting executable from
deploy0/emit/c/CompileUnit to bin (in the case of windows, the entire
contents of the directory). Then, TWX_StdLib.exe -buildFile
Gen/buildFiles/build3.txt to build the "new" version under
deploy3/..., copy the deploy3/...CompileUnit contents to bin as
before, you are ready to go at this point, the buildtw0 and deploy0
can be removed and you will probably want to build
Gen/buildFiles/build.txt (for the entire generator + library) or
Gen/buildFiles/buildlib.txt to just build a library and continue to
use the deploy3 generator with your own code.
In order to port to a platform not yet
defined, you must:
In Gen/CEmitter.tw you must add the
appropriate entries in to Gen:CompileProfile new(). Please look at
existing blocks for current platoforms for example. You must also
modify buildProfile() in StdLib/Process.tw. In many cases it will
just be a matter of adding the platform name to the existing list
(for Posix/Nixish platforms). If the port is to a significantly
different platform from the existing, further changes may be required
for IO:File, see the difference betwen FileNixish.tw and
FileMswin.tw, and the attendant platform buildfile differences for
example. A search for "linux" (including quotes) throughout
the codebase will point you at the required areas.
