1.3 KiB
1.3 KiB
Multi-Target Static Rust Project from Git Repo
Using this Dockerfile one can build a statically linked Rust project from a Git repo (provided it has minimal external dependencies) in an Ubuntu (latest) container targeting both ARMv7 and i686.
Container Build
$ podman build -t crossbuild-multi -f multi-target-static-git
Build Example
This assumes PROJECT_DIR
is set to the path to which this repo was cloned.
The project built in this example is my connchk
crate.
$ mkdir ~/build_dir
$ cp ${PROJECT_DIR}/examples/multi-target-static-git.sh ~/build_dir/
$ podman run --rm -it -e GIT_REPO="https://git.staart.one/ajmartinez/connchk.git" \
-e BIN_NAME="connchk" \
-v "${HOME}/build_dir:/opt/build:z \
crossbuild-multi:latest \
/opt/build/multi-target-static-git.sh
# Build output redacted
$ file build_dir/*_connchk
build_dir/armv7-unknown-linux-gnueabihf_connchk: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, BuildID[sha1]=f4c5af4314c56d6d2a6d4a1743ca3e3ccd0f955d, for GNU/Linux 3.2.0, stripped
build_dir/i686-unknown-linux-gnu_connchk: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, BuildID[sha1]=e9937cbc4f944b66aedd393ef270be9ab85002da, for GNU/Linux 3.2.0, stripped