tl_runtime 0.3.1

Runtime library for TL differentiable programming language
fn main() {
    println!("cargo:rerun-if-changed=src/cuda_kernels/activation.cu");
    println!("cargo:rerun-if-changed=build.rs");

    // Only build CUDA kernels if the 'cuda' feature is enabled
    #[cfg(feature = "cuda")]
    {
        // check if nvcc is installed
        let output = std::process::Command::new("nvcc").arg("--version").output();

        if let Ok(output) = output {
            if output.status.success() {
                // nvcc is available, compile kernels
                cc::Build::new()
                    .cuda(true)
                    .cudart("shared") // Link against shared cuda runtime
                    .flag("-gencode")
                    .flag("arch=compute_75,code=sm_75") // Target T4/RTX20xx class, adjust as needed
                    .file("src/cuda_kernels/activation.cu")
                    .compile("tl_cuda_kernels");

                // Link CUDA libraries
                println!("cargo:rustc-link-lib=dylib=cudart");
                println!("cargo:rustc-link-lib=dylib=cuda");
            } else {
                println!("cargo:warning=nvcc found but failed version check. Skipping CUDA kernel compilation.");
            }
        } else {
            println!("cargo:warning=nvcc not found. Skipping CUDA kernel compilation. (This is expected if you don't have CUDA installed)");
        }
    }
}