feat: livetable derive generates working code

Database identifiers are parsed and merged with table definition.
Add support machinery for multi-stage derive macros.
This commit is contained in:
YetAnotherMinion 2021-10-08 23:56:02 +01:00 committed by nobody
commit afb53518a5
Signed by: GrocerPublishAgent
GPG key ID: D460CD54A9E3AB86

View file

@ -62,22 +62,17 @@ fn exec(
output: Option<PathBuf>, output: Option<PathBuf>,
verbosity: u64, verbosity: u64,
) -> Result<(), Problem> { ) -> Result<(), Problem> {
// Our first elm make call is where we build the users program. There is a pretty good chance
// this won't work.
let mut command = Command::new("elm"); let mut command = Command::new("elm");
command command
.arg("make") .arg("make")
.arg("--output") .arg("--output")
.arg("/dev/null") .arg("/dev/null");
.stdin(Stdio::null()); //.stdin(Stdio::null());
//.stdout(Stdio::null());
if verbosity < 1 { // I am using the default inherit stderr behavior here.
command.stderr(Stdio::null()); //.stderr(Stdio::piped());
command.stdout(Stdio::null());
} else {
let pipe = dup_stderr()
.map_err(|io_err| CompilerError::ReadInputFailed(io_err, "stdout".into()))?;
command.stdout(pipe);
command.stderr(Stdio::piped());
}
if debug { if debug {
command.arg("--debug"); command.arg("--debug");
@ -85,14 +80,18 @@ fn exec(
command.arg(&file); command.arg(&file);
let start = Instant::now(); let start = Instant::now();
match command.status() { match command.output() {
Ok(exit_status) => { Ok(output) => {
if !exit_status.success() { if !output.status.success() {
// TODO report the stdout from the elm compiler io::stderr().write_all(&output.stderr).unwrap();
return Err(Problem::Wildcard("elm failed".into())); return Err(CompilerError::FailedBuildingFixture.into());
}
if verbosity > 0 {
io::stderr().write_all(&output.stderr).unwrap();
} }
} }
Err(_) => { Err(io_err) => {
// TODO handle this one
return Err(Problem::Wildcard("elm failed".into())); return Err(Problem::Wildcard("elm failed".into()));
} }
} }
@ -699,7 +698,7 @@ fn setup_generator_project(verbosity: u64, elm_project_dir: PathBuf) -> Result<P
let mut hasher = PortableHash::new(); let mut hasher = PortableHash::new();
std::io::copy(&mut elm_json_file, &mut hasher).unwrap(); std::io::copy(&mut elm_json_file, &mut hasher).unwrap();
let checksum: u64 = hasher.finish(); let checksum: u64 = hasher.finish();
println!("elm.json checksum {}", checksum); eprintln!("elm.json checksum {}", checksum);
let checksum_file = our_temp_dir.join("elm-json-checksum"); let checksum_file = our_temp_dir.join("elm-json-checksum");
if checksum_file.exists() { if checksum_file.exists() {