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 Windows build and add cross compilation targets to CI #180

Merged
merged 1 commit into from
Jul 3, 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
44 changes: 44 additions & 0 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: cross
on:
pull_request: {}
push:
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- powerpc64le-unknown-linux-gnu
- s390x-unknown-linux-gnu
- x86_64-pc-windows-gnu
- x86_64-unknown-freebsd
- x86_64-pc-solaris
name: ${{matrix.target}}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate lockfile
run: cargo generate-lockfile
- name: Setup Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cross-${{matrix.target}}-${{ hashFiles('**/Cargo.lock') }}
- name: Install cross-rs
run: |
cargo install cross --git https://github.com/cross-rs/cross
cross --version
- name: Ensure the latest base image
run: docker pull ghcr.io/cross-rs/${{matrix.target}}:main
- name: Build for ${{matrix.target}}
run: cross build -v --target ${{matrix.target}}
12 changes: 5 additions & 7 deletions src/runtime/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub struct Process {

#[serde(default, skip_serializing_if = "Option::is_none")]
#[getset(get = "pub", set = "pub")]
#[cfg(any(target_os = "linux", target_os = "solaris"))]
/// Rlimits specifies rlimit options to apply to the process.
rlimits: Option<Vec<PosixRlimit>>,

Expand Down Expand Up @@ -147,6 +148,7 @@ impl Default for Process {
capabilities: Some(Default::default()),
// Sets the default maximum of 1024 files the process can open
// This is the same as the linux kernel default
#[cfg(any(target_os = "linux", target_os = "solaris"))]
rlimits: vec![PosixRlimit {
typ: PosixRlimitType::RlimitNofile,
hard: 1024,
Expand Down Expand Up @@ -187,27 +189,23 @@ pub struct Box {
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, StrumDisplay, EnumString)]
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[cfg(any(target_os = "linux", target_os = "solaris"))]
/// Available rlimit types (see <https://man7.org/linux/man-pages/man2/getrlimit.2.html>)
pub enum PosixRlimitType {
/// Limit in seconds of the amount of CPU time that the process can consume.
#[cfg(any(target_os = "linux", target_os = "solaris"))]
RlimitCpu,

/// Maximum size in bytes of the files that the process creates.
#[cfg(any(target_os = "linux", target_os = "solaris"))]
RlimitFsize,

/// Maximum size of the process's data segment (init data, uninit data and
/// heap) in bytes.
#[cfg(any(target_os = "linux", target_os = "solaris"))]
RlimitData,

/// Maximum size of the proces stack in bytes.
#[cfg(any(target_os = "linux", target_os = "solaris"))]
RlimitStack,

/// Maximum size of a core dump file in bytes.
#[cfg(any(target_os = "linux", target_os = "solaris"))]
RlimitCore,

/// Limit on the process's resident set (the number of virtual pages
Expand All @@ -221,15 +219,13 @@ pub enum PosixRlimitType {

/// One greator than the maximum number of file descritors that one process
/// may open.
#[cfg(any(target_os = "linux", target_os = "solaris"))]
RlimitNofile,

/// Maximum number of bytes of memory that may be locked into RAM.
#[cfg(target_os = "linux")]
RlimitMemlock,

/// Maximum size of the process's virtual memory(address space) in bytes.
#[cfg(any(target_os = "linux", target_os = "solaris"))]
RlimitAs,

/// Limit on the number of locks and leases for the process.
Expand Down Expand Up @@ -260,6 +256,7 @@ pub enum PosixRlimitType {
RlimitRttime,
}

#[cfg(any(target_os = "linux", target_os = "solaris"))]
impl Default for PosixRlimitType {
fn default() -> Self {
Self::RlimitCpu
Expand All @@ -276,6 +273,7 @@ impl Default for PosixRlimitType {
build_fn(error = "OciSpecError")
)]
#[getset(get_copy = "pub", set = "pub")]
#[cfg(any(target_os = "linux", target_os = "solaris"))]
/// RLimit types and restrictions.
pub struct PosixRlimit {
#[serde(rename = "type")]
Expand Down
Loading