Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 46abec1237 | |||
| 49eaf6dbfc | |||
| 02009762c1 | |||
| e52ad0bc24 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -247,7 +247,7 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
||||
|
||||
[[package]]
|
||||
name = "pallet"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"clap_complete",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "pallet"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
edition = "2024"
|
||||
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>
|
||||
pkgname=pallet
|
||||
pkgver=1.0.5
|
||||
pkgver=1.0.6
|
||||
pkgrel=1
|
||||
pkgdesc="A simple C project manager inspired by Cargo"
|
||||
arch=('x86_64')
|
||||
url=""
|
||||
license=('MIT')
|
||||
depends=()
|
||||
depends=('gcc')
|
||||
makedepends=('rust' 'cargo')
|
||||
source=()
|
||||
|
||||
|
||||
25
src/app.rs
25
src/app.rs
@@ -29,6 +29,9 @@ enum Subcommand {
|
||||
Init,
|
||||
/// Run the local project
|
||||
Run {
|
||||
/// Force recompilation of the project
|
||||
#[arg(long, short)]
|
||||
force_recompile: bool,
|
||||
/// The build mode to use
|
||||
mode: Option<String>,
|
||||
/// Arguments to pass to the project binary
|
||||
@@ -37,6 +40,9 @@ enum Subcommand {
|
||||
},
|
||||
/// Build the local project
|
||||
Build {
|
||||
/// Force recompilation of the project
|
||||
#[arg(long, short)]
|
||||
force_recompile: bool,
|
||||
/// The build mode to use
|
||||
mode: Option<String>,
|
||||
},
|
||||
@@ -86,8 +92,12 @@ impl App {
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Subcommand::Run { mode, args } => {
|
||||
match build(&mode) {
|
||||
Subcommand::Run {
|
||||
mode,
|
||||
args,
|
||||
force_recompile,
|
||||
} => {
|
||||
match build(&mode, force_recompile) {
|
||||
Err(e) => {
|
||||
eprintln!("Error building project: {e}");
|
||||
std::process::exit(1);
|
||||
@@ -99,7 +109,10 @@ impl App {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
Subcommand::Build { mode } => match build(&mode) {
|
||||
Subcommand::Build {
|
||||
mode,
|
||||
force_recompile,
|
||||
} => match build(&mode, force_recompile) {
|
||||
Err(e) => {
|
||||
eprintln!("Error building project: {e}");
|
||||
std::process::exit(1);
|
||||
@@ -220,7 +233,7 @@ fn get_config() -> Option<crate::config::Config> {
|
||||
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() {
|
||||
Some(conf) => conf,
|
||||
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));
|
||||
|
||||
if old_compute_path.exists() {
|
||||
if old_compute_path.exists() && !force_recompile {
|
||||
let text = std::fs::read_to_string(old_compute_path)?;
|
||||
|
||||
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 {
|
||||
command.arg(arg);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#[derive(serde::Deserialize, serde::Serialize, Default)]
|
||||
pub struct Config {
|
||||
/// The C compiler to use (defaults to "gcc")
|
||||
pub compiler: Option<String>,
|
||||
/// The name of the output binary
|
||||
pub name: String,
|
||||
/// The default build to use
|
||||
|
||||
Reference in New Issue
Block a user