Merge pull request #56 from mist-go/future-proofed-modules
Future proofed module stucture
This commit is contained in:
Generated
+12
-5
@@ -455,6 +455,17 @@ dependencies = [
|
|||||||
"tower-lsp",
|
"tower-lsp",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mist-api"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"cargo_metadata",
|
||||||
|
"mist-codegen",
|
||||||
|
"mist-parser",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mist-codegen"
|
name = "mist-codegen"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
@@ -466,12 +477,8 @@ dependencies = [
|
|||||||
name = "mist-lang"
|
name = "mist-lang"
|
||||||
version = "0.0.5-alpha0"
|
version = "0.0.5-alpha0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo_metadata",
|
|
||||||
"mist-analyzer",
|
"mist-analyzer",
|
||||||
"mist-codegen",
|
"mist-api",
|
||||||
"mist-parser",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
+3
-10
@@ -16,19 +16,15 @@ include = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mist-parser = { workspace = true }
|
|
||||||
mist-analyzer = { workspace = true }
|
mist-analyzer = { workspace = true }
|
||||||
mist-codegen = { workspace = true }
|
mist-api = { workspace = true }
|
||||||
|
|
||||||
serde = { version = "1.0.228", features = ["serde_derive"] }
|
|
||||||
serde_json = "1.0.149"
|
|
||||||
cargo_metadata = "0.23.1"
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"crates/parser",
|
"crates/parser",
|
||||||
"crates/analyzer",
|
"crates/analyzer",
|
||||||
"crates/codegen",
|
"crates/codegen",
|
||||||
|
"crates/mist-api",
|
||||||
]
|
]
|
||||||
|
|
||||||
exclude = [
|
exclude = [
|
||||||
@@ -39,6 +35,7 @@ exclude = [
|
|||||||
mist-parser = { path = "crates/parser", version = "0.1.6" }
|
mist-parser = { path = "crates/parser", version = "0.1.6" }
|
||||||
mist-analyzer = { path = "crates/analyzer", version = "0.0.3" }
|
mist-analyzer = { path = "crates/analyzer", version = "0.0.3" }
|
||||||
mist-codegen = { path = "crates/codegen", version = "0.1.2" }
|
mist-codegen = { path = "crates/codegen", version = "0.1.2" }
|
||||||
|
mist-api = { path = "crates/mist-api", version = "0.1.0" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "mist"
|
name = "mist"
|
||||||
@@ -48,10 +45,6 @@ path = ".mist/src/main.rs"
|
|||||||
name = "mist-lsp"
|
name = "mist-lsp"
|
||||||
path = ".mist/lsp/main.rs"
|
path = ".mist/lsp/main.rs"
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "mist-header"
|
|
||||||
path = "src/_header.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "mist-analyzer"
|
name = "mist-analyzer"
|
||||||
path = ".mist/src/analyzer.rs"
|
path = ".mist/src/analyzer.rs"
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[package]
|
||||||
|
name = "mist-api"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0.228", features = ["serde_derive"] }
|
||||||
|
serde_json = "1.0.149"
|
||||||
|
cargo_metadata = "0.23.1"
|
||||||
|
mist-parser = { workspace = true }
|
||||||
|
mist-codegen = { workspace = true }
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "mist_api"
|
||||||
|
path = ".mist/src/lib.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "mist_lsp"
|
||||||
|
path = ".mist/lsp/main.rs"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
pub mod builder;
|
||||||
|
pub mod transpiler;
|
||||||
|
pub mod modules;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
pub mod builder;
|
||||||
|
pub mod transpiler;
|
||||||
|
pub mod modules;
|
||||||
|
|
||||||
|
void main() {}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
use <std::path::Path>;
|
||||||
|
use <std::path::PathBuf>;
|
||||||
|
use <std::fs>;
|
||||||
|
use <std::process>;
|
||||||
|
|
||||||
|
pub class Module {
|
||||||
|
pub String name;
|
||||||
|
pub PathBuf path;
|
||||||
|
pub Vec<Self> children;
|
||||||
|
|
||||||
|
pub constructor(String name, PathBuf mist_path, PathBuf rust_path) {
|
||||||
|
self.children = new Vec();
|
||||||
|
self.name = name;
|
||||||
|
self.path = mist_path;
|
||||||
|
|
||||||
|
if (self.path.is_dir()) {
|
||||||
|
var entries = match (fs::read_dir(&self.path)) {
|
||||||
|
Ok[entries] => entries;
|
||||||
|
Err[e] => {
|
||||||
|
eprintln!(
|
||||||
|
"error: failed to read directory {}\n {}",
|
||||||
|
self.path.display(),
|
||||||
|
e
|
||||||
|
);
|
||||||
|
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (entry : entries) {
|
||||||
|
var entry = match (entry) {
|
||||||
|
Ok[entry] => entry;
|
||||||
|
Err[e] => {
|
||||||
|
eprintln!("error: failed to read directory entry\n {}", e);
|
||||||
|
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
PathBuf child_path = entry.path();
|
||||||
|
|
||||||
|
String child_name = child_path.file_stem()
|
||||||
|
.and_then(|var s| s.to_str())
|
||||||
|
.expect("Failed to get module name")
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
PathBuf child_output = rust_path.join(&child_name).with_extension("rs");
|
||||||
|
|
||||||
|
if (should_skip(&child_path, &child_output)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.children.push(new Module(child_name, child_path, child_output));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub Module new_package(PathBuf mist_path, PathBuf rust_path) {
|
||||||
|
String name = mist_path.file_stem()
|
||||||
|
.and_then(|var s| s.to_str())
|
||||||
|
.expect("Failed to get module name")
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
new Module(name, mist_path, rust_path)
|
||||||
|
}
|
||||||
|
|
||||||
|
bool should_skip(Path* source, Path* output) {
|
||||||
|
var src_time = fs::metadata(source)
|
||||||
|
.ok()
|
||||||
|
.and_then(|var v| v.modified().ok());
|
||||||
|
|
||||||
|
var out_time = fs::metadata(output)
|
||||||
|
.ok()
|
||||||
|
.and_then(|var v| v.modified().ok());
|
||||||
|
|
||||||
|
out_time
|
||||||
|
.map(|var out_time| out_time >= src_time.unwrap())
|
||||||
|
.unwrap_or_default()
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package = "main.mist"
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
pub mod builder;
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
+2
-3
@@ -1,9 +1,8 @@
|
|||||||
use <std::process>;
|
use <std::process>;
|
||||||
use <std::env>;
|
use <std::env>;
|
||||||
use <std::fs>;
|
use <std::fs>;
|
||||||
|
use <mist_api::builder>;
|
||||||
pub mod builder;
|
use <mist_api::transpiler>;
|
||||||
pub mod transpiler;
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
Vec<String> args = env::args().collect();
|
Vec<String> args = env::args().collect();
|
||||||
|
|||||||
Reference in New Issue
Block a user