Cross compile
This commit is contained in:
parent
a14f940d30
commit
db21c7a858
8
.cargo/config
Normal file
8
.cargo/config
Normal file
@ -0,0 +1,8 @@
|
||||
[target.aarch64-unknown-linux-musl]
|
||||
linker = "aarch64-linux-gnu-gcc"
|
||||
|
||||
[target.armv7-unknown-linux-musleabi]
|
||||
linker = "arm-linux-gnueabi-gcc"
|
||||
|
||||
[target.arm-unknown-linux-musleabi]
|
||||
linker = "arm-linux-gnueabi-gcc"
|
@ -1,3 +1,4 @@
|
||||
*
|
||||
!/src
|
||||
!/Cargo.*
|
||||
!/.cargo
|
||||
|
22
Cargo.toml
22
Cargo.toml
@ -14,25 +14,3 @@ tui = "0.14"
|
||||
termion = "1.5"
|
||||
serde = {version = "1.0", features = ["derive"]}
|
||||
confy = "0.4.0"
|
||||
|
||||
#[target.arm-linux-linux-muxl]
|
||||
#linker = "arm-linux-unknown-gcc"
|
||||
|
||||
[target.aarch64-linux-musl]
|
||||
linker = "aarch64-linux-gnu-gcc"
|
||||
|
||||
[target.aarch64-unknown-linux-musl]
|
||||
linker = "aarch64-linux-gnu-gcc"
|
||||
|
||||
[target.aarch64-unknown-linux-gcc]
|
||||
linker = "aarch64-linux-gnu-gcc"
|
||||
|
||||
# TODO: cross compilation
|
||||
# [target.arm-unknown-linux-gnueabihf]
|
||||
# linker = "arm-linux-gnueabihf-gcc"
|
||||
|
||||
# [target.armv7-unknown-linux-musleabi]
|
||||
# linker = "armv7-unknown-linux-musleabi-gcc"
|
||||
|
||||
# [target.aarch64-unknown-linux-musl]
|
||||
# linker = "aarch64-unknown-linux-musl-gcc"
|
||||
|
49
build.earth
49
build.earth
@ -1,34 +1,47 @@
|
||||
FROM rust:latest
|
||||
ENV CARGO_HOME=/deps
|
||||
ARG APP_NAME=rpn_rs
|
||||
WORKDIR /work
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu gdb-mingw-w64 gcc-mingw-w64-x86-64
|
||||
|
||||
deps:
|
||||
COPY ./Cargo.toml ./Cargo.lock .
|
||||
# This is a binary program, expose a main.rs file
|
||||
RUN mkdir src && touch src/main.rs
|
||||
RUN cargo fetch
|
||||
SAVE ARTIFACT /deps
|
||||
|
||||
build:
|
||||
ARG TOOLCHAIN
|
||||
RUN rustup target add $TOOLCHAIN
|
||||
SAVE IMAGE docker-wg:5000/rust-builder:$TOOLCHAIN
|
||||
rust-builder:
|
||||
RUN rustup target add x86_64-unknown-linux-musl
|
||||
RUN rustup target add x86_64-pc-windows-gnu
|
||||
RUN rustup target add i686-unknown-linux-musl
|
||||
RUN rustup target add aarch64-unknown-linux-musl
|
||||
RUN rustup target add arm-unknown-linux-musleabi
|
||||
RUN rustup target add armv7-unknown-linux-musleabi
|
||||
|
||||
RUN apt-get update
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu gdb-mingw-w64 gcc-mingw-w64-x86-64
|
||||
|
||||
SAVE IMAGE docker-wg:5000/rust-builder
|
||||
|
||||
build:
|
||||
FROM +rust-builder
|
||||
COPY . .
|
||||
COPY +deps/deps /deps
|
||||
COPY ./Cargo.toml ./Cargo.lock .
|
||||
COPY ./src/ ./src/
|
||||
|
||||
ARG TOOLCHAIN
|
||||
|
||||
RUN cargo build --release --target "$TOOLCHAIN"
|
||||
RUN strip "target/$TOOLCHAIN/release/rpn_rs"
|
||||
RUN xz --keep "target/$TOOLCHAIN/release/rpn_rs"
|
||||
SAVE ARTIFACT target/$TOOLCHAIN/release/rpn_rs AS LOCAL target/$TOOLCHAIN/release/rpn_rs-$TOOLCHAIN
|
||||
SAVE ARTIFACT target/$TOOLCHAIN/release/rpn_rs.xz AS LOCAL target/$TOOLCHAIN/release/rpn_rs-$TOOLCHAIN.xz
|
||||
ARG STRIP_CMD
|
||||
RUN "$STRIP_CMD" "target/$TOOLCHAIN/release/$APP_NAME"
|
||||
RUN xz --keep "target/$TOOLCHAIN/release/$APP_NAME"
|
||||
SAVE ARTIFACT target/$TOOLCHAIN/release/$APP_NAME AS LOCAL target/$TOOLCHAIN/release/$APP_NAME-$TOOLCHAIN
|
||||
SAVE ARTIFACT target/$TOOLCHAIN/release/$APP_NAME.xz AS LOCAL target/$TOOLCHAIN/release/$APP_NAME-$TOOLCHAIN.xz
|
||||
|
||||
all:
|
||||
BUILD --build-arg TOOLCHAIN=x86_64-unknown-linux-musl +build
|
||||
BUILD --build-arg TOOLCHAIN=i686-unknown-linux-musl +build
|
||||
BUILD --build-arg TOOLCHAIN=x86_64-unknown-linux-musl --build-arg STRIP_CMD=x86_64-linux-gnu-strip +build
|
||||
BUILD --build-arg TOOLCHAIN=i686-unknown-linux-musl --build-arg STRIP_CMD=x86_64-linux-gnu-strip +build
|
||||
BUILD --build-arg TOOLCHAIN=aarch64-unknown-linux-musl --build-arg STRIP_CMD=aarch64-linux-gnu-strip +build
|
||||
BUILD --build-arg TOOLCHAIN=arm-unknown-linux-musleabi --build-arg STRIP_CMD=arm-linux-gnueabi-strip +build
|
||||
BUILD --build-arg TOOLCHAIN=armv7-unknown-linux-musleabi --build-arg STRIP_CMD=arm-linux-gnueabi-strip +build
|
||||
# TODO: Cross compile to windows
|
||||
# BUILD --build-arg TOOLCHAIN=x86_64-pc-windows-gnu +build
|
||||
# TODO: Cross compile
|
||||
# BUILD --build-arg TOOLCHAIN=aarch64-unknown-linux-musl +build
|
||||
# BUILD --build-arg TOOLCHAIN=arm-unknown-linux-musleabi +build
|
||||
# BUILD --build-arg TOOLCHAIN=armv7-unknown-linux-musleabi +build
|
||||
|
Loading…
Reference in New Issue
Block a user