-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make it possible to build the engines without
.git
directory (#…
…4992) Follow-up to #4986. * Change the `build.rs` scripts to pass through the `GIT_HASH` environment variable if it's already set. * Set dummmy `GIT_HASH` value in the Nix packages used in the engines size dashboard. * Consistently use the new logic everywhere. Fixes: #4991 Closes: prisma/team-orm#1261
- Loading branch information
Showing
18 changed files
with
75 additions
and
92 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "build-utils" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
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,23 @@ | ||
use std::process::Command; | ||
|
||
/// Store the current git commit hash in the `GIT_HASH` variable in rustc env. | ||
/// If the `GIT_HASH` environment variable is already set, this function does nothing. | ||
pub fn store_git_commit_hash_in_env() { | ||
if std::env::var("GIT_HASH").is_ok() { | ||
return; | ||
} | ||
|
||
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap(); | ||
|
||
// Sanity check on the output. | ||
if !output.status.success() { | ||
panic!( | ||
"Failed to get git commit hash.\nstderr: \n{}\nstdout {}\n", | ||
String::from_utf8(output.stderr).unwrap_or_default(), | ||
String::from_utf8(output.stdout).unwrap_or_default(), | ||
); | ||
} | ||
|
||
let git_hash = String::from_utf8(output.stdout).unwrap(); | ||
println!("cargo:rustc-env=GIT_HASH={git_hash}"); | ||
} |
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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
use std::process::Command; | ||
|
||
fn main() { | ||
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap(); | ||
let git_hash = String::from_utf8(output.stdout).unwrap(); | ||
println!("cargo:rustc-env=GIT_HASH={git_hash}"); | ||
build_utils::store_git_commit_hash_in_env(); | ||
} |
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 |
---|---|---|
@@ -1,11 +1,3 @@ | ||
use std::process::Command; | ||
|
||
fn store_git_commit_hash() { | ||
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap(); | ||
let git_hash = String::from_utf8(output.stdout).unwrap(); | ||
println!("cargo:rustc-env=GIT_HASH={git_hash}"); | ||
} | ||
|
||
fn main() { | ||
store_git_commit_hash(); | ||
build_utils::store_git_commit_hash_in_env(); | ||
} |
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 |
---|---|---|
|
@@ -46,3 +46,4 @@ once_cell = "1.19.0" | |
|
||
[build-dependencies] | ||
cbindgen = "0.24.0" | ||
build-utils.path = "../../libs/build-utils" |
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 |
---|---|---|
@@ -1,24 +1,4 @@ | ||
extern crate napi_build; | ||
|
||
use std::process::Command; | ||
|
||
fn store_git_commit_hash() { | ||
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap(); | ||
|
||
// Sanity check on the output. | ||
if !output.status.success() { | ||
panic!( | ||
"Failed to get git commit hash.\nstderr: \n{}\nstdout {}\n", | ||
String::from_utf8(output.stderr).unwrap_or_default(), | ||
String::from_utf8(output.stdout).unwrap_or_default(), | ||
); | ||
} | ||
|
||
let git_hash = String::from_utf8(output.stdout).unwrap(); | ||
println!("cargo:rustc-env=GIT_HASH={git_hash}"); | ||
} | ||
|
||
fn main() { | ||
store_git_commit_hash(); | ||
build_utils::store_git_commit_hash_in_env(); | ||
napi_build::setup() | ||
} |
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 |
---|---|---|
@@ -1,11 +1,3 @@ | ||
use std::process::Command; | ||
|
||
fn store_git_commit_hash() { | ||
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap(); | ||
let git_hash = String::from_utf8(output.stdout).unwrap(); | ||
println!("cargo:rustc-env=GIT_HASH={git_hash}"); | ||
} | ||
|
||
fn main() { | ||
store_git_commit_hash(); | ||
build_utils::store_git_commit_hash_in_env(); | ||
} |
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 |
---|---|---|
@@ -1,21 +1,3 @@ | ||
use std::process::Command; | ||
|
||
fn store_git_commit_hash() { | ||
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap(); | ||
|
||
// Sanity check on the output. | ||
if !output.status.success() { | ||
panic!( | ||
"Failed to get git commit hash.\nstderr: \n{}\nstdout {}\n", | ||
String::from_utf8(output.stderr).unwrap_or_default(), | ||
String::from_utf8(output.stdout).unwrap_or_default(), | ||
); | ||
} | ||
|
||
let git_hash = String::from_utf8(output.stdout).unwrap(); | ||
println!("cargo:rustc-env=GIT_HASH={git_hash}"); | ||
} | ||
|
||
fn main() { | ||
store_git_commit_hash(); | ||
build_utils::store_git_commit_hash_in_env(); | ||
} |
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 |
---|---|---|
@@ -1,21 +1,3 @@ | ||
use std::process::Command; | ||
|
||
fn store_git_commit_hash() { | ||
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap(); | ||
|
||
// Sanity check on the output. | ||
if !output.status.success() { | ||
panic!( | ||
"Failed to get git commit hash.\nstderr: \n{}\nstdout {}\n", | ||
String::from_utf8(output.stderr).unwrap_or_default(), | ||
String::from_utf8(output.stdout).unwrap_or_default(), | ||
); | ||
} | ||
|
||
let git_hash = String::from_utf8(output.stdout).unwrap(); | ||
println!("cargo:rustc-env=GIT_HASH={git_hash}"); | ||
} | ||
|
||
fn main() { | ||
store_git_commit_hash(); | ||
build_utils::store_git_commit_hash_in_env(); | ||
} |