Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cross compile support to Linux and Windows OS with x86_64 archs. #34

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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*
20 changes: 20 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pipeline {
agent any
stages {
stage('check deps') {
steps {
sh 'cargo --version'
}
}
stage('compile') {
steps {
sh 'cargo build'
}
}
stage('run with cargo') {
steps {
sh 'cargo run'
}
}
}
}
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"]