Repository navigation
Don't let the build script overwrite TYPST_VERSION - #154
Conversation
|
Why is this useful? It is only set in the |
|
I am trying to package typst for nixpkgs, and |
CGMossa
left a comment
There was a problem hiding this comment.
I would suggest to write this in a way, that makes the version stuff and this one unified "unit". Build scripts tend to build up fast, and having things in succinct units does help.
|
Could you elaborate on the unit concept? I don't quite understand what should be done. I tried to make the least amount of changes possible to make the nix package simpler while not affecting what's already here. |
|
Suggested edit: diff --git a/cli/build.rs b/cli/build.rs
index 1b37602f..515349ad 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -2,16 +2,17 @@ use std::process::Command;
fn main() {
println!("cargo:rerun-if-env-changed=TYPST_VERSION");
- if option_env!("TYPST_VERSION").is_some() {
- return;
- }
+ let version = if let Some(version) = option_env!("TYPST_VERSION") {
+ version.into()
+ } else {
+ Command::new("git")
+ .args(&["rev-parse", "HEAD"])
+ .output()
+ .ok()
+ .and_then(|output| output.status.success().then(|| output))
+ .and_then(|output| String::from_utf8(output.stdout[..8].into()).ok())
+ .unwrap_or_else(|| "(unknown version)".into())
+ };
- let version = Command::new("git")
- .args(&["rev-parse", "HEAD"])
- .output()
- .ok()
- .and_then(|output| output.status.success().then(|| output))
- .and_then(|output| String::from_utf8(output.stdout[..8].into()).ok())
- .unwrap_or_else(|| "(unknown version)".into());
println!("cargo:rustc-env=TYPST_VERSION={version}");
}
|
|
Damn.. I'm not sure this is strictly better... But it is a suggestion atleast 🤷♂️ |
|
Either way is fine with me, also applied some clippy suggestions since we are now touching that part of the code |
CGMossa
left a comment
There was a problem hiding this comment.
LGTM
I feel the need to point out, that I'm not part of the team.
|
I think the original version with The general change seems good, if it allows more flexibility for packaging, I'm all for it. |
* 'main' of https://github.com/typst/typst: (22 commits) Added IPA pronunciation (typst#349) Cache eviction helps Pronunciation Don't let the build script overwrite TYPST_VERSION (typst#154) Document behaviour of dictionary.insert() when key exists (typst#282) Add custom font search path support for typst cli (typst#270) Added return type to methods of colors in docs (typst#291) change page numbering for outline (typst#284) Newton's notation for derivatives (typst#281) Use correct smart quotes for Norwegian Bokmål language code (typst#278) Fix fill color obstructing page header and background (typst#277) Simplify heading block example Fix index out of bounds error in build script (typst#173) Replace infinite repeat layout panic with error (typst#235) Changed "ColorChoice::Always" to "ColorChoice::Auto" to honour user setting of TERM / NO_COLOR (typst#230) Fixed Typo (typst#227) Fix descriptions of some types (typst#206) Fix import syntax in tutorial (typst#205) Make alignment actually centered (typst#176) strip cli target (typst#143) ...
No description provided.