Compare commits
4 Commits
218a6306d4
...
v1.0.6
| Author | SHA1 | Date | |
|---|---|---|---|
| 46abec1237 | |||
| 49eaf6dbfc | |||
| 02009762c1 | |||
| e52ad0bc24 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -247,7 +247,7 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pallet"
|
name = "pallet"
|
||||||
version = "1.0.5"
|
version = "1.0.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pallet"
|
name = "pallet"
|
||||||
version = "1.0.5"
|
version = "1.0.6"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
description = "A project manager and build system for C inspired by Rust's Cargo"
|
description = "A project manager and build system for C inspired by Rust's Cargo"
|
||||||
|
|
||||||
|
|||||||
4
PKGBUILD
4
PKGBUILD
@@ -1,12 +1,12 @@
|
|||||||
# Maintainer: Shea Frembling <sfrembling@gmail.com>
|
# Maintainer: Shea Frembling <sfrembling@gmail.com>
|
||||||
pkgname=pallet
|
pkgname=pallet
|
||||||
pkgver=1.0.5
|
pkgver=1.0.6
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="A simple C project manager inspired by Cargo"
|
pkgdesc="A simple C project manager inspired by Cargo"
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
url=""
|
url=""
|
||||||
license=('MIT')
|
license=('MIT')
|
||||||
depends=()
|
depends=('gcc')
|
||||||
makedepends=('rust' 'cargo')
|
makedepends=('rust' 'cargo')
|
||||||
source=()
|
source=()
|
||||||
|
|
||||||
|
|||||||
25
src/app.rs
25
src/app.rs
@@ -29,6 +29,9 @@ enum Subcommand {
|
|||||||
Init,
|
Init,
|
||||||
/// Run the local project
|
/// Run the local project
|
||||||
Run {
|
Run {
|
||||||
|
/// Force recompilation of the project
|
||||||
|
#[arg(long, short)]
|
||||||
|
force_recompile: bool,
|
||||||
/// The build mode to use
|
/// The build mode to use
|
||||||
mode: Option<String>,
|
mode: Option<String>,
|
||||||
/// Arguments to pass to the project binary
|
/// Arguments to pass to the project binary
|
||||||
@@ -37,6 +40,9 @@ enum Subcommand {
|
|||||||
},
|
},
|
||||||
/// Build the local project
|
/// Build the local project
|
||||||
Build {
|
Build {
|
||||||
|
/// Force recompilation of the project
|
||||||
|
#[arg(long, short)]
|
||||||
|
force_recompile: bool,
|
||||||
/// The build mode to use
|
/// The build mode to use
|
||||||
mode: Option<String>,
|
mode: Option<String>,
|
||||||
},
|
},
|
||||||
@@ -86,8 +92,12 @@ impl App {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Subcommand::Run { mode, args } => {
|
Subcommand::Run {
|
||||||
match build(&mode) {
|
mode,
|
||||||
|
args,
|
||||||
|
force_recompile,
|
||||||
|
} => {
|
||||||
|
match build(&mode, force_recompile) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Error building project: {e}");
|
eprintln!("Error building project: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
@@ -99,7 +109,10 @@ impl App {
|
|||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Subcommand::Build { mode } => match build(&mode) {
|
Subcommand::Build {
|
||||||
|
mode,
|
||||||
|
force_recompile,
|
||||||
|
} => match build(&mode, force_recompile) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Error building project: {e}");
|
eprintln!("Error building project: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
@@ -220,7 +233,7 @@ fn get_config() -> Option<crate::config::Config> {
|
|||||||
toml::from_str(&raw).ok()
|
toml::from_str(&raw).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(mode: &Option<String>) -> std::io::Result<()> {
|
fn build(mode: &Option<String>, force_recompile: bool) -> std::io::Result<()> {
|
||||||
let conf = match get_config() {
|
let conf = match get_config() {
|
||||||
Some(conf) => conf,
|
Some(conf) => conf,
|
||||||
None => {
|
None => {
|
||||||
@@ -249,7 +262,7 @@ fn build(mode: &Option<String>) -> std::io::Result<()> {
|
|||||||
|
|
||||||
let old_compute_path = PathBuf::from(format!("target/{}/.build_hash", build_config.name));
|
let old_compute_path = PathBuf::from(format!("target/{}/.build_hash", build_config.name));
|
||||||
|
|
||||||
if old_compute_path.exists() {
|
if old_compute_path.exists() && !force_recompile {
|
||||||
let text = std::fs::read_to_string(old_compute_path)?;
|
let text = std::fs::read_to_string(old_compute_path)?;
|
||||||
|
|
||||||
if hash.trim() == text.trim() {
|
if hash.trim() == text.trim() {
|
||||||
@@ -261,7 +274,7 @@ fn build(mode: &Option<String>) -> std::io::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut command = Command::new("gcc");
|
let mut command = Command::new(conf.compiler.as_deref().unwrap_or("gcc"));
|
||||||
|
|
||||||
for arg in &build_config.args {
|
for arg in &build_config.args {
|
||||||
command.arg(arg);
|
command.arg(arg);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#[derive(serde::Deserialize, serde::Serialize, Default)]
|
#[derive(serde::Deserialize, serde::Serialize, Default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
/// The C compiler to use (defaults to "gcc")
|
||||||
|
pub compiler: Option<String>,
|
||||||
/// The name of the output binary
|
/// The name of the output binary
|
||||||
pub name: String,
|
pub name: String,
|
||||||
/// The default build to use
|
/// The default build to use
|
||||||
|
|||||||
Reference in New Issue
Block a user