fmake

make any project just by typing `fmake`

commit 356ae291822d8d03dce901528b13059dbf8debdb
parent b980866e759a9f0741d02fc1c8de5632bd9c9f8d
Author: Bharatvaj Hemanth <bharatvaj@getsh.org>
Date: Sat, 26 Nov 2022 02:48:03 +0530

Add support for Cargo.toml and setup.py

Remove old commands
2 files changed, 12 insertions(+), 20 deletions(-)
M
config.h
|
25
++++++++++++-------------
M
fmake.c
|
7
-------
diff --git a/config.h b/config.h
@@ -7,6 +7,9 @@ typedef enum {
 	FMAKE_AUTOCONF,
 	FMAKE_CONFIGURE,
 	FMAKE_CMAKE,
+	FMAKE_NPM,
+	FMAKE_RUST,
+	FMAKE_PIP,
 } maker_t;
 
 typedef struct {

@@ -16,23 +19,19 @@ typedef struct {
 	const char* args;
 } maker_config_t;
 
-static const char* cmdlists[] = {
-	"make",
-	"gmake",
-	"bmake",
-};
-
 #define multiple_(ARG) \
 	ARG, cmdlists[ARG]
 
 static const maker_config_t makers[] = {
-	{ "configure", FMAKE_CMAKE,          "sh", "configure"   },
-	{ "Makefile",       FMAKE_POSIX_MAKEFILE, "make", ""        },
-	{ "makefile",       FMAKE_POSIX_MAKEFILE, "make", ""        },
-	{ "GNUMakefile",    FMAKE_GNU_MAKEFILE,   "gmake", ""       },
-	{ "BSDMakefile",    FMAKE_BSD_MAKEFILE,   "bmake", ""       },
-	{ "CMakeLists.txt", FMAKE_CMAKE,          "cmake", "-B out/"   },
-	{ "package.json", FMAKE_CMAKE,          "npm", "install"   },
+	{ "configure",      FMAKE_CMAKE,          "sh",    "configure"   },
+	{ "Makefile",       FMAKE_POSIX_MAKEFILE, "make",  ""            },
+	{ "makefile",       FMAKE_POSIX_MAKEFILE, "make",  ""            },
+	{ "GNUMakefile",    FMAKE_GNU_MAKEFILE,   "gmake", ""            },
+	{ "BSDMakefile",    FMAKE_BSD_MAKEFILE,   "bmake", ""            },
+	{ "CMakeLists.txt", FMAKE_CMAKE,          "cmake", "-B out/"     },
+	{ "package.json",   FMAKE_NPM,          "npm",   "install"     },
+	{ "Cargo.toml",     FMAKE_RUST,          "cargo", "install"     },
+	{ "setup.py",       FMAKE_PIP,          "pip",   "install ."   },
 };
 
 static int8_t *detected_indices = 0;
diff --git a/fmake.c b/fmake.c
@@ -5,11 +5,6 @@
 
 #include "config.h"
 
-// Two things to do
-// scan directory and pick out the maker
-// process the input string and convert it for the `maker`
-// output the full commands
-
 void process_build() {
 	printf("%s %s", maker.cmd, maker.args);
 }

@@ -32,8 +27,6 @@ void process_string() {
 	}
 }
 
-// support -- arguments for cmake and other stuff
-// fmake -- --preset x86-64-apple-darwin
 
 int main(int argc, char* argv[]) {
 	process_string();