Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml parsing started #17

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
main*
main.o

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ members = [
"object",
"linker",
"ast",
"project",
"ty",
"ir",
"e2e",
]
Expand Down
9 changes: 5 additions & 4 deletions docs/project.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
type: Project
name:
details:

type: project
name:
targets:
-
hooks:
---
type: Exe
name: ty
Expand Down
10 changes: 10 additions & 0 deletions project/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "project"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1", features = [ "derive" ] }
serde_yaml = "0"
48 changes: 48 additions & 0 deletions project/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use serde::{Deserialize, Serialize};
use serde_yaml::{self};

#[derive(Serialize, Deserialize, Debug)]
pub struct Recipe {
kind: String,
name: String,
details: serde_yaml::Value,
}

pub struct ProjectConfig {}

impl ProjectConfig {
pub fn new() -> ProjectConfig {
ProjectConfig {}
}
pub fn parse_multi_yaml(&mut self, file: String) -> () {
for document in serde_yaml::Deserializer::from_str(&file) {
let v = Recipe::deserialize(document).unwrap();
println!("{:?}", v);
}
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let yaml = "\
kind: project\n\
name: SDL\n\
details:\n\
- ref: help\n\
- me\n\
---\n\
kind: target\n\
name: sdl_exe\n\
details:\n\
- help\n\
- me\n\
"
.to_string();
let mut project = ProjectConfig::new();
project.parse_multi_yaml(yaml);
}
}
8 changes: 8 additions & 0 deletions ty/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "ty"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
3 changes: 3 additions & 0 deletions ty/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
Loading