json_makefile

0.1.0 • Public • Published

JSON to Makefile

A simple utility to convert a JSON file to a well-formatted Makefile. Helps you to generate a beautiful, programmable, with error checks and portable Makefile.

Notes of the version :

  • Fixed a bug in returned error message.
  • Added the possibility to add variables with multiple values (array).

Install :

npm i json_makefile

OR

apt install nodejs -y
apt install npm -y
git clone https://github.com/flavienbwk/json_makefile
cd json_makefile

Use :

Assuming makefile_example.json is the JSON Makefile you want to convert.

node json_to_makefile.ts makefile_example.json # [ makefile_example_2.json [ makefile_example_3.json [...]]] 

Creating the JSON Makefile (example) :

{
    "parser_version": "0.0.1",      // Version of json_to_makefile for which the JSON has been designed.
    "output": "Makefile",           // Name of the output file converted.
    "variables": {                  // Declare here your variables and their values.
        "CC": "gcc",
        "MAIN_PRGM": "main.c",
        "NAME_PRGM": "my_program",
        "$(NAME)": "this is a name",
        "$(LMY)": "another name",
        "SRC": [                    // Variable with multiple values.
            "./src/file_manager.c",
            "./src/arguments_handler.c"
        ]
    },
    "targets": [                    // Define here your targets.
        {
            "name": "$(NAME)",      // Name of the target.
            "dependencies" : [      // Dependencies of the target.
                "$(OBJ)",
                "$(LMY)"
            ],
            "commands": [           // Commands associated with the target.
                "ar rc $(NAME) $(OBJ)",
                "ranlib $(NAME)",
                "chmod +x $(NAME)"
            ]
        },
        {
            "name": "$(LMY)",
            "dependencies": [],     // Can have no dependency.
            "commands": [
                "make -C $(LMY)"
            ]
        }
        // [...]
    ]
}

Will output inside Makefile :

CC        = gcc
MAIN_PRGM = main.c
NAME_PRGM = my_ls
$(NAME)   = this is a name
$(LMY)    = another name
SRC   = ./src/file_manager.c \
            ./src/arguments_handler.c
 
$(NAME):    $(OBJ) $(LMY)
            ar rc $(NAME) $(OBJ)
            ranlib $(NAME)
            chmod +x $(NAME)
 
$(LMY):     
            make -C $(LMY)
 

install

npm i json_makefile

Downloadsweekly downloads

2

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability