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
1 change: 1 addition & 0 deletions basics/checking-accounts/asm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[package]
build = "build.rs"
name = "checking-account-asm-program"
version = "0.1.0"
edition = "2021"
Expand Down
22 changes: 22 additions & 0 deletions basics/checking-accounts/asm/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// The tests embed the assembled program with include_bytes!, which needs the
// file to exist at compile time. `sbpf build` produces it, and it is gitignored,
// so a fresh checkout has no binary and the test module cannot compile. Set a
// cfg when the binary is present and let the tests key off it: present, they
// compile and run; absent, they are left out and the crate still builds.
use std::path::Path;

const BINARY: &str = "deploy/checking-account-asm-program.so";

fn main() {
// Declare the cfg so `-D warnings` builds do not fail on unexpected_cfgs.
println!("cargo::rustc-check-cfg=cfg(has_asm_binary)");
// Re-run when the binary appears or changes, so the cfg never goes stale.
println!("cargo::rerun-if-changed={BINARY}");

if Path::new(BINARY).exists() {
println!("cargo::rustc-cfg=has_asm_binary");
} else {
println!("cargo::warning=ASM binary not found at {BINARY}: tests skipped");
println!("cargo::warning=Run `sbpf build` in this directory to generate it");
}
}
2 changes: 1 addition & 1 deletion basics/checking-accounts/asm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(test)]
#[cfg(all(test, has_asm_binary))]
mod tests {

use litesvm::LiteSVM;
Expand Down
1 change: 1 addition & 0 deletions basics/create-account/asm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[package]
build = "build.rs"
name = "create-account-asm-program"
version = "0.1.0"
edition = "2021"
Expand Down
22 changes: 22 additions & 0 deletions basics/create-account/asm/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// The tests embed the assembled program with include_bytes!, which needs the
// file to exist at compile time. `sbpf build` produces it, and it is gitignored,
// so a fresh checkout has no binary and the test module cannot compile. Set a
// cfg when the binary is present and let the tests key off it: present, they
// compile and run; absent, they are left out and the crate still builds.
use std::path::Path;

const BINARY: &str = "deploy/create-account-asm-program.so";

fn main() {
// Declare the cfg so `-D warnings` builds do not fail on unexpected_cfgs.
println!("cargo::rustc-check-cfg=cfg(has_asm_binary)");
// Re-run when the binary appears or changes, so the cfg never goes stale.
println!("cargo::rerun-if-changed={BINARY}");

if Path::new(BINARY).exists() {
println!("cargo::rustc-cfg=has_asm_binary");
} else {
println!("cargo::warning=ASM binary not found at {BINARY}: tests skipped");
println!("cargo::warning=Run `sbpf build` in this directory to generate it");
}
}
2 changes: 1 addition & 1 deletion basics/create-account/asm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(test)]
#[cfg(all(test, has_asm_binary))]
mod tests {

use litesvm::LiteSVM;
Expand Down
1 change: 1 addition & 0 deletions basics/hello-solana/asm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[package]
build = "build.rs"
name = "hello-solana-asm-program"
version = "0.1.0"
edition = "2021"
Expand Down
22 changes: 22 additions & 0 deletions basics/hello-solana/asm/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// The tests embed the assembled program with include_bytes!, which needs the
// file to exist at compile time. `sbpf build` produces it, and it is gitignored,
// so a fresh checkout has no binary and the test module cannot compile. Set a
// cfg when the binary is present and let the tests key off it: present, they
// compile and run; absent, they are left out and the crate still builds.
use std::path::Path;

const BINARY: &str = "deploy/hello-solana-asm-program.so";

fn main() {
// Declare the cfg so `-D warnings` builds do not fail on unexpected_cfgs.
println!("cargo::rustc-check-cfg=cfg(has_asm_binary)");
// Re-run when the binary appears or changes, so the cfg never goes stale.
println!("cargo::rerun-if-changed={BINARY}");

if Path::new(BINARY).exists() {
println!("cargo::rustc-cfg=has_asm_binary");
} else {
println!("cargo::warning=ASM binary not found at {BINARY}: tests skipped");
println!("cargo::warning=Run `sbpf build` in this directory to generate it");
}
}
2 changes: 1 addition & 1 deletion basics/hello-solana/asm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(test)]
#[cfg(all(test, has_asm_binary))]
mod tests {
use litesvm::LiteSVM;
use solana_instruction::{AccountMeta, Instruction};
Expand Down
1 change: 1 addition & 0 deletions basics/transfer-sol/asm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "asm"
version = "0.1.0"
edition = "2021"
build = "build.rs"

[dependencies]

Expand Down
22 changes: 22 additions & 0 deletions basics/transfer-sol/asm/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// The tests embed the assembled program with include_bytes!, which needs the
// file to exist at compile time. `sbpf build` produces it, and it is gitignored,
// so a fresh checkout has no binary and the test module cannot compile. Set a
// cfg when the binary is present and let the tests key off it: present, they
// compile and run; absent, they are left out and the crate still builds.
use std::path::Path;

const BINARY: &str = "deploy/transfer-sol-cpi.so";

fn main() {
// Declare the cfg so `-D warnings` builds do not fail on unexpected_cfgs.
println!("cargo::rustc-check-cfg=cfg(has_asm_binary)");
// Re-run when the binary appears or changes, so the cfg never goes stale.
println!("cargo::rerun-if-changed={BINARY}");

if Path::new(BINARY).exists() {
println!("cargo::rustc-cfg=has_asm_binary");
} else {
println!("cargo::warning=ASM binary not found at {BINARY}: tests skipped");
println!("cargo::warning=Run `sbpf build` in this directory to generate it");
}
}
2 changes: 1 addition & 1 deletion basics/transfer-sol/asm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(test)]
#[cfg(all(test, has_asm_binary))]
mod tests {
use litesvm::LiteSVM;
use solana_instruction::{AccountMeta, Instruction};
Expand Down
Loading