Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Build examples in debug mode
  • Loading branch information
bugadani committed Sep 4, 2024
commit e8afa156ad24e60dbbeb1bd7afaf40aec71d2e0f
2 changes: 1 addition & 1 deletion .github/actions/check-esp-hal/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ runs:
esp-hal
- name: Build (examples)
shell: bash
run: cargo +${{ inputs.toolchain }} xtask build-examples esp-hal ${{ inputs.device }}
run: cargo +${{ inputs.toolchain }} xtask build-examples esp-hal ${{ inputs.device }} --debug
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
cargo xtask build-package --features=esp32c3,wifi,ble,async --target=riscv32imc-unknown-none-elf esp-wifi
cargo xtask build-package --features=esp32c6,wifi,ble,async --target=riscv32imac-unknown-none-elf esp-wifi
cargo xtask build-package --features=esp32h2,ble,async --target=riscv32imac-unknown-none-elf esp-wifi

# Verify the MSRV for all Xtensa chips:
- name: msrv Xtensa (esp-hal)
run: |
Expand Down
8 changes: 8 additions & 0 deletions xtask/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ impl CargoArgsBuilder {
self
}

pub fn add_arg<S>(&mut self, arg: S) -> &mut Self
where
S: Into<String>,
{
self.args.push(arg.into());
self
}

#[must_use]
pub fn build(self) -> Vec<String> {
let mut args = vec![];
Expand Down
22 changes: 18 additions & 4 deletions xtask/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ pub fn execute_app(
app: &Metadata,
action: CargoAction,
repeat: usize,
debug: bool,
) -> Result<()> {
log::info!(
"Building example '{}' for '{}'",
Expand All @@ -225,7 +226,16 @@ pub fn execute_app(
};

for features in feature_sets {
execute_app_with_features(package_path, chip, target, app, action, repeat, features)?;
execute_app_with_features(
package_path,
chip,
target,
app,
action,
repeat,
features,
debug,
)?;
}

Ok(())
Expand All @@ -241,6 +251,7 @@ pub fn execute_app_with_features(
action: CargoAction,
mut repeat: usize,
mut features: Vec<String>,
debug: bool,
) -> Result<()> {
if !features.is_empty() {
log::info!("Features: {}", features.join(","));
Expand Down Expand Up @@ -269,19 +280,22 @@ pub fn execute_app_with_features(

let mut builder = CargoArgsBuilder::default()
.subcommand(subcommand)
.arg("--release")
.target(target)
.features(&features)
.arg(bin);

if !debug {
builder.add_arg("--release");
}

if subcommand == "test" && chip == Chip::Esp32c2 {
builder = builder.arg("--").arg("--speed").arg("15000");
builder.add_arg("--").add_arg("--speed").add_arg("15000");
}

// If targeting an Xtensa device, we must use the '+esp' toolchain modifier:
if target.starts_with("xtensa") {
builder = builder.toolchain("esp");
builder = builder.arg("-Zbuild-std=core,alloc")
builder.add_arg("-Zbuild-std=core,alloc");
}

let args = builder.build();
Expand Down
8 changes: 8 additions & 0 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ struct ExampleArgs {
chip: Chip,
/// Optional example to act on (all examples used if omitted)
example: Option<String>,
/// Build examples in debug mode only
#[arg(long)]
debug: bool,
}

#[derive(Debug, Args)]
Expand Down Expand Up @@ -236,6 +239,7 @@ fn build_examples(args: ExampleArgs, examples: Vec<Metadata>, package_path: &Pat
example,
CargoAction::Build,
1,
args.debug,
)
} else if args.example.is_some() {
// An invalid argument was provided:
Expand All @@ -250,6 +254,7 @@ fn build_examples(args: ExampleArgs, examples: Vec<Metadata>, package_path: &Pat
example,
CargoAction::Build,
1,
args.debug,
)
})
}
Expand All @@ -269,6 +274,7 @@ fn run_example(args: ExampleArgs, examples: Vec<Metadata>, package_path: &Path)
example,
CargoAction::Run,
1,
args.debug,
)
} else {
bail!("Example not found or unsupported for the given chip")
Expand Down Expand Up @@ -300,6 +306,7 @@ fn tests(workspace: &Path, args: TestArgs, action: CargoAction) -> Result<()> {
test,
action,
args.repeat.unwrap_or(1),
false,
)
} else if args.test.is_some() {
bail!("Test not found or unsupported for the given chip")
Expand All @@ -313,6 +320,7 @@ fn tests(workspace: &Path, args: TestArgs, action: CargoAction) -> Result<()> {
&test,
action,
args.repeat.unwrap_or(1),
false,
)
.is_err()
{
Expand Down