Saves a universal binary LispWorks image using a script designed for saving a mono-architecture image.
hcl
save-universal-from-script script-name &key output-stream split keep-temps => target-image
script-name⇩ |
A pathname designator. |
output-stream⇩ |
A stream, t or nil . |
split⇩ | nil , t or :resources . |
keep-temps⇩ |
A boolean. |
target-image⇩ |
A pathname designator. |
The function save-universal-from-script
provides a convenient way to create a universal binary on a macOS Apple silicon (arm64) computer, using a script designed for saving a mono-architecture image.
script-name is the name of a LispWorks build script (written in Lisp) for saving or delivering an image, as would be used to create a mono-architecture image. It should load the application and then call either deliver or save-image as appropriate.
save-universal-from-script
runs the current LispWorks image in two subprocesses, once for the native arm64 architecture and once for the x86_64 architecture, passing -build script-name
on the command line. The contents of script-name are evaluated as normal, except that the images are written to temporary files rather than to the filenames that are passed to save-image or deliver. If these two subprocesses are successful, then the temporary files are combined to make a universal binary in the same way as create-universal-binary.
The arm64 subprocess is run first, and the filename argument that the script supplies to deliver or save-image in this subprocess is recorded and later used by save-universal-from-script
as the target-name for creating the universal binary. During the arm64 run, calls to the function building-main-architecture-p return t
.
The x86_64 subprocess runs second. The filename argument that the script supplies to deliver or save-image in this subprocess is ignored completely, and calls to the function building-main-architecture-p return nil
inside this subprocess.
Calls to the function building-universal-intermediate-p return t
in both subprocesses.
The command line arguments of the images run by the subprocesses will include the command line arguments that were passed to the current image. In addition, various undocumented command line arguments will be prepended, which control how deliver or save-image work in the script.
If output-stream is non-nil, then any output generated by the subprocesses is written to it. If output-stream is t
(the default), then the output is written to *standard-output*. If output-stream is nil
, then the output is discarded.
split can be used to control the splitting of the universal binary. It has the same behaviour as in save-image. Normally it is more convenient not to use split and rely on the default value.
If keep-temps is non-nil, the temporary files that save-universal-from-script
creates are not deleted. which is sometimes useful for debugging.
The result target-image is the path of the universal binary that was created.
save-universal-from-script
can only be called from a LispWorks for Macintosh image that is itself a universal binary, such as the distributed image, and is running on an Apple silicon (arm64) computer.
The script may contain code that should execute only once, for example creating a macOS bundle structure. Call building-main-architecture-p to control such code, as in the example.
When building a universal binary, the Application Builder in the LispWorks IDE does exactly the same as save-universal-from-script
, except for how it displays the output.
save-universal-from-script
signals an error if load-all-patches has not been called in the current session.
In LispWorks 6,1 for Macintosh and earlier versions, save-universal-from-script
had an additional argument, target-name. As described above, the target name is now determined by the argument to save-image or deliver in the main architecture run (that is arm64 run).
In LispWorks 7.0 and 7.1, save-universal-from-script
was deprecated and always signaled an error.
The example file:
(example-edit-file "configuration/save-macos-application.lisp")
demonstrates how to save an image with your configuration, and is intended to be used in the Application Builder, but you can also use it as an argument to save-universal-from-script
. Create a file with your configuraion in ~/my-configuration.lisp
, and then evaluate:
(save-universal-from-script (example-file "configuration/save-macos-application.lisp"))
save-image
create-universal-binary
building-universal-intermediate-p
building-main-architecture-p
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:35