#gamedev #cargo #cargo-build #tool

build copy_to_output

A small rust library to copy files/folders from the project directory to the output directory

5 stable releases

2.2.0 Dec 19, 2023
2.1.0 Mar 26, 2023
2.0.1 Mar 18, 2023
2.0.0 Jul 7, 2022
1.0.0 Jun 21, 2022

#279 in Filesystem

Download history 64/week @ 2024-01-20 74/week @ 2024-01-27 55/week @ 2024-02-03 65/week @ 2024-02-10 125/week @ 2024-02-17 134/week @ 2024-02-24 115/week @ 2024-03-02 156/week @ 2024-03-09 138/week @ 2024-03-16 215/week @ 2024-03-23 153/week @ 2024-03-30 96/week @ 2024-04-06 100/week @ 2024-04-13 130/week @ 2024-04-20 111/week @ 2024-04-27 104/week @ 2024-05-04

459 downloads per month
Used in ctp-sys

MIT/Apache

7KB

copy_to_output

A small rust library to copy files/folders from the project directory to the output directory

Copy file/folder

copy_to_output("path name", "build profile");

When building

You can use a build.rs file to copy a file/folder to the output directory when running cargo build

Example build.rs

 use std::env;  
 use copy_to_output::copy_to_output;  
   
 fn main() {  
     // Re-runs script if any files in res are changed  
     println!("cargo:rerun-if-changed=res/*");  
     copy_to_output("res", &env::var("PROFILE").unwrap()).expect("Could not copy");  
 }

where 'res' is the name of the directory to copy to the output directory

Example Cargo.toml

[package]
name = "test_crate"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
copy_to_output = "2.1.0"
glob = "0.3"

glob provides the * wildcard operator for the println!() line in build.rs

Both of these examples are in the example_files folder in this repo

Dependencies

~250KB