mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-10 14:40:32 +00:00
Tweak codegen
This commit is contained in:
@@ -7,7 +7,7 @@ use std::{
|
|||||||
collections::{BTreeMap, BTreeSet},
|
collections::{BTreeMap, BTreeSet},
|
||||||
env, fmt,
|
env, fmt,
|
||||||
io::Read,
|
io::Read,
|
||||||
path::Path,
|
path::{Path, PathBuf},
|
||||||
slice,
|
slice,
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
@@ -23,14 +23,14 @@ fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
let package = &args[0];
|
let package = &args[0];
|
||||||
|
|
||||||
let root_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
|
let workspace_root = &workspace_root();
|
||||||
.join("../..")
|
let manifest_path = &workspace_root
|
||||||
.canonicalize()?;
|
.join("manifests")
|
||||||
let manifest_path = &root_dir.join("manifests").join(format!("{package}.json"));
|
.join(format!("{package}.json"));
|
||||||
let download_cache_dir = &root_dir.join("tools/codegen/tmp/cache").join(package);
|
let download_cache_dir = &workspace_root.join("tools/codegen/tmp/cache").join(package);
|
||||||
fs::create_dir_all(download_cache_dir)?;
|
fs::create_dir_all(download_cache_dir)?;
|
||||||
let base_info: BaseManifest = serde_json::from_slice(&fs::read(
|
let base_info: BaseManifest = serde_json::from_slice(&fs::read(
|
||||||
root_dir
|
workspace_root
|
||||||
.join("tools/codegen/base")
|
.join("tools/codegen/base")
|
||||||
.join(format!("{package}.json")),
|
.join(format!("{package}.json")),
|
||||||
)?)?;
|
)?)?;
|
||||||
@@ -334,6 +334,13 @@ fn main() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn workspace_root() -> PathBuf {
|
||||||
|
let mut dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
|
dir.pop(); // codegen
|
||||||
|
dir.pop(); // tools
|
||||||
|
dir
|
||||||
|
}
|
||||||
|
|
||||||
fn replace_vars(s: &str, package: &str, version: &str, platform: HostPlatform) -> Result<String> {
|
fn replace_vars(s: &str, package: &str, version: &str, platform: HostPlatform) -> Result<String> {
|
||||||
let s = s
|
let s = s
|
||||||
.replace("${package}", package)
|
.replace("${package}", package)
|
||||||
|
|||||||
Reference in New Issue
Block a user