Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build data dir #53

Merged
merged 3 commits into from
Jul 4, 2024
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ Windows:

1. `cargo build --release`

## Set the `data` directory

Cacophony's default data directory is located at `../data`. To set the default data directory at *compile time*, set the `CACOPHONY_BUILD_DATA_DIR` enviroment variable:

```bash
export CACOPHONY_BUILD_DATA_DIR=/usr/share/cacophony
cargo build --release
```

## Tests

To test, just `cargo test --all`.
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.2.6

- Fixed: If you let all notes in your music play (as opposed to stopping in the middle), it frequently becomes impossible to play or add new notes.
- Added a build env variable: Set `CACOPHONY_BUILD_DATA_DIR` to set the default path to the data directory.

## 0.2.5

Expand Down
6 changes: 5 additions & 1 deletion common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub use piano_roll_mode::PianoRollMode;
use std::env::current_dir;
use std::fs::{metadata, File};
use std::io::Read;
use std::option_env;
use std::path::{Path, PathBuf};
pub mod font;
pub mod open_file;
Expand All @@ -72,7 +73,10 @@ pub fn get_bytes(path: &Path) -> Vec<u8> {

/// Default directory for looking at the 'data/' folder.
pub fn get_default_data_folder() -> PathBuf {
current_dir().unwrap().join("data")
match option_env!("CACOPHONY_BUILD_DATA_DIR") {
Some(dir) => PathBuf::from(dir),
None => current_dir().unwrap().join("data"),
}
}

#[cfg(debug_assertions)]
Expand Down
Loading