Skip to content

Commit

Permalink
feat: added buildtools
Browse files Browse the repository at this point in the history
  • Loading branch information
szkabaroli committed Aug 12, 2024
1 parent 9b45c54 commit 3db9be9
Show file tree
Hide file tree
Showing 22 changed files with 361 additions and 328 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion experiments/testmidlgen/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "experiments/testmidlgen",
"projectType": "application",
"implicitDependencies": ["tools/midl/midlgen_rust", "tools/midl/midlgen"],
"implicitDependencies": [],
"targets": {
"build:table.json": {
"executor": "nx:run-commands",
Expand Down
4 changes: 2 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"extends": "nx/presets/npm.json",
"targetDefaults": {
"build": {
"dependsOn": ["^build", "build:*"],
"dependsOn": ["^build", "build_*"],
"cache": true
},
"build*": {
"build_*": {
"inputs": ["{projectRoot}/BUILD.hcl"]
},
"lint": {
Expand Down
27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"release": "npm run build && npx changeset publish"
},
"dependencies": {
"@nx/devkit": "19.5.6",
"@nx/devkit": "19.5.7",
"@swc/helpers": "0.5.11",
"eslint-plugin-import": "^2.29.0",
"execa": "^8.0.1",
Expand Down Expand Up @@ -41,16 +41,16 @@
"@libp2p/websockets": "^8.1.2",
"@multiformats/multiaddr": "^12.3.0",
"@multiformats/multiaddr-matcher": "1.2.4",
"@nx/esbuild": "19.5.6",
"@nx/eslint": "19.5.6",
"@nx/eslint-plugin": "19.5.6",
"@nx/jest": "19.5.6",
"@nx/js": "19.5.6",
"@nx/next": "19.5.6",
"@nx/node": "19.5.6",
"@nx/plugin": "19.5.6",
"@nx/vite": "19.5.6",
"@nx/web": "19.5.6",
"@nx/esbuild": "19.5.7",
"@nx/eslint": "19.5.7",
"@nx/eslint-plugin": "19.5.7",
"@nx/jest": "19.5.7",
"@nx/js": "19.5.7",
"@nx/next": "19.5.7",
"@nx/node": "19.5.7",
"@nx/plugin": "19.5.7",
"@nx/vite": "19.5.7",
"@nx/web": "19.5.7",
"@nxrs/cargo": "^0.4.0",
"@swc-node/register": "~1.9.1",
"@swc/cli": "0.3.14",
Expand Down Expand Up @@ -82,7 +82,7 @@
"jsdom": "22.1.0",
"libp2p": "^1.8.1",
"next": "^14.2.3",
"nx": "19.5.6",
"nx": "19.5.7",
"postcss": "8.4.38",
"prettier": "^2.6.2",
"react": "18.2.0",
Expand All @@ -96,5 +96,6 @@
"vite-plugin-eslint": "^1.8.1",
"vite-tsconfig-paths": "^4.3.0",
"vitest": "^1.6.0"
}
},
"packageManager": "[email protected]+sha512.dc09430156b427f5ecfc79888899e1c39d2d690f004be70e05230b72cb173d96839587545d09429b55ac3c429c801b4dc3c0e002f653830a420fa2dd4e3cf9cf"
}
421 changes: 222 additions & 199 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

60 changes: 28 additions & 32 deletions src/sys/pkg/lib/meshx-pkg/src/package_build_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use {
crate::errors::PackageBuildManifestError,
meshx_url::validate_resource_path,
serde::{Deserialize, Serialize},
std::{
collections::{btree_map, BTreeMap, HashSet},
fs,
io::{self, Read},
path::Path,
},
walkdir::WalkDir,
};
use crate::errors::PackageBuildManifestError;
use meshx_url::validate_resource_path;
use serde::{Deserialize, Serialize};
use std::collections::{btree_map, BTreeMap, HashSet};
use std::fs;
use std::io::{self, Read};
use std::path::Path;
use walkdir::WalkDir;

/// A `PackageBuildManifest` lists the files that should be included in a Fuchsia package. Both
/// `external_contents` and `far_contents` are maps from package resource paths in the to-be-created
Expand Down Expand Up @@ -169,7 +165,7 @@ impl PackageBuildManifest {
PackageBuildManifest::from_external_and_far_contents(external_contents, far_contents)
}

/// Create a `PackageBuildManifest` from a `pm-build`-style Fuchsia INI file (fini). fini is a
/// Create a `PackageBuildManifest` from a `pm-build`-style MeshX INI file (mini). mini is a
/// simple format where each line is an entry of `$PKG_PATH=$HOST_PATH`. This copies the
/// parsing algorithm from pm, where:
///
Expand All @@ -186,13 +182,13 @@ impl PackageBuildManifest {
///
/// ```
/// # use meshx_pkg::PackageBuildManifest;
/// let fini_string = "\
/// let mini_string = "\
/// lib/mylib.so=build/system/path/mylib.so\n\
/// meta/my_component_manifest.cml=other/build/system/path/my_component_manifest.cml\n";
///
/// let creation_manifest = PackageBuildManifest::from_pm_fini(fini_string.as_bytes()).unwrap();
/// let creation_manifest = PackageBuildManifest::from_pm_mini(mini_string.as_bytes()).unwrap();
/// ```
pub fn from_pm_fini<R: io::BufRead>(mut reader: R) -> Result<Self, PackageBuildManifestError> {
pub fn from_pm_mini<R: io::BufRead>(mut reader: R) -> Result<Self, PackageBuildManifestError> {
let mut external_contents = BTreeMap::new();
let mut far_contents = BTreeMap::new();

Expand Down Expand Up @@ -477,9 +473,9 @@ mod tests {
}

#[test]
fn test_from_pm_fini() {
fn test_from_pm_mini() {
assert_eq!(
PackageBuildManifest::from_pm_fini(
PackageBuildManifest::from_pm_mini(
"this-path=this-host-path\n\
that/path=that/host/path\n\
another/path=another/host=path\n
Expand Down Expand Up @@ -508,9 +504,9 @@ mod tests {
}

#[test]
fn test_from_pm_fini_empty() {
fn test_from_pm_mini_empty() {
assert_eq!(
PackageBuildManifest::from_pm_fini("".as_bytes()).unwrap(),
PackageBuildManifest::from_pm_mini("".as_bytes()).unwrap(),
PackageBuildManifest(VersionedPackageBuildManifest::Version1(PackageBuildManifestV1 {
external_contents: btreemap! {},
far_contents: btreemap! {}
Expand All @@ -519,7 +515,7 @@ mod tests {
}

#[test]
fn test_from_pm_fini_same_file_contents() {
fn test_from_pm_mini_same_file_contents() {
let dir = tempfile::tempdir().unwrap();

let path = dir.path().join("path");
Expand All @@ -528,15 +524,15 @@ mod tests {
fs::write(&path, b"hello world").unwrap();
fs::write(&same, b"hello world").unwrap();

let fini = format!(
let mini = format!(
"path={path}\n\
path={same}\n",
path = path.to_str().unwrap(),
same = same.to_str().unwrap(),
);

assert_eq!(
PackageBuildManifest::from_pm_fini(fini.as_bytes()).unwrap(),
PackageBuildManifest::from_pm_mini(mini.as_bytes()).unwrap(),
PackageBuildManifest(VersionedPackageBuildManifest::Version1(PackageBuildManifestV1 {
external_contents: btreemap! {
"path".to_string() => path.to_str().unwrap().to_string(),
Expand All @@ -547,7 +543,7 @@ mod tests {
}

#[test]
fn test_from_pm_fini_different_contents() {
fn test_from_pm_mini_different_contents() {
let dir = tempfile::tempdir().unwrap();

let path = dir.path().join("path");
Expand All @@ -556,15 +552,15 @@ mod tests {
fs::write(&path, b"hello world").unwrap();
fs::write(&different, b"different").unwrap();

let fini = format!(
let mini = format!(
"path={path}\n\
path={different}\n",
path = path.to_str().unwrap(),
different = different.to_str().unwrap()
);

assert_matches!(
PackageBuildManifest::from_pm_fini(fini.as_bytes()),
PackageBuildManifest::from_pm_mini(mini.as_bytes()),
Err(PackageBuildManifestError::DuplicateResourcePath { path }) if path == "path"
);
}
Expand Down Expand Up @@ -596,31 +592,31 @@ mod tests {
}

#[test]
fn test_from_pm_fini_not_found() {
fn test_from_pm_mini_not_found() {
let dir = tempfile::tempdir().unwrap();

let path = dir.path().join("path");
let not_found = dir.path().join("not_found");

fs::write(&path, b"hello world").unwrap();

let fini = format!(
let mini = format!(
"path={path}\n\
path={not_found}\n",
path = path.to_str().unwrap(),
not_found = not_found.to_str().unwrap()
);

assert_matches!(
PackageBuildManifest::from_pm_fini(fini.as_bytes()),
PackageBuildManifest::from_pm_mini(mini.as_bytes()),
Err(PackageBuildManifestError::IoError(err)) if err.kind() == io::ErrorKind::NotFound
);
}

#[cfg(not(target_os = "fuchsia"))]
#[cfg(unix)]
#[test]
fn test_from_pm_fini_link() {
fn test_from_pm_mini_link() {
let dir = tempfile::tempdir().unwrap();

let path = dir.path().join("path");
Expand All @@ -631,7 +627,7 @@ mod tests {
fs::hard_link(&path, &hard).unwrap();
std::os::unix::fs::symlink(&path, &sym).unwrap();

let fini = format!(
let mini = format!(
"path={path}\n\
path={hard}\n\
path={sym}\n",
Expand All @@ -641,7 +637,7 @@ mod tests {
);

assert_eq!(
PackageBuildManifest::from_pm_fini(fini.as_bytes()).unwrap(),
PackageBuildManifest::from_pm_mini(mini.as_bytes()).unwrap(),
PackageBuildManifest(VersionedPackageBuildManifest::Version1(PackageBuildManifestV1 {
external_contents: btreemap! {
"path".to_string() => path.to_str().unwrap().to_string(),
Expand Down
5 changes: 3 additions & 2 deletions src/sys/pkg/lib/package-tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tempfile-ext = {path = "../tempfile-ext"}
version-history = {path = "../../../../lib/version-history"}

[dev-dependencies]
walkdir="2.5"
tokio = {version = "1", features = ["full"]}
pretty_assertions = "1.0"
#meshx-archive = {path = "../meshx-archive"}
#pretty_assertions = "1.0"
#tokio = {version = "1", features = ["full"]}
29 changes: 14 additions & 15 deletions src/sys/pkg/lib/package-tool/src/package_archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ pub async fn cmd_package_archive_remove(cmd: PackageArchiveRemoveCommand) -> Res
}
*/

/*

#[cfg(test)]
mod tests {
use {
super::*,
crate::convert_to_depfile_filepath,
camino::Utf8PathBuf,
meshx_archive::Utf8Reader,
//meshx_archive::Utf8Reader,
meshx_pkg::PackageBuilder,
pretty_assertions::assert_eq,
std::{collections::BTreeMap, io::Write, process::Command},
Expand Down Expand Up @@ -350,7 +350,7 @@ mod tests {
extract_contents
}

#[tokio::test]
/*#[tokio::test]
async fn test_archive_create_and_extract() {
let tmp = TempDir::new().unwrap();
let root = Utf8Path::from_path(tmp.path()).unwrap();
Expand Down Expand Up @@ -430,10 +430,10 @@ mod tests {
);
assert_eq!(extract_contents, BTreeMap::new());
}
}*/

/// Returns the path of the directory into which we extracted the modified far
async fn test_archive_add_inner(
/*async fn test_archive_add_inner(
tmp: &TempDir,
path_to_add: Utf8PathBuf,
contents_to_add: &str,
Expand Down Expand Up @@ -495,9 +495,9 @@ mod tests {
.unwrap();
Ok(extract_dir)
}
}*/

#[tokio::test]
/*#[tokio::test]
async fn test_archive_add() {
let tmp = TempDir::new().unwrap();
let extract_dir = test_archive_add_inner(&tmp, "add_test".into(), "test", false)
Expand Down Expand Up @@ -585,9 +585,9 @@ mod tests {
]
)
);
}
}*/

#[tokio::test]
/*#[tokio::test]
async fn test_archive_remove() {
let tmp = TempDir::new().unwrap();
let root = Utf8Path::from_path(tmp.path()).unwrap();
Expand Down Expand Up @@ -661,7 +661,7 @@ mod tests {
]
)
);
}
}*/

#[tokio::test]
async fn test_package_tool_archive_and_pm_expand() {
Expand Down Expand Up @@ -737,7 +737,7 @@ mod tests {
assert_eq!(extract_contents, BTreeMap::new());
}

#[tokio::test]
/*#[tokio::test]
async fn test_archive_create_with_depfile() {
let tmp = TempDir::new().unwrap();
let root = Utf8Path::from_path(tmp.path()).unwrap();
Expand Down Expand Up @@ -789,7 +789,7 @@ mod tests {
.join(" "),
),
);
}
}*/

#[tokio::test]
async fn test_pm_archive_and_package_tool_extract() {
Expand All @@ -799,7 +799,7 @@ mod tests {
let pkg_dir = root.join("pkg");
std::fs::create_dir(&pkg_dir).unwrap();

// `pm archive` also needs a FINI build manifest.
// `pm archive` also needs a MINI build manifest.
let build_manifest_path = pkg_dir.join("build.manifest");
let mut f = std::fs::File::create(&build_manifest_path).unwrap();
writeln!(f, "bin={}", pkg_dir.join("bin")).unwrap();
Expand Down Expand Up @@ -849,5 +849,4 @@ mod tests {
);
assert_eq!(extract_contents, BTreeMap::from([]));
}
}
*/
}
Loading

0 comments on commit 3db9be9

Please sign in to comment.