Skip to content

Commit

Permalink
trying to configure cross compilation in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwellflitton committed Jan 10, 2025
1 parent a89b855 commit e6ec80c
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 53 deletions.
106 changes: 53 additions & 53 deletions .github/workflows/surrealml_deployment.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
release:
name: Release - ${{ matrix.platform.os-name }}
strategy:
matrix:
platform:
- os-name: FreeBSD-x86_64
runs-on: ubuntu-20.04
target: x86_64-unknown-freebsd
skip_tests: true

- os-name: Linux-x86_64
runs-on: ubuntu-20.04
target: x86_64-unknown-linux-musl

- os-name: Linux-aarch64
runs-on: ubuntu-20.04
target: aarch64-unknown-linux-musl

- os-name: Linux-riscv64
runs-on: ubuntu-20.04
target: riscv64gc-unknown-linux-gnu

- os-name: Windows-x86_64
runs-on: windows-latest
target: x86_64-pc-windows-msvc

- os-name: macOS-x86_64
runs-on: macOS-latest
target: x86_64-apple-darwin

# more targets here ...

runs-on: ${{ matrix.platform.runs-on }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: ${{ matrix.platform.command }}
target: ${{ matrix.platform.target }}
args: "--locked --release"
strip: true
- name: Publish artifacts and release
uses: houseabsolute/actions-rust-release@v0
with:
executable-name: ubi
target: ${{ matrix.platform.target }}
# on:
# pull_request:
# types: [opened, reopened, synchronize]

# jobs:
# release:
# name: Release - ${{ matrix.platform.os-name }}
# strategy:
# matrix:
# platform:
# - os-name: FreeBSD-x86_64
# runs-on: ubuntu-20.04
# target: x86_64-unknown-freebsd
# skip_tests: true

# - os-name: Linux-x86_64
# runs-on: ubuntu-20.04
# target: x86_64-unknown-linux-musl

# - os-name: Linux-aarch64
# runs-on: ubuntu-20.04
# target: aarch64-unknown-linux-musl

# - os-name: Linux-riscv64
# runs-on: ubuntu-20.04
# target: riscv64gc-unknown-linux-gnu

# - os-name: Windows-x86_64
# runs-on: windows-latest
# target: x86_64-pc-windows-msvc

# - os-name: macOS-x86_64
# runs-on: macOS-latest
# target: x86_64-apple-darwin

# # more targets here ...

# runs-on: ${{ matrix.platform.runs-on }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Build binary
# uses: houseabsolute/actions-rust-cross@v0
# with:
# command: ${{ matrix.platform.command }}
# target: ${{ matrix.platform.target }}
# args: "--locked --release"
# strip: true
# - name: Publish artifacts and release
# uses: houseabsolute/actions-rust-release@v0
# with:
# executable-name: ubi
# target: ${{ matrix.platform.target }}
Empty file added install/install_ml_c_lib.sh
Empty file.
4 changes: 4 additions & 0 deletions modules/c-wrapper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ RUN apt-get update && apt-get install -y \
build-essential \
libssl-dev \
pkg-config \
ca-certificates \
curl \
gnupg \
lsb-release \
&& rm -rf /var/lib/apt/lists/*

# Set the working directory
Expand Down
45 changes: 45 additions & 0 deletions modules/c-wrapper/corss-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM rust:1.81

# Install necessary tools and dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
clang \
cmake \
curl \
file \
git \
libssl-dev \
pkg-config \
python3 \
qemu-user-static \
wget \
xz-utils \
zlib1g-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Install Docker (for cross)
RUN curl -fsSL https://get.docker.com | sh

# Install Cross
RUN cargo install cross --git https://github.com/cross-rs/cross

# Add macOS cross-compilation toolchain using osxcross
# RUN git clone https://github.com/tpoechtrager/osxcross.git /osxcross \
# && cd ../osxcross \
# && wget -q https://github.com/tpoechtrager/osxcross/releases/download/v1.1/MacOSX10.11.sdk.tar.xz -O tarballs/MacOSX10.11.sdk.tar.xz \
# && UNATTENDED=1 ./build.sh

# ENV PATH="/osxcross/target/bin:$PATH"
# ENV CROSS_CONTAINER_IN_CONTAINER=true
# ENV MACOSX_DEPLOYMENT_TARGET=11.0

# # Add Windows cross-compilation toolchain
# RUN rustup target add x86_64-pc-windows-gnu aarch64-pc-windows-gnu

# # Add Linux cross-compilation toolchains
# RUN rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu

# Set up entrypoint for container
WORKDIR /project

ENTRYPOINT ["/bin/bash"]
18 changes: 18 additions & 0 deletions modules/c-wrapper/scripts/run_cross.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# navigate to directory
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
cd $SCRIPTPATH

cd ..

dockerd
sudo systemctl start docker
cross build --target aarch64-unknown-linux-gnu


docker run --rm -it \
-v "$(pwd):/project" \ # Mount the current directory to /project
-v /var/run/docker.sock:/var/run/docker.sock \ # Share host Docker socket
-w /project \ # Set the working directory inside the container
rust-cross-compiler

0 comments on commit e6ec80c

Please sign in to comment.