Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Peco602/rust-universal-compiler
Container solution to compile Rust projects for Linux, macOS and Windows
https://github.com/Peco602/rust-universal-compiler
container cross-compilation docker linux macos rust windows
Last synced: about 2 months ago
JSON representation
Container solution to compile Rust projects for Linux, macOS and Windows
- Host: GitHub
- URL: https://github.com/Peco602/rust-universal-compiler
- Owner: Peco602
- License: mit
- Created: 2022-06-28T10:38:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-30T17:04:02.000Z (over 1 year ago)
- Last Synced: 2024-08-01T05:20:40.298Z (5 months ago)
- Topics: container, cross-compilation, docker, linux, macos, rust, windows
- Language: Dockerfile
- Homepage:
- Size: 9.77 KB
- Stars: 27
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-docker - Rust Universal Compiler - Container solution to compile Rust projects for Linux, macOS and Windows. By [@Peco602][peco602] (Development with Docker / Development Environment)
README
![Test](https://github.com/Peco602/rust-universal-compiler/actions/workflows/test.yml/badge.svg)
[![Mentioned in awesome-docker](https://awesome.re/mentioned-badge.svg)](https://github.com/veggiemonk/awesome-docker)# Rust Universal Compiler Docker image
Container solution to compile Rust projects for Linux, macOS and Windows.
## Build the image
```ps1
docker build -t rust-universal-compiler:latest .
```## Configure the project
To allow cross-compilation from Linux to Windows and MacOS, it is necessary to create in the project folder the `.cargo/config` file containing the following lines:
```ini
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"][target.x86_64-apple-darwin]
linker = "x86_64-apple-darwin14-clang"
ar = "x86_64-apple-darwin14-ar"
```## Compile the project
Compile for Linux (`x86_64-unknown-linux-gnu`):
```bash
docker run --rm -v $PWD/test-project:/app -w /app rust-universal-compiler:latest cargo build --target x86_64-unknown-linux-gnu --release
```Compile for MacOS (`x86_64-apple-darwin`):
```bash
docker run --rm -v $PWD/test-project:/app -w /app rust-universal-compiler:latest cargo build --target x86_64-apple-darwin --release
```Compile for Windows (`x86_64-pc-windows-msvc`):
```bash
docker run --rm -v $PWD/test-project:/app -w /app rust-universal-compiler:latest cargo build --target x86_64-pc-windows-msvc --release
```## DockerHub
- [peco602/rust-universal-compiler](https://hub.docker.com/r/peco602/rust-universal-compiler)
## Bibliography
- https://github.com/Jake-Shadle/xwin
- https://wapl.es/rust/2019/02/17/rust-cross-compile-linux-to-macos.html