fmake

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

commit c6f0fbb6f0cebee1b38a6a8cac9c470e5159b90d
parent 1a3efd728daef82de7eaa80ff308e110e0170d72
Author: Bharatvaj Hemanth <bharatvaj@getsh.org>
Date:   Fri, 25 Nov 2022 23:24:06 +0530

Refactor fatmake to fmake

Add support for make and cmake

Diffstat:
A.gitignore | 1+
MMakefile | 16+++++++++++-----
MREADME | 21++++++++++++++++++---
Mconfig.h | 36+++++++++++++++++++++++++++++++-----
Aconfig.mk | 3+++
Dfatmake.c | 32--------------------------------
Afmake.c | 37+++++++++++++++++++++++++++++++++++++
Alist.txt | 17+++++++++++++++++
8 files changed, 118 insertions(+), 45 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1 @@ +fmake diff --git a/Makefile b/Makefile @@ -1,11 +1,17 @@ -SRC = fatmake.c +include config.mk -all: fatmake +PROGRAM = fmake -fatmake: $(SRC) +SRC = $(PROGRAM).c + +all: $(PROGRAM) + +$(PROGRAM): $(SRC) config.h clean: - rm fatmake + rm $(PROGRAM) test: - ./fatmake ENABLE_DEBUG=1 + @./$(PROGRAM) ENABLE_DEBUG=1 + +.PHONY: all test clean diff --git a/README b/README @@ -1,8 +1,23 @@ -fatmake -------- +fmake +===== An attempt at saving developers time. -fatmake is a program that brings `make`s interface to almost any build system. +fmake is a program that brings `make`s interface to almost any build system. See this |list.txt| for the number of build systems available. + + +fmake refrains from reading the source files, but does so when required like reading a version number or detecting a syntax. + +Every build system has ranking that is followed so that +autotools - 1 +cmake - 1 +make - 2 + + +fmake "intelligently" knows what targets to build +mapper files +------------ + +`fmake` has the analogy of mapper files which can be used to make a project. diff --git a/config.h b/config.h @@ -1,10 +1,36 @@ #include <stdint.h> -static int8_t *detected_indices = 0; -static char* maker = 0; +typedef enum { + FMAKE_POSIX_MAKEFILE, + FMAKE_GNU_MAKEFILE, + FMAKE_BSD_MAKEFILE, + FMAKE_CMAKE, +} maker_t; + +typedef struct { + const char* filename; + maker_t type; + const char* cmd; + const char* args; +} maker_config_t; -static const char* filenames[] = { - "Makefile", - "makefile" +static const char* cmdlists[] = { + "make", + "gmake", + "bmake", }; +#define multiple_(ARG) \ + ARG, cmdlists[ARG] + +static const maker_config_t makers[] = { + { "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" }, +}; + +static int8_t *detected_indices = 0; +static maker_config_t maker; + diff --git a/config.mk b/config.mk @@ -0,0 +1,3 @@ +VERSION := 0.1.0 + +CFLAGS := -DFMAKE_VERSION=$(VERSION) diff --git a/fatmake.c b/fatmake.c @@ -1,32 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> - -#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 - -char* process_string() { - char* s = (char*)malloc(256); - strcpy(s, "hello, wold"); - struct stat st = {0}; - for (int i = 0; i < sizeof(filenames); i++) { - if (!stat(filenames[i], &st)) { - printf("File detected %s", filenames[i]); - break; - } - } - return s; -} - -// support -- arguments for cmake and other stuff -// fmake -- --preset x86-64-apple-darwin - -int main(int argc, char* argv[]) { - printf("%s\n", process_string()); - return -1; -} diff --git a/fmake.c b/fmake.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +#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", maker.cmd); +} + +char* process_string() { + char* s = (char*)malloc(256); + struct stat st = {0}; + for (int i = 0; i < sizeof(makers); i++) { + const char* filename = makers[i].filename; + if (!stat(filename, &st)) { + maker = makers[i]; + process_build(); + break; + } + } + return s; +} + +// support -- arguments for cmake and other stuff +// fmake -- --preset x86-64-apple-darwin + +int main(int argc, char* argv[]) { + printf("%s\n", process_string()); + return -1; +} diff --git a/list.txt b/list.txt @@ -0,0 +1,17 @@ +Supported build files +--------------------- + +* .sln +* .xcrun + +* cmake + +* gmake +* bmake +* nmake + +* bazel +* gradle +* meson + +* autotools