4 Commits

Author SHA1 Message Date
46abec1237 Increment version 2026-03-23 11:09:19 -05:00
49eaf6dbfc Enable compilers other than gcc (#6)
issue: #1
Reviewed-on: http://192.168.1.227:3000/sfrembling/pallet/pulls/6
Co-authored-by: godsfryingpan <sfrembling@gmail.com>
Co-committed-by: godsfryingpan <sfrembling@gmail.com>
2026-03-23 10:08:35 -06:00
02009762c1 update PKGBUILD with gcc as dep (#5)
issue: #3
Reviewed-on: http://192.168.1.227:3000/sfrembling/pallet/pulls/5
Co-authored-by: godsfryingpan <sfrembling@gmail.com>
Co-committed-by: godsfryingpan <sfrembling@gmail.com>
2026-03-23 09:57:14 -06:00
e52ad0bc24 add --force-recompile flag (#4)
issue: #2
Reviewed-on: http://192.168.1.227:3000/sfrembling/pallet/pulls/4
Co-authored-by: godsfryingpan <sfrembling@gmail.com>
Co-committed-by: godsfryingpan <sfrembling@gmail.com>
2026-03-23 09:55:03 -06:00
5 changed files with 25 additions and 10 deletions

2
Cargo.lock generated
View File

@@ -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",

View File

@@ -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"

View File

@@ -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=()

View File

@@ -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);

View File

@@ -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