Skip to content
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
71 changes: 37 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ defaults:
shell: bash
env:
PEXRC_INSTALL_TOOLS: 1
PEXRC_PROFILE: release

concurrency:
group: CI-${{ github.ref }}
Expand All @@ -19,36 +18,7 @@ jobs:
steps:
- name: Noop
if: false
run: |
echo "This is a dummy step that will never run."

build:
name: "${{ matrix.name }} build"
needs: setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
# N.B.: macos-14 is the oldest non-deprecated ARM Mac runner.
include:
- name: Linux aarch64
os: ubuntu-22.04-arm
- name: Linux x86_64
os: ubuntu-22.04
- name: Mac aarch64
os: macos-14
- name: Mac x86_64
os: macos-15-intel
- name: Windows aarch64
os: windows-11-arm
- name: Windows x86_64
os: windows-2022
steps:
- name: Checkout Pexrc
uses: actions/checkout@v6
- name: Build pexrc binary for all targets.
run: |
PEXRC_TARGETS=all cargo build --release
target/release/pexrc info
run: echo "This is a dummy step that will never run."

checks:
name: "Check Formatting and Lints"
Expand All @@ -63,6 +33,39 @@ jobs:
cargo +nightly fmt --check --all
cargo clippy --locked --all

cross-build:
name: "Cross-build pexrc"
needs: setup
runs-on: ubuntu-22.04-arm
# N.B.: We break these up just to save wall time; they all can be built on 1 machine in ~40
# minutes; this gets us to a ~20 minute long-pole.
strategy:
matrix:
include:
- targets: >-
--target aarch64-unknown-linux-gnu
--target aarch64-unknown-linux-musl
- targets: >-
--target armv7-unknown-linux-gnueabihf
--target powerpc64le-unknown-linux-gnu
- targets: >-
--target riscv64gc-unknown-linux-gnu
--target s390x-unknown-linux-gnu
- targets: >-
--target x86_64-unknown-linux-gnu
--target x86_64-unknown-linux-musl
- targets: >-
--target aarch64-apple-darwin
--target x86_64-apple-darwin
- targets: >-
--target aarch64-pc-windows-gnullvm
--target x86_64-pc-windows-gnu
steps:
- name: Checkout Pexrc
uses: actions/checkout@v6
- name: Build pexrc binary for all targets.
run: cargo run -p package -- --profile release ${{ matrix.targets }}

tests:
name: "${{ matrix.name }} tests"
needs: setup
Expand All @@ -89,15 +92,15 @@ jobs:
- name: Run Tests
run: |
cargo test --all
uv run dev-cmd test -- -vvs
PEXRC_PROFILE=release uv run dev-cmd test -- -vvs

final-status:
name: Gather Final Status
needs:
- build
- checks
- cross-build
- tests
runs-on: ubuntu-24.04
runs-on: ubuntu-slim
steps:
- name: Check Non-Success
if: |
Expand Down
15 changes: 15 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"crates/cache",
"crates/clib",
"crates/interpreter",
"crates/package",
"crates/pex",
"crates/pexrc-build-system",
"crates/pexrs",
Expand Down Expand Up @@ -98,7 +99,7 @@ anyhow = "1.0"
base64 = "0.22"
bstr = "1.12"
build-target = "0.8"
clap = { version = "4.5", features = ["derive"] }
clap = { version = "4.5", features = ["derive", "string"] }
clap-verbosity-flag = "3.0"
colorchoice-clap = "1.0"
const_format = { version = "0.2", features = ["rust_1_64"] }
Expand Down
55 changes: 7 additions & 48 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2026 Pex project contributors.
// SPDX-License-Identifier: Apache-2.0

use std::borrow::Cow;
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
Expand All @@ -15,8 +14,6 @@ use pexrc_build_system::{
ClassifiedTargets,
ClibConfiguration,
FoundTool,
InstallDirs,
ToolInstallation,
classify_targets,
ensure_tools_installed,
};
Expand All @@ -27,57 +24,19 @@ fn main() -> anyhow::Result<()> {
env_logger::init();

let cargo: PathBuf = env::var("CARGO")?.into();

let target_dir: PathBuf = if let Some(custom_target_dir) = env::var_os("CARGO_TARGET_DIR") {
custom_target_dir.into()
} else {
PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("target")
};

let install_dirs = InstallDirs::system("pexrc-dev").unwrap_or_else(|| {
let cache_base_dir = target_dir.join(".pexrc-dev");
println!(
"cargo::warning=Failed to discover the user cache dir; using {cache_base_dir}",
cache_base_dir = cache_base_dir.display()
);
InstallDirs::new(cache_base_dir)
});

let cargo_manifest_contents = {
let manifest_path = env::var("CARGO_MANIFEST_PATH")?;
println!("cargo::rerun-if-changed={manifest_path}");
fs::read_to_string(manifest_path)?
};

println!("cargo::rerun-if-env-changed=PEXRC_INSTALL_TOOLS");
let install_missing_tools = env::var_os("PEXRC_INSTALL_TOOLS").unwrap_or_default() == "1";

let tool_installation = ensure_tools_installed(
&cargo,
&cargo_manifest_contents,
install_dirs,
install_missing_tools,
)?;
let (mut clib, glibc, found_tools) = match tool_installation {
ToolInstallation::Success(results) => results,
ToolInstallation::Failure((zig, missing_binstall_tools, tool_search_path)) => {
bail!(
"The following tools are required but are not installed: {tools}\n\
Searched PATH: {search_path}\n\
Re-run with PEXRC_INSTALL_TOOLS=1 to let the build script install these tools.",
tools = missing_binstall_tools
.iter()
.map(|tool| Cow::Borrowed(tool.binary_name()))
.chain(
zig.missing_version()
.iter()
.map(|version| Cow::Owned(format!("zig@{version}")))
)
.join(" "),
search_path = tool_search_path.display()
);
}
let target_dir: PathBuf = if let Some(custom_target_dir) = env::var_os("CARGO_TARGET_DIR") {
custom_target_dir.into()
} else {
PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("target")
};

let (mut clib, glibc, found_tools) =
ensure_tools_installed(&cargo, &cargo_manifest_contents, &target_dir, true)?;
println!("cargo::rerun-if-env-changed=PROFILE");
let profile = env::var("PROFILE")?;
let clib = clib.configuration_for(&profile);
Expand Down
13 changes: 13 additions & 0 deletions crates/package/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "package"
edition = "2024"

[dependencies]
anstream = { workspace = true }
anyhow = { workspace = true }
clap = { workspace = true }
clap-verbosity-flag = { workspace = true }
colorchoice-clap = { workspace = true }
env_logger = { workspace = true }
owo-colors = { workspace = true }
pexrc-build-system = { path = "../pexrc-build-system" }
Loading