Skip to content

Commit

Permalink
specify PAX_WORKSPACE_ROOT in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelselleck committed Feb 1, 2024
1 parent fd72b84 commit 6a36ca4
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 48 deletions.
2 changes: 1 addition & 1 deletion examples/src/camera/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/color-grid/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/component_in_component/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/fireworks/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/grids/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/hello-rgb/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/layer-tests/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/one-rect/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/paths/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/playground/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/raycast-tests/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/simple-conditional/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/simple-stacker/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/three-repeats/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion examples/src/words/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
2 changes: 1 addition & 1 deletion pax-compiler/new-libdev-project-template/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
../target/debug/pax-cli "$@" --path="$current_dir" --libdev
PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev
popd
13 changes: 3 additions & 10 deletions pax-compiler/src/building/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! The `build_chassis_with_cartridge` function is the main entrypoint
use flate2::read::GzDecoder;
use libc::EXIT_FAILURE;
use pax_manifest::PaxManifest;
use std::{
collections::HashMap,
Expand Down Expand Up @@ -144,16 +145,8 @@ pub fn clone_all_to_pkg_dir(pax_dir: &PathBuf, pax_version: &Option<String>, ctx
if let Ok(specified_override) = std::env::var("PAX_WORKSPACE_ROOT") {
PathBuf::from(&specified_override)
} else {
pax_dir
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.into()
eprintln!("ERROR: environment PAX_WORKSPACE_ROOT needs to be set");
std::process::exit(EXIT_FAILURE);
};

let src = pax_workspace_root.join(pkg);
Expand Down
23 changes: 1 addition & 22 deletions pax-compiler/src/building/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{copy_dir_recursively, errors, pre_exec_hook, RunContext, RunTarget};
use color_eyre::eyre;
use colored::Colorize;
use std::fs;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use std::process::Command;
use std::sync::{Arc, Mutex};

Expand Down Expand Up @@ -37,27 +37,6 @@ pub fn build_web_chassis_with_cartridge(
.join(PKG_DIR_NAME)
.join(format!("pax-chassis-{}", target_str_lower));

if ctx.is_libdev_mode {
let mut cmd = Command::new("./build-interface.sh");
if let Ok(root) = std::env::var("PAX_WORKSPACE_ROOT") {
let chassis_web_path = Path::new(&root).join("pax-chassis-web");
cmd.current_dir(&chassis_web_path)
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped());
if !cmd
.output()
.expect("failed to start process")
.status
.success()
{
eprintln!(
"failed to build js files running ./build-interface.sh at {:?}",
chassis_web_path
);
};
}
}

let is_release: bool = ctx.is_release;

let build_mode_name: &str = if is_release { "release" } else { "debug" };
Expand Down
25 changes: 25 additions & 0 deletions pax-compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub struct RunContext {
pub is_release: bool,
}

#[derive(PartialEq)]
pub enum RunTarget {
#[allow(non_camel_case_types)]
macOS,
Expand All @@ -75,6 +76,30 @@ pub enum RunTarget {
/// then run it with a patched build of the `chassis` appropriate for the specified platform
/// See: pax-compiler-sequence-diagram.png
pub fn perform_build(ctx: &RunContext) -> eyre::Result<(), Report> {
//Compile ts files if applicable (this needs to happen before copying to .pax)
if ctx.is_libdev_mode && ctx.target == RunTarget::Web {
let mut cmd = Command::new("./build-interface.sh");
if let Ok(root) = std::env::var("PAX_WORKSPACE_ROOT") {
let chassis_web_path = Path::new(&root).join("pax-chassis-web");
cmd.current_dir(&chassis_web_path)
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped());
if !cmd
.output()
.expect("failed to start process")
.status
.success()
{
eprintln!(
"failed to build js files running ./build-interface.sh at {:?}",
chassis_web_path
);
};
} else {
eprintln!("Warning: PAX_WORKSPACE_ROOT env variable not set - didn't compile typescript files");
}
}

//First we clone dependencies into the .pax/pkg directory. We must do this before running
//the parser binary specifical for libdev in pax-example — see pax-example/Cargo.toml where
//dependency paths are `.pax/pkg/*`.
Expand Down

0 comments on commit 6a36ca4

Please sign in to comment.