// SPDX-FileCopyrightText: 2022 Lars Wirzenius // SPDX-FileCopyrightText: 2023-2024 David Runge // SPDX-License-Identifier: MIT OR Apache-2.0 use std::env::var; use std::fs::File; use std::path::Path; fn main() -> Result<(), Box> { // Only generate test code from the subplot, if a virtual smart // card is available. This is a kludge until Subplot can do // conditional scenarios // (https://gitlab.com/subplot/subplot/-/issues/20). if option_env!("CARD_BASED_TESTS").is_some() { subplot_build::codegen("subplot/oct.subplot")?; println!("cargo:warning=generated subplot tests"); } else { // If we're not generating code from the subplot, we should at // least create an empty file so that the tests/oct.rs // file can include it. Otherwise the build will fail. println!("cargo:warning=did not generate subplot tests"); let out_dir = var("OUT_DIR")?; let include = Path::new(&out_dir).join("oct.rs"); eprintln!("build.rs: include={}", include.display()); if !include.exists() { File::create(include)?; } } Ok(()) }