-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into change-liberate-voicevox-core
- Loading branch information
Showing
12 changed files
with
118 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use std::env; | ||
|
||
use derive_syn_parse::Parse; | ||
use quote::ToTokens as _; | ||
use serde::Deserialize; | ||
use syn::LitStr; | ||
|
||
pub(crate) fn pyproject_project_version(_: Input) -> syn::Result<proc_macro2::TokenStream> { | ||
let span = proc_macro2::Span::call_site(); | ||
let error = |e| syn::Error::new(span, e); | ||
|
||
let path = &env::var("CARGO_MANIFEST_DIR") | ||
.map_err(|e| error(format!("could not get `$CARGO_MANIFEST_DIR`: {e}")))?; | ||
let path = std::path::Path::new(path).join("pyproject.toml"); | ||
|
||
let PyprojectToml { | ||
project: Project { version }, | ||
} = &fs_err::read_to_string(path) | ||
.map_err(|e| e.to_string()) | ||
.and_then(|s| toml::from_str(&s).map_err(|e| e.to_string())) | ||
.map_err(error)?; | ||
|
||
return Ok(LitStr::new(version, span).to_token_stream()); | ||
|
||
#[derive(Deserialize)] | ||
struct PyprojectToml { | ||
project: Project, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
struct Project { | ||
version: String, | ||
} | ||
} | ||
|
||
#[derive(Parse)] | ||
pub(crate) struct Input {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.