Skip to content

Commit

Permalink
chore(actors-sdk-embed): auto-build & install manager dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Jan 29, 2025
1 parent a5bd03c commit 6489694
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
41 changes: 39 additions & 2 deletions packages/toolchain/actors-sdk-embed/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,24 @@ use std::{

#[tokio::main]
async fn main() -> Result<()> {
// Check if yarn is installed
let yarn_check = tokio::process::Command::new("yarn")
.arg("--version")
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.await;
ensure!(
yarn_check.is_ok() && yarn_check.unwrap().success(),
"yarn is not installed, please install yarn to build this project"
);

let manifest_dir = std::env::var("CARGO_MANIFEST_DIR")?;
let out_dir = std::env::var("OUT_DIR")?;

let sdk_path = PathBuf::from(manifest_dir.clone()).join("../../../sdks/actor");
let project_root = PathBuf::from(manifest_dir.clone()).join("../../..");
let sdk_path = project_root.join("sdks/actor");
let manager_path = sdk_path.join("manager");

// Copy SDK directory to out_dir
let dist_path = Path::new(&out_dir).join("actor-sdk");
Expand All @@ -22,7 +36,26 @@ async fn main() -> Result<()> {
fs::remove_dir_all(&dist_path).context("fs::remove_dir_all")?;
}

// Build manager
// Build manager dependencies (required for building the manager itself)
let status = tokio::process::Command::new("yarn")
.arg("install")
.arg("--immutable")
.current_dir(&manager_path)
.status()
.await?;
ensure!(status.success(), "yarn install failed");

let status = tokio::process::Command::new("yarn")
.arg("run")
.arg("build")
.arg("--filter=@rivet-gg/actor-manager")
.current_dir(&project_root)
.status()
.await?;
ensure!(status.success(), "yarn build failed");

// Build manager using Rivet build script (not using tsup/turbo because this includes custom
// polyfill functionality)
build_backend_command_raw(CommandOpts {
task_path: "src/tasks/build/mod.ts",
input: json!({
Expand All @@ -38,7 +71,9 @@ async fn main() -> Result<()> {
})
.await?;

// Rebuild if SDK changes (in order to include manager dependencies)
println!("cargo:rerun-if-changed={}", sdk_path.display());

println!(
"cargo:rustc-env=ACTOR_SDK_DIST_PATH={}",
dist_path.display()
Expand Down Expand Up @@ -83,6 +118,8 @@ pub async fn build_backend_command_raw(opts: CommandOpts) -> Result<()> {
// Serialize command
let input_json = serde_json::to_string(&opts.input)?;

// Yarn install

// Run backend
let status = tokio::process::Command::new(deno.executable_path)
.args([
Expand Down
1 change: 0 additions & 1 deletion packages/toolchain/js-utils-embed/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use merkle_hash::MerkleTree;
use std::{
fs,
path::{Path, PathBuf},
process::Stdio,
};

#[tokio::main]
Expand Down
1 change: 0 additions & 1 deletion packages/toolchain/toolchain/src/tasks/deploy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use anyhow::*;
use rivet_api::{apis, models};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::Path;
use uuid::Uuid;

use crate::{
Expand Down

0 comments on commit 6489694

Please sign in to comment.