fmake

make any project just by typing `fmake`
git clone git@getsh.org:fmake.git
Log | Files | Refs | README | LICENSE

commit d51d84605e57552a3b30d90348d589ae291bc399
parent 4bb1265dd73e8370c79666bb6c541bdb025bf1a1
Author: Bharatvaj Hemanth <bharatvaj@getsh.org>
Date:   Sat, 26 Nov 2022 03:32:19 +0530

Fix crash when no supported maker file is found

Fix the configure loop issue, makefiles now have more priority than
cofigure script

Diffstat:
Mconfig.h | 2+-
Mfmake.c | 14+++++---------
2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/config.h b/config.h @@ -24,11 +24,11 @@ typedef struct { 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", "" }, +{ "configure", FMAKE_CONFIGURE, "sh", "configure" }, { "CMakeLists.txt", FMAKE_CMAKE, "cmake", "-B out/" }, { "package.json", FMAKE_NPM, "npm", "install" }, { "Cargo.toml", FMAKE_RUST, "cargo", "install" }, diff --git a/fmake.c b/fmake.c @@ -9,22 +9,18 @@ void process_build() { printf("%s %s", maker.cmd, maker.args); } +struct stat st = {0}; void process_string() { - struct stat st = {0}; - short maker_found = 0; - for (int i = 0; i < sizeof(makers); i++) { + for (int i = 0; i < (sizeof(makers) / sizeof(maker_config_t)); i++) { const char* filename = makers[i].filename; if (!stat(filename, &st)) { maker = makers[i]; - maker_found = 1; process_build(); - break; + return; } } - if (maker_found == 0) { - maker = makers[FMAKE_POSIX_MAKEFILE]; - process_build(); - } + maker = makers[FMAKE_POSIX_MAKEFILE]; + process_build(); }