Merge the shared repo directories.
This commit is contained in:
909
Cargo.lock
generated
909
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,8 @@ opentelemetry-otlp = { version = "0.13.0", optional = true }
|
|||||||
opentelemetry-semantic-conventions = { version = "0.12.0", optional = true }
|
opentelemetry-semantic-conventions = { version = "0.12.0", optional = true }
|
||||||
serde = { version = "1.0.228", default-features = false, features = ["std", "derive"] }
|
serde = { version = "1.0.228", default-features = false, features = ["std", "derive"] }
|
||||||
serde_json = { version = "1.0.149", default-features = false, features = ["std"] }
|
serde_json = { version = "1.0.149", default-features = false, features = ["std"] }
|
||||||
|
sha2 = { version = "0.10.9", default-features = false, features = ["std"] }
|
||||||
|
sqlx = "0.8.6"
|
||||||
tokio = { version = "1.49.0", default-features = false, features = ["rt", "rt-multi-thread", "fs", "io-util", "process"] }
|
tokio = { version = "1.49.0", default-features = false, features = ["rt", "rt-multi-thread", "fs", "io-util", "process"] }
|
||||||
toml = { version = "0.9.11", default-features = false, features = ["display", "parse", "serde", "std"] }
|
toml = { version = "0.9.11", default-features = false, features = ["display", "parse", "serde", "std"] }
|
||||||
tracing = { version = "0.1.37", optional = true }
|
tracing = { version = "0.1.37", optional = true }
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ impl Config {
|
|||||||
Ok(target_config)
|
Ok(target_config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The root directory where all the output is stored.
|
||||||
pub(crate) fn get_output_directory(&self) -> Result<Cow<'_, Path>, CustomError> {
|
pub(crate) fn get_output_directory(&self) -> Result<Cow<'_, Path>, CustomError> {
|
||||||
let maybe_repo_directory = self.output_directory.as_deref().map(Cow::Borrowed);
|
let maybe_repo_directory = self.output_directory.as_deref().map(Cow::Borrowed);
|
||||||
if let Some(work_dir) = maybe_repo_directory {
|
if let Some(work_dir) = maybe_repo_directory {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ use std::path::Path;
|
|||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use sha2::Digest;
|
||||||
|
use sha2::Sha256;
|
||||||
|
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
|
|
||||||
@@ -34,13 +36,31 @@ pub(crate) struct TargetConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TargetConfig {
|
impl TargetConfig {
|
||||||
|
/// The folder that contains the folders for the build targets.
|
||||||
|
pub(crate) fn get_target_root_directory<'target, 'root>(
|
||||||
|
&'target self,
|
||||||
|
config_root: &'root Config,
|
||||||
|
) -> Result<Cow<'target, Path>, CustomError> {
|
||||||
|
let output_directory = config_root.get_output_directory()?;
|
||||||
|
Ok(Cow::Owned(output_directory.join("target")))
|
||||||
|
}
|
||||||
|
|
||||||
/// The root directory for this specific build target.
|
/// The root directory for this specific build target.
|
||||||
pub(crate) fn get_target_directory<'target, 'root>(
|
pub(crate) fn get_target_directory<'target, 'root>(
|
||||||
&'target self,
|
&'target self,
|
||||||
config_root: &'root Config,
|
config_root: &'root Config,
|
||||||
) -> Result<Cow<'target, Path>, CustomError> {
|
) -> Result<Cow<'target, Path>, CustomError> {
|
||||||
let repo_directory = config_root.get_output_directory()?;
|
let target_root = self.get_target_root_directory(config_root)?;
|
||||||
Ok(Cow::Owned(repo_directory.join(&self.name)))
|
Ok(Cow::Owned(target_root.join(&self.name)))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The folder that contains the folders containing the checkouts of the git repositories.
|
||||||
|
pub(crate) fn get_repo_root_directory<'target, 'root>(
|
||||||
|
&'target self,
|
||||||
|
config_root: &'root Config,
|
||||||
|
) -> Result<Cow<'target, Path>, CustomError> {
|
||||||
|
let output_directory = config_root.get_output_directory()?;
|
||||||
|
Ok(Cow::Owned(output_directory.join("repo")))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The root of the checkout of the git repository.
|
/// The root of the checkout of the git repository.
|
||||||
@@ -48,8 +68,11 @@ impl TargetConfig {
|
|||||||
&'target self,
|
&'target self,
|
||||||
config_root: &'root Config,
|
config_root: &'root Config,
|
||||||
) -> Result<Cow<'target, Path>, CustomError> {
|
) -> Result<Cow<'target, Path>, CustomError> {
|
||||||
let target_directory = self.get_target_directory(config_root)?;
|
let hashed_repo = Sha256::digest(&self.repo);
|
||||||
Ok(Cow::Owned(target_directory.join("repo")))
|
let hashed_repo = hex_string(&hashed_repo);
|
||||||
|
|
||||||
|
let repo_root = self.get_repo_root_directory(config_root)?;
|
||||||
|
Ok(Cow::Owned(repo_root.join(hashed_repo)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The directory that contains flake.nix.
|
/// The directory that contains flake.nix.
|
||||||
@@ -99,3 +122,11 @@ impl TargetConfig {
|
|||||||
Ok(&self.attr)
|
Ok(&self.attr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hex_string(data: &[u8]) -> String {
|
||||||
|
let mut out = String::with_capacity(data.len() * 2);
|
||||||
|
for byte in data {
|
||||||
|
out.push_str(format!("{:02x}", byte).as_str());
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user