tamer: Remove graphml target

This was originally created to populate Neo4J for querying, but it has not
been utilized.  It's become a maintenance burden as I try to change the API
of and encapsulate the graph, which is important for upholding its
invariants.

This feature, or one like it, will return in the future.  I have other
related plans; we'll see if they materialize.

The graph can't be encapsulated fully just yet because of the linker; those
commits will come in the following days.

DEV-13597
main
Mike Gerwitz 2023-01-23 13:35:14 -05:00
parent 8735c2fca3
commit 055ff4a9d9
5 changed files with 4 additions and 109 deletions

17
tamer/Cargo.lock generated
View File

@ -94,16 +94,6 @@ dependencies = [
"indexmap",
]
[[package]]
name = "petgraph-graphml"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f99237d858a7675759c308324348d81742553ed1d65ddce0854a55688e8487b"
dependencies = [
"petgraph",
"xml-rs",
]
[[package]]
name = "quick-xml"
version = "0.23.0-alpha3"
@ -131,7 +121,6 @@ dependencies = [
"memchr",
"paste",
"petgraph",
"petgraph-graphml",
"quick-xml",
"static_assertions",
"unicode-width",
@ -142,9 +131,3 @@ name = "unicode-width"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "xml-rs"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"

View File

@ -31,7 +31,6 @@ getopts = "0.2"
memchr = ">= 2.3.4" # quick-xml expects =2.3.4 at the time
paste = ">= 1.0.5"
petgraph = "0.6.0"
petgraph-graphml = "3.0.0"
quick-xml = ">= 0.23.0-alpha3"
static_assertions = ">= 1.1.0"
unicode-width = "0.1.5"

View File

@ -54,10 +54,10 @@ pub trait IndexType = petgraph::graph::IndexType;
pub type AsgResult<T> = Result<T, AsgError>;
/// There are currently no data stored on edges ("edge weights").
pub type AsgEdge = ObjectRelTy;
type AsgEdge = ObjectRelTy;
/// Each node of the graph.
pub type Node = ObjectContainer;
type Node = ObjectContainer;
/// Index size for Graph nodes and edges.
type Ix = global::ProgSymSize;

View File

@ -46,9 +46,6 @@ enum Emit {
/// Outputs the linked object files in a format that can be used in an
/// application.
Xmle,
/// Used for exploring the linked graph
Graphml,
}
/// Entrypoint for the linker
@ -64,7 +61,6 @@ pub fn main() -> Result<(), TameldError> {
match parse_options(opts, args) {
Ok(Command::Link(input, output, emit)) => match emit {
Emit::Xmle => poc::xmle(&input, &output),
Emit::Graphml => poc::graphml(&input, &output),
}
.map_err(|e| {
// POC: Rendering to a string ensures buffering so that we don't
@ -99,12 +95,7 @@ fn get_opts() -> Options {
let mut opts = Options::new();
opts.optopt("o", "output", "set output file name", "NAME");
opts.optflag("h", "help", "print this help menu");
opts.optopt(
"",
"emit",
"set the output to be emitted",
"--emit xmle|graphml",
);
opts.optopt("", "emit", "set the output to be emitted", "--emit xmle");
opts
}
@ -138,7 +129,6 @@ fn parse_options(opts: Options, args: Vec<String>) -> Result<Command, Fail> {
let emit = match matches.opt_str("emit") {
Some(m) => match &m[..] {
"xmle" => Emit::Xmle,
"graphml" => Emit::Graphml,
em => return Err(Fail::ArgumentMissing(format!("--emit {em}"))),
},
None => Emit::Xmle,
@ -312,28 +302,4 @@ mod test {
_ => panic!("Unexpected result"),
}
}
#[test]
fn parse_options_valid_long_emit_graphml() {
let opts = get_opts();
let result = parse_options(
opts,
vec![
String::from("program"),
String::from("foo"),
String::from("--output"),
String::from("bar"),
String::from("--emit"),
String::from("graphml"),
],
);
match result {
Ok(Command::Link(infile, outfile, Emit::Graphml)) => {
assert_eq!("foo", infile);
assert_eq!("bar", outfile);
}
_ => panic!("Unexpected result"),
}
}
}

View File

@ -28,7 +28,7 @@ use super::xmle::{
use crate::{
asg::{
air::{Air, AirAggregate},
Asg, AsgError, DefaultAsg, Object,
Asg, AsgError, DefaultAsg,
},
diagnose::{AnnotatedSpan, Diagnostic},
fs::{
@ -52,7 +52,6 @@ use crate::{
},
};
use fxhash::FxBuildHasher;
use petgraph_graphml::GraphMl;
use std::{
error::Error,
fmt::{self, Display},
@ -94,58 +93,6 @@ pub fn xmle(package_path: &str, output: &str) -> Result<(), TameldError> {
Ok(())
}
// TODO: This needs to be further generalized.
pub fn graphml(package_path: &str, output: &str) -> Result<(), TameldError> {
let mut fs = VisitOnceFilesystem::new();
let escaper = DefaultEscaper::default();
let (depgraph, _) = load_xmlo(
package_path,
&mut fs,
LinkerAsg::with_capacity(65536, 65536),
&escaper,
XmloAirContext::default(),
)?;
// if we move away from petgraph, we will need to abstract this away
let g = depgraph.into_inner();
let graphml =
GraphMl::new(&g)
.pretty_print(true)
.export_node_weights(Box::new(|node| {
let (name, kind, generated) = match node.get() {
Object::Ident(n) => {
let generated = match n.src() {
Some(src) => src.generated,
None => false,
};
(
n.name().symbol().lookup_str().into(),
n.kind().unwrap().as_sym(),
format!("{}", generated),
)
}
// TODO: We want these filtered.
_ => (
String::from("non-ident"),
"non-ident".into(),
"false".into(),
),
};
vec![
("label".into(), name.into()),
("kind".into(), kind.lookup_str().into()),
("generated".into(), generated.into()),
]
}));
fs::write(output, graphml.to_string())?;
Ok(())
}
fn load_xmlo<P: AsRef<Path>, S: Escaper>(
path_str: P,
fs: &mut VisitOnceFilesystem<FsCanonicalizer, FxBuildHasher>,