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

fix: build ffi script #320

Merged
merged 1 commit into from
Aug 21, 2024
Merged
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
163 changes: 130 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions rivet-toolchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ uuid = { version = "1.3", features = ["v4"] }
webbrowser = "0.8.7"
which = "5.0.0"
zip = "0.5"
const_format = "0.2.32"

[target.'cfg(unix)'.dependencies]
nix = { version = "0.27", default-features = false, features = ["user", "signal"] }
Expand All @@ -64,5 +65,5 @@ assert_cmd = "2.0"

[build-dependencies]
anyhow = "1.0"
vergen = { version = "7.5", default-features = false, features = ["build", "git", "rustc", "cargo"] }

vergen-git2 = "1.0.0"
pkg-version = "1.0.0"
10 changes: 6 additions & 4 deletions rivet-toolchain/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use anyhow::Result;
use vergen::{vergen, Config};
use vergen_git2::{Emitter, Git2Builder};

fn main() -> Result<()> {
let mut config = Config::default();
*config.git_mut().sha_kind_mut() = vergen::ShaKind::Both;
vergen(config)
Emitter::default()
.add_instructions(&Git2Builder::default().sha(true).build()?)?
.emit()?;

Ok(())
}
14 changes: 8 additions & 6 deletions rivet-toolchain/src/ctx.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use global_error::prelude::*;
use rivet_api::apis;
use std::{env, sync::Arc};
use pkg_version::{pkg_version_major, pkg_version_minor, pkg_version_patch};

use crate::config;

pub const VERSION: &str = concat!(
env!("VERGEN_BUILD_SEMVER"),
" (",
env!("VERGEN_GIT_SHA_SHORT"),
")"
);
pub const VERSION: &str = {
const MAJOR: u32 = pkg_version_major!();
const MINOR: u32 = pkg_version_minor!();
const PATCH: u32 = pkg_version_patch!();
const GIT_SHA: &str = env!("VERGEN_GIT_SHA");
const_format::formatcp!("{MAJOR}.{MINOR}.{PATCH} ({GIT_SHA})")
};

pub fn user_agent() -> String {
format!("CLI/{VERSION}")
Expand Down
43 changes: 22 additions & 21 deletions scripts/build_ffi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*

# Install osxcross
RUN git config --global --add safe.directory '*'
RUN git clone https://github.com/tpoechtrager/osxcross /root/osxcross
WORKDIR /root/osxcross
RUN wget -nc https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz
Expand Down Expand Up @@ -67,34 +68,34 @@ set -e
# ls /root/osxcross/target/bin
# exit 1
echo "Building for x86 Linux..."
# cargo build --target x86_64-unknown-linux-gnu
# echo "Building for x86 Windows..."
# cargo build --target x86_64-pc-windows-gnu
cargo build --target x86_64-unknown-linux-gnu
echo "Building for x86 Windows..."
cargo build --target x86_64-pc-windows-gnu
echo "Building for x86 macOS..."
cargo build --target x86_64-apple-darwin
# echo "Building for ARM macOS..."
# cargo build --target aarch64-apple-darwin
echo "Building for ARM macOS..."
cargo build --target aarch64-apple-darwin
'

# docker run -it --rm -v "$(pwd)":/app rust-cross-compiler /bin/sh -c '
# set -e
# echo "Building for x86 Linux..."
# cargo build --target x86_64-unknown-linux-gnu --release
# echo "Building for x86 Windows..."
# cargo build --target x86_64-pc-windows-gnu --release
# echo "Building for x86 macOS..."
# cargo build --target x86_64-apple-darwin --release
# echo "Building for ARM macOS..."
# cargo build --target aarch64-apple-darwin --release
# '
docker run -it --rm -v "$(pwd)":/app rust-cross-compiler /bin/sh -c '
set -e
echo "Building for x86 Linux..."
cargo build --target x86_64-unknown-linux-gnu --release
echo "Building for x86 Windows..."
cargo build --target x86_64-pc-windows-gnu --release
echo "Building for x86 macOS..."
cargo build --target x86_64-apple-darwin --release
echo "Building for ARM macOS..."
cargo build --target aarch64-apple-darwin --release
'

echo "Build process completed."
echo "Built libraries can be found at:"
# echo "x86 Linux: target/x86_64-unknown-linux-gnu/release/"
# echo "x86 Windows: target/x86_64-pc-windows-gnu/release/"
# echo "x86 macOS: target/x86_64-apple-darwin/release/"
# echo "ARM macOS: target/aarch64-apple-darwin/release/"
echo "x86 Linux: target/x86_64-unknown-linux-gnu/release/"
echo "x86 Windows: target/x86_64-pc-windows-gnu/release/"
echo "x86 macOS: target/x86_64-apple-darwin/release/"
echo "ARM macOS: target/aarch64-apple-darwin/release/"
echo "x86 Linux: target/x86_64-unknown-linux-gnu/debug/"
echo "x86 Windows: target/x86_64-pc-windows-gnu/debug/"
echo "x86 macOS: target/x86_64-apple-darwin/debug/"
echo "ARM macOS: target/aarch64-apple-darwin/debug/"
echo "ARM macOS: target/aarch64-apple-darwin/debug/"
Loading