Skip to content

Commit

Permalink
Add cross compile support to Linux and Windows OS with x86_64 archs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmosc committed Feb 17, 2023
1 parent a96b91a commit 1f1bb5c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/target
target*
*.env
*cache*
10 changes: 10 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pipeline {
agent { any { image 'rust:latest' } }
stages {
stage('build') {
steps {
sh 'rust --version'
}
}
}
}
12 changes: 11 additions & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ error() {
main() {
BIN_PATH="/usr/local/bin";
BIN_NAME="gptc";
URL="https://github.com/dmosc/gptc/releases/latest/download/gptc";
OS=$(uname -s);
ARCH=$(uname -m);
URL="https://github.com/dmosc/gptc/releases/latest/download/gptc-$OS-$ARCH";

if [[ $OS != *"Linux"* || $OS != *"Darwin"* || $OS != *"Windows"* ]]; then
error "Unsupported operating system: $OS";
fi

if [[ $ARCH != *"x86_64"* || $ARCH != *"arm64"* || $ARCH != *"aarch64"* ]]; then
error "Unsupported architecture: $ARCH";
fi

if [[ $SHELL == *"/zsh" ]]; then
SHELL_PROFILE="$HOME/.zshrc";
Expand Down
11 changes: 11 additions & 0 deletions x86_64-linux.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM amd64/rust:latest

WORKDIR /app
COPY . .
RUN apt update
RUN apt upgrade -y
RUN apt install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
RUN rm -rf /var/lib/apt/lists/*
RUN cargo install --path .
ENV CARGO_TARGET_DIR=target.x86_64-linux
CMD ["cargo", "build", "--release"]
10 changes: 10 additions & 0 deletions x86_64-windows.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM rust:latest

WORKDIR /app
RUN apt update
RUN apt upgrade -y
RUN apt install -y g++-mingw-w64-x86-64
RUN rustup target add x86_64-pc-windows-gnu
RUN rustup toolchain install stable-x86_64-pc-windows-gnu
ENV CARGO_TARGET_DIR=target/target.x86_64-windows
CMD ["cargo", "build", "--release", "--target", "x86_64-pc-windows-gnu"]

0 comments on commit 1f1bb5c

Please sign in to comment.