Skip to content

Commit

Permalink
fix: add wasm to possible targets
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Nov 8, 2024
1 parent 4dfbd11 commit f74da3d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
1 change: 0 additions & 1 deletion workspace/gh-workflow-gen/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ fn main() {
.on(on_push)
.on(on_pull_request)
.add_job("build", job_build)
.unwrap()
.generate()
.unwrap();
}
16 changes: 12 additions & 4 deletions workspace/gh-workflow/src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub enum Arch {
X86_64,
Aarch64,
Arm,
Wasm32,
}

impl Display for Arch {
Expand All @@ -60,6 +61,7 @@ impl Display for Arch {
Arch::X86_64 => "x86_64",
Arch::Aarch64 => "aarch64",
Arch::Arm => "arm",
Arch::Wasm32 => "wasm32",
};
write!(f, "{}", val)
}
Expand Down Expand Up @@ -125,10 +127,10 @@ impl Display for Abi {

#[derive(Clone, Setters)]
pub struct Target {
arch: Arch,
vendor: Vendor,
system: System,
abi: Option<Abi>,
pub arch: Arch,
pub vendor: Vendor,
pub system: System,
pub abi: Option<Abi>,
}

/// A Rust representation for the inputs of the setup-rust action.
Expand All @@ -139,6 +141,7 @@ pub struct Target {
#[setters(strip_option)]
pub struct ToolchainStep {
pub toolchain: Vec<Toolchain>,
#[setters(skip)]
pub target: Option<Target>,
pub components: Vec<Component>,
pub cache: Option<bool>,
Expand Down Expand Up @@ -181,6 +184,11 @@ impl ToolchainStep {
self.components.push(Component::Rustfmt);
self
}

pub fn target(mut self, arch: Arch, vendor: Vendor, system: System, abi: Option<Abi>) -> Self {
self.target = Some(Target { arch, vendor, system, abi });
self
}
}

impl AddStep for ToolchainStep {
Expand Down
9 changes: 3 additions & 6 deletions workspace/gh-workflow/src/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use serde_json::Value;

use crate::error::{Error, Result};
use crate::error::Result;
use crate::generate::Generate;
use crate::{EventValue, ToolchainStep};

Expand Down Expand Up @@ -57,14 +57,11 @@ impl Workflow {
Ok(serde_yaml::to_string(self)?)
}

pub fn add_job<T: ToString, J: Into<Job>>(mut self, id: T, job: J) -> Result<Self> {
pub fn add_job<T: ToString, J: Into<Job>>(mut self, id: T, job: J) -> Self {
let key = id.to_string();
if self.jobs.contains_key(&key) {
return Err(Error::JobIdAlreadyExists(key.as_str().to_string()));
}

self.jobs.insert(key, job.into());
Ok(self)
self
}

pub fn parse(yml: &str) -> Result<Self> {
Expand Down

0 comments on commit f74da3d

Please sign in to comment.