Skip to content

Commit

Permalink
working for protoapp
Browse files Browse the repository at this point in the history
  • Loading branch information
millergarym committed Apr 4, 2023
1 parent 2474bb4 commit a9d4fc7
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rust/compiler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[[bin]]
name = "adlc"
name = "radlc"
path = "src/main.rs"

[dependencies]
15 changes: 12 additions & 3 deletions rust/compiler/src/cli/tsgen/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

pub fn rel_import(src: &String, dst: &String) -> String {
let src_v: Vec<&str> = src.split(['.']).collect();
// strip off the name, only leave the path
@@ -15,8 +14,16 @@ pub fn rel_import(src: &String, dst: &String) -> String {
}
common += 1;
}
// dbg!(&src_v);
// dbg!(common);
// dbg!(&dst_v);
import.push_str("../".repeat(src_v.len() - common).as_str());
import.push_str(dst_v[common..].join("/").as_str());
if common == dst_v.len() {
import.push_str("../");
import.push_str(dst_v.join("/").as_str());
} else {
import.push_str(dst_v[common..].join("/").as_str());
}
import
}

@@ -26,7 +33,6 @@ mod tests {

#[test]
fn test_relative_import() {

let tests: Vec<(&str, &str, &str, &str)> = vec![
("test 00", "abc", "runtime.adl", "./runtime/adl"),
("test 01", "scopedname.def", "scopedname.abc", "./abc"),
@@ -42,6 +48,9 @@ mod tests {
"runtime.adl",
"./../runtime/adl",
),
("test 04", "common.adminui.api", "common", "./../../common"),
("test 05", "common.adminui.api", "common.db", "./../db"),
("test 06", "common.adminui.api", "common.adminui", "./../common/adminui"),
];

for t in tests {

0 comments on commit a9d4fc7

Please sign in to comment.