added license

This commit is contained in:
bQUARKz 2026-01-19 06:30:40 +00:00 committed by Nilton Constantino
parent 2d04dc37b1
commit 536a64afed
No known key found for this signature in database
8 changed files with 357 additions and 2 deletions

133
Cargo.lock generated
View File

@ -104,6 +104,56 @@ dependencies = [
"libc",
]
[[package]]
name = "anstream"
version = "0.6.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
[[package]]
name = "anstyle-parse"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys 0.61.2",
]
[[package]]
name = "arrayref"
version = "0.3.9"
@ -303,6 +353,46 @@ dependencies = [
"libloading 0.8.9",
]
[[package]]
name = "clap"
version = "4.5.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.114",
]
[[package]]
name = "clap_lex"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32"
[[package]]
name = "codespan-reporting"
version = "0.11.1"
@ -313,6 +403,12 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "colorchoice"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
[[package]]
name = "com"
version = "0.6.0"
@ -700,6 +796,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
version = "0.5.2"
@ -722,6 +824,12 @@ dependencies = [
"hashbrown 0.16.1",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]]
name = "itertools"
version = "0.13.0"
@ -1290,6 +1398,12 @@ version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "once_cell_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "orbclient"
version = "0.3.50"
@ -1455,6 +1569,13 @@ version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773"
[[package]]
name = "prometeu"
version = "0.1.0"
dependencies = [
"clap",
]
[[package]]
name = "prometeu-core"
version = "0.1.0"
@ -1796,6 +1917,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "1.0.109"
@ -1957,6 +2084,12 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "version_check"
version = "0.9.5"

View File

@ -2,5 +2,9 @@
members = [
"crates/prometeu-core",
"crates/prometeu-runtime-desktop",
"crates/prometeu",
]
resolver = "2"
[workspace.package]
license = "MIT"

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Nilton Constantino, aka bQUARKz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -46,11 +46,18 @@ runtime/
Cargo.toml # Workspace root
rust-toolchain.toml # Versão do Rust (fixa)
crates/
prometeu/ # CLI Dispatcher (ponto de entrada unificado)
prometeu-core/ # PROMETEU Core (hardware lógico)
prometeu-runtime-desktop/ # Host desktop (janela, input real, present)
cart-demo/ # Cartucho/demo hardcoded (temporário)
```
### crates/prometeu
O binário principal que centraliza o acesso ao ecossistema:
- `prometeu run <cart>`: Executa um cartucho
- `prometeu debug <cart>`: Inicia em modo debug
- `prometeu build/pack`: Comandos planejados para ferramentas de build e empacotamento
### crates/prometeu-core
Contém o **núcleo do PROMETEU**:
- loop lógico
@ -104,7 +111,13 @@ Na raiz do repositório:
```bash
cargo build
cargo run -p prometeu-runtime-desktop
./target/debug/prometeu run <caminho_do_cartucho>
```
Ou diretamente via cargo:
```bash
cargo run -p prometeu -- run <caminho_do_cartucho>
```
No início, o host apenas valida:
@ -129,7 +142,7 @@ Nada aqui deve ser considerado API estável ainda.
## 📜 Licença
A definir.
Este projeto está licenciado sob a Licença MIT - veja o arquivo [LICENSE](LICENSE) para detalhes.
---

View File

@ -2,6 +2,7 @@
name = "prometeu-core"
version = "0.1.0"
edition = "2024"
license.workspace = true
[dependencies]
serde = { version = "1.0", features = ["derive"] }

View File

@ -2,6 +2,7 @@
name = "prometeu-runtime-desktop"
version = "0.1.0"
edition = "2024"
license.workspace = true
[dependencies]
prometeu-core = { path = "../prometeu-core" }

View File

@ -0,0 +1,8 @@
[package]
name = "prometeu"
version = "0.1.0"
edition = "2024"
license.workspace = true
[dependencies]
clap = { version = "4.5", features = ["derive"] }

174
crates/prometeu/src/main.rs Normal file
View File

@ -0,0 +1,174 @@
use clap::{Parser, Subcommand};
use std::env;
use std::path::{Path, PathBuf};
use std::process::Command;
#[derive(Parser)]
#[command(name = "prometeu")]
#[command(about = "Dispatcher para o ecossistema Prometeu", long_about = None)]
struct Cli {
#[command(subcommand)]
command: Option<Commands>,
}
#[derive(Subcommand)]
enum Commands {
/// Executa um cartucho
Run {
/// Caminho para o cartucho
cart: String,
},
/// Debuga um cartucho
Debug {
/// Caminho para o cartucho
cart: String,
/// Porta para o debugger (padrão: 7777)
#[arg(long, default_value_t = 7777)]
port: u16,
},
/// Compila um projeto
Build {
/// Diretório do projeto
project_dir: String,
},
/// Empacota um cartucho
Pack {
/// Diretório do cartucho
cart_dir: String,
},
/// Verifica integridade de um projeto ou cartucho
Verify {
#[command(subcommand)]
target: VerifyCommands,
},
}
#[derive(Subcommand)]
enum VerifyCommands {
/// Verifica um projeto
C {
/// Diretório do projeto
project_dir: String,
},
/// Verifica um cartucho ou arquivo PMC
P {
/// Caminho para o cartucho ou PMC
cart_or_pmc: String,
},
}
fn main() {
let cli = Cli::parse();
let exe_dir = match env::current_exe() {
Ok(exe_path) => exe_path.parent().unwrap_or_else(|| Path::new(".")).to_path_buf(),
Err(e) => {
eprintln!("Erro ao obter o caminho do executável: {}", e);
std::process::exit(1);
}
};
match cli.command {
Some(Commands::Run { cart }) => {
dispatch(&exe_dir, "prometeu-runtime", &["--run", &cart]);
}
Some(Commands::Debug { cart, port }) => {
dispatch(
&exe_dir,
"prometeu-runtime",
&["--debug", &cart, "--port", &port.to_string()],
);
}
Some(Commands::Build { .. }) => {
not_implemented("build", "prometeuc");
}
Some(Commands::Pack { .. }) => {
not_implemented("pack", "prometeup");
}
Some(Commands::Verify { target }) => match target {
VerifyCommands::C { .. } => not_implemented("verify c", "prometeuc"),
VerifyCommands::P { .. } => not_implemented("verify p", "prometeup"),
},
None => {
use clap::CommandFactory;
Cli::command().print_help().unwrap();
println!();
}
}
}
fn get_binary_path(dir: &Path, name: &str) -> PathBuf {
let mut path = dir.join(name);
if cfg!(target_os = "windows") {
path.set_extension("exe");
}
path
}
fn dispatch(exe_dir: &Path, bin_name: &str, args: &[&str]) {
let bin_path = get_binary_path(exe_dir, bin_name);
if !bin_path.exists() {
// Tenta encontrar o runtime com o nome exato (prometeu-runtime-desktop)
// caso prometeu-runtime seja apenas um alias ou link que ainda não existe
let alt_bin_name = if bin_name == "prometeu-runtime" {
Some("prometeu-runtime-desktop")
} else {
None
};
let final_bin_path = if let Some(alt_name) = alt_bin_name {
let alt_path = get_binary_path(exe_dir, alt_name);
if alt_path.exists() {
alt_path
} else {
bin_path
}
} else {
bin_path
};
if !final_bin_path.exists() {
eprintln!(
"prometeu: comando '{}' ainda não está disponível nesta distribuição",
match bin_name {
"prometeu-runtime" => "run/debug",
"prometeuc" => "build/verify c",
"prometeup" => "pack/verify p",
_ => bin_name,
}
);
std::process::exit(1);
}
execute_bin(&final_bin_path, args);
} else {
execute_bin(&bin_path, args);
}
}
fn execute_bin(bin_path: &Path, args: &[&str]) {
let status = Command::new(bin_path)
.args(args)
.stdin(std::process::Stdio::inherit())
.stdout(std::process::Stdio::inherit())
.stderr(std::process::Stdio::inherit())
.status();
match status {
Ok(status) => {
std::process::exit(status.code().unwrap_or(0));
}
Err(e) => {
eprintln!("Erro ao executar {}: {}", bin_path.display(), e);
std::process::exit(1);
}
}
}
fn not_implemented(cmd: &str, _bin_name: &str) {
eprintln!(
"prometeu: comando '{}' ainda não está disponível nesta distribuição",
cmd
);
std::process::exit(1);
}