Skip to content

Commit

Permalink
error on unknown fields for AdlWorkspace0
Browse files Browse the repository at this point in the history
  • Loading branch information
millergarym committed May 1, 2023
1 parent 976e9c3 commit fe6a159
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 48 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions rust/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ convert_case = "0.6.0"
backtrace-on-stack-overflow = "0.3.0"
regex = "1.7.3"
rust-embed = "6.6.1"
serde_ignored = "0.1.7"
41 changes: 12 additions & 29 deletions rust/compiler/src/cli/workspace.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

use std::collections::HashMap;
use std::collections::{HashMap, BTreeSet};
use std::path::PathBuf;
use std::{env, fs};

Expand Down Expand Up @@ -66,7 +66,6 @@ fn wrk1_to_wld(wrk1: AdlWorkspace1) -> Result<LoaderWorkspace, anyhow::Error> {
r#use: u2,
named_options: HashMap::new(),
runtimes: wrk1.runtimes,
// embedded_sys_loader: Maybe(wrk1.embedded_sys_loader.0.as_ref().map(payload1_to_loader_ref)),
})
}

Expand All @@ -88,8 +87,6 @@ fn payload1_to_loader_ref(payload1: &Payload1) -> Result<LoaderRef, anyhow::Erro
},
}),
},
// path: payload1.p_ref.path.clone(),
// global_alias: payload1.pkg.global_alias.clone(),
loader_inject_annotate: vec![],
resolver_inject_annotate: vec![],
};
Expand All @@ -104,18 +101,6 @@ fn payload1_to_loader_ref(payload1: &Payload1) -> Result<LoaderRef, anyhow::Erro
},
serde_json::json!(&ts_opts.npm_pkg_name),
))));
// let mn1 = "adlc.config.typescript".to_string();
// module1.annotations.0.insert(
// adlast::ScopedName {
// module_name: if *module_name == mn1 {
// "".to_string()
// } else {
// mn1
// },
// name: "NpmPackage".to_string(),
// },
// serde_json::json!(&ts_opts.npm_pkg_name),
// );
}

Ok(loader_ref)
Expand All @@ -138,15 +123,23 @@ fn collection_to_workspace(
let porw_path = porw.1.join(porw.2);
let content = fs::read_to_string(&porw_path)
.map_err(|e| anyhow!("{:?}: {}", porw_path, e.to_string()))?;
let mut de = serde_json::Deserializer::from_str(&content);
let de = &mut serde_json::Deserializer::from_str(&content);
match porw.0 {
PkgDef::Pkg => {
// let pkg = AdlPackage::deserialize(&mut de).map_err(|e| anyhow!("{:?}: {}", porw_path, e.to_string()))?;
// println!("pkg {:?}", pkg);
}
PkgDef::Work => {
let wrk0 = AdlWorkspace0::deserialize(&mut de)
.map_err(|e| anyhow!("{:?}: {}", porw_path, e.to_string()))?;
// let wrk0 = AdlWorkspace0::deserialize(de).map_err(|e| anyhow!("{:?}: {}", porw_path, e.to_string()))?;

let mut unused = BTreeSet::new();
let wrk0: AdlWorkspace0 = serde_ignored::deserialize(de, |path| {
unused.insert(path.to_string());
}).map_err(|e| anyhow!("{:?}: {}", porw_path, e.to_string()))?;
if unused.len() != 0 {
return Err(anyhow!("unknown fields `{:?}` {:?}", unused, porw_path));
}

let named_opts = wrk0.named_options;
let mut wrk1 = AdlWorkspace1 {
adlc: wrk0.adlc.clone(),
Expand Down Expand Up @@ -191,11 +184,6 @@ fn collection_to_workspace(
log::warn!("Named option set specified but not found. Name: {} Package: {}", name, aprt_to_name(&p.r#ref));
}
}
// let p_path = porw.1.join(&p.path).join("adl.pkg.json");
// let content = fs::read_to_string(&p_path).map_err(|e| anyhow!("Can't read pkg specified in workspace.\n\tworkspace {:?}\n\t package {:?}\n\t error: {}", porw_path, p_path, e.to_string()))?;
// let mut de = serde_json::Deserializer::from_str(&content);
// let pkg = AdlPackage::deserialize(&mut de)
// .map_err(|e| anyhow!("{:?}: {}", p_path, e.to_string()))?;
wrk1.r#use.push(Payload1::new(p2, pkg));
}
return Ok((porw.1, wrk1));
Expand All @@ -205,11 +193,6 @@ fn collection_to_workspace(
Err(anyhow!("No workspace found"))
}

// const ADL_PKG_FILES: &[(&str, PkgDef)] = &[
// ("adl.pkg.json", PkgDef::Pkg),
// ("adl.work.json", PkgDef::Work),
// ];

#[derive(Debug, Copy, Clone, PartialEq)]
enum PkgDef {
Pkg,
Expand Down
11 changes: 4 additions & 7 deletions typescript/workspace/adl.work.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"runtime_opts": {
"workspace_ref": "@adl-lang/runtime"
},
"extra_dev_dependencies": {
"dev_dependencies": {
"tsconfig": "workspace:*",
"typescript": "^4.9.3"
},
Expand Down Expand Up @@ -59,8 +59,7 @@
"outputs": {
"gen": {
"output_dir": "./generated/sys",
"manifest": "./generated/sys/.adl-manifest",
"strip_first": true
"manifest": "./generated/sys/.adl-manifest"
}
},
"include_resolver": true
Expand All @@ -78,8 +77,7 @@
"outputs": {
"gen": {
"output_dir": "./generated/common",
"manifest": "./generated/common/.adl-manifest",
"strip_first": true
"manifest": "./generated/common/.adl-manifest"
}
},
"include_resolver": true
Expand All @@ -101,8 +99,7 @@
"outputs": {
"gen": {
"output_dir": "./generated/protoclient",
"manifest": "./generated/protoclient/.adl-manifest",
"strip_first": true
"manifest": "./generated/protoclient/.adl-manifest"
}
},
"include_resolver": true
Expand Down
9 changes: 6 additions & 3 deletions typescript/workspace/generated/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"tsc": "tsc"
},
"dependencies": {
"@adl-lang/sys": "workspace:*",
"@adl-lang/runtime": "^1.0.0"
"@adl-lang/runtime": "^1.0.0",
"@adl-lang/sys": "workspace:*"
},
"devDependencies": {}
"devDependencies": {
"typescript": "^4.9.3",
"tsconfig": "workspace:*"
}
}
11 changes: 7 additions & 4 deletions typescript/workspace/generated/protoclient/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
"tsc": "tsc"
},
"dependencies": {
"@adl-lang/runtime": "^1.0.0",
"@adl-lang/common": "workspace:*",
"@adl-lang/sys": "workspace:*",
"base64-js": "^1.5.1"
"@adl-lang/common": "workspace:*",
"base64-js": "^1.5.1",
"@adl-lang/runtime": "^1.0.0"
},
"devDependencies": {}
"devDependencies": {
"typescript": "^4.9.3",
"tsconfig": "workspace:*"
}
}
13 changes: 8 additions & 5 deletions typescript/workspace/generated/sys/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"name": "@adl-lang/sys",
"version": "1.0.0",
"scripts": {
"tsc": "tsc",
"clean": "rm -rf dist && rm -rf node_modules"
"clean": "rm -rf dist && rm -rf node_modules",
"tsc": "tsc"
},
"dependencies": {
"base64-js": "^1.5.1",
"@adl-lang/runtime": "^1.0.0"
"@adl-lang/runtime": "^1.0.0",
"base64-js": "^1.5.1"
},
"devDependencies": {}
"devDependencies": {
"typescript": "^4.9.3",
"tsconfig": "workspace:*"
}
}

0 comments on commit fe6a159

Please sign in to comment.