top
up

29Cross-compiling Racket Sources for iOSπŸ”— i

See API for Cross-Platform Configuration for general information on using Racket in cross-build mode. Everything in this section can be adapted to other cross-compilation targets, but iOS is used to make the examples concrete.

After cross-compiling Racket CS for iOS according to the source distribution’s "src/README.txt" file, you can use that build ios-racket-dir in conjunction with the host build it was compiled by to cross-compile Racket modules for iOS by passing the following set of flags to the host executable:

racket\

--compile-any\

--compiled ios-racket-dir/src/build/cs/c/compiled:\

--cross\

--cross-compiler tarm64osx ios-racket-dir/src/build/cs/c\

--config ios-racket-dir/etc\

--collects ios-racket-dir/collects

The above command runs the host Racket REPL with support for writing compiled code for both the host machine and for the tarm64osx target. The first path to --compiled (before the :) can be any absolute path, and ".zo" files for the host platform will be written there; specifying the path "ios-racket-dir/src/build/cs/c/compiled" is meant to reuse the directory that was created during cross-compilation installation. The second path to --compiled (after :) is empty, which causes target-platform ".zo" files to be written in the usual "compiled" subdirectory.

Instruct the host Racket to run library code by passing the -l flag. For example, you can setup the target Racket’s installation with the following command:

racket\

--compile-any\

--compiled ios-racket-dir/src/build/cs/c/compiled:\

--cross\

--cross-compiler tarm64osx ios-racket-dir/lib\

--config ios-racket-dir/etc\

--collects ios-racket-dir/collects\

-l-\

raco setup

Finally, you can package up a Racket module and its dependencies for use with racket_embedded_load_file (after installing "compiler-lib" and "cext-lib" for the target Racket) with:

racket\

--compile-any\

--compiled ios-racket-dir/src/build/cs/c/compiled:\

--cross\

--cross-compiler tarm64osx ios-racket-dir/lib\

--config ios-racket-dir/etc\

--collects ios-racket-dir/collects\

-l-\

raco ctool --mods application.zo src/application.rkt

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /