Skip to content

vassilvk/cross-pony-docker

Repository files navigation

cross-pony

Utility Docker image for cross-compiling Pony programs.

Cross-compile Pony?

Use this image to compile and link Pony programs to any of the supported target platforms regardless of the host platform. For example, one can build Windows executables while running this image on a Linux host.

Currently supported target platforms:

  • Linux x64
  • Linux arm64v8
  • Windows x64

Simple Example

To build a Pony program, run the following from the root of your Pony project:

docker run --rm -it -v /$(pwd):/src/main vassilvk/cross-pony <target>

...where <target> is one of the following:

  • linux-amd64
  • linux-arm64v8
  • windows-amd64

Pony stable

If your project includes file bundle.json, cross-pony will perform stable fetch to pull in the project's dependencies, then it will compile your project through stable env ponyc....

Passing arguments to ponyc

You can pass parameters to the underlying ponyc call - every argument past <target> is relayed to ponyc.

For example, the following will pass flag --debug to ponyc to build your project in debug mode:

docker run --rm -it -v /$(pwd):/src/main vassilvk/cross-pony windows-amd64 --debug

Executable name

The image assumes that your project is called main. This is reflected in the name of the executable generated by the image. For example, depending on the target architecture, you'll end up with one of the following binaries:

  • Linux x64 - main-linux-amd64
  • Linux arm64v8 - main-linux-arm64v8
  • Windows x64 - main-windows-amd64

If you are building a subfolder of your project, you need use ponyc's -b option to set the output binary name to main.

This example will build the project's test subfolder:

docker run --rm -it -v /$(pwd):/src/main vassilvk/cross-pony windows-amd64 ./test -b main

Using extra libraries

The image includes all the necessary libraries required to build projects which use Pony's standard library. If your program imports external libraries, you will need to mount them into the respective target platform's folder (see below) and pass the library names to the container through variable EXTRA_LIBS.

Extra libraries should be volume-mounted into their respective location in the container:

  • Linux x64 libraries: /usr/local/lib/extra/linux-amd64/
  • Linux arm64v8 libraries: /usr/local/lib/extra/linux-arm64v8/
  • Windows x64 libraries: /usr/local/lib/extra/windows-amd64/

For example, jemc/pony-zmq uses libsodium. Follow these steps to build its tests for Windows:

  • Clone jemc/pony-zmq
  • Download libsodium's Windows binaries (for example libsodium-1.0.16-msvc.zip)
  • Unzip the x64 static library libsodium.lib into your project's lib/windows-amd64 folder
  • Run the following in the project's folder:
docker run --rm -it -v /$(pwd):/src/main -v /$(pwd)/lib/windows-amd64:/usr/local/lib/extra/windows-amd64 -e EXTRA_LIBS="libsodium" vassilvk/cross-pony windows-amd64 zmq/test -b main

This will compile and link pony-zmq's test suite into Windows executable main-windows-amd64.exe.

Image contents

The image contains the following:

  • ponyc 0.21.3 + LLVM 3.9.1
  • LLVM 6.0.1

About

Docker image for ponylang cross-compilation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages