https://github.com/flavienbwk/json_makefile
A simple utility to convert a JSON file to a well-formatted Makefile.
https://github.com/flavienbwk/json_makefile
cli json makefile nodejs
Last synced: 2 months ago
JSON representation
A simple utility to convert a JSON file to a well-formatted Makefile.
- Host: GitHub
- URL: https://github.com/flavienbwk/json_makefile
- Owner: flavienbwk
- License: mit
- Created: 2018-06-30T17:26:40.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-02T18:17:56.000Z (about 8 years ago)
- Last Synced: 2025-10-19T00:54:40.912Z (9 months ago)
- Topics: cli, json, makefile, nodejs
- Language: TypeScript
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 :
```bash
npm i json_makefile
```
**OR**
```bash
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.
```bash
node json_to_makefile.ts makefile_example.json # [ makefile_example_2.json [ makefile_example_3.json [...]]]
```
## Creating the JSON Makefile (example) :
```javascript
{
"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` :
```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)
```