Project Skeleton
This commit is contained in:
parent
b500f3359c
commit
c86f8cd336
11 changed files with 70 additions and 0 deletions
35
Makefile
Normal file
35
Makefile
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
CC = gcc
|
||||||
|
CFLAGS = -Wall -Wextra -std=c99 -I$(HEADERS_DIR)
|
||||||
|
|
||||||
|
BIN_DIR = bin
|
||||||
|
BUILD_DIR = build
|
||||||
|
CORE_DIR = core
|
||||||
|
MODULES_DIR = modules
|
||||||
|
HEADERS_DIR = include
|
||||||
|
|
||||||
|
SRC_FILES = $(wildcard $(CORE_DIR)/*.c) $(wildcard $(MODULES_DIR)/*.c)
|
||||||
|
OBJ_FILES = $(patsubst %.c,$(BUILD_DIR)/%.o,$(notdir $(SRC_FILES)))
|
||||||
|
|
||||||
|
TARGET = $(BIN_DIR)/cpm
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
$(TARGET): $(OBJ_FILES) | $(BIN_DIR)
|
||||||
|
$(CC) $(CFLAGS) -o $@ $(OBJ_FILES)
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.o: $(CORE_DIR)/%.c | $(BUILD_DIR)
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.o: $(MODULES_DIR)/%.c | $(BUILD_DIR)
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(BUILD_DIR):
|
||||||
|
mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
|
$(BIN_DIR):
|
||||||
|
mkdir -p $(BIN_DIR)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR)/*
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
BIN
bin/cpm
Executable file
BIN
bin/cpm
Executable file
Binary file not shown.
BIN
build/cli.o
Normal file
BIN
build/cli.o
Normal file
Binary file not shown.
BIN
build/install.o
Normal file
BIN
build/install.o
Normal file
Binary file not shown.
BIN
build/main.o
Normal file
BIN
build/main.o
Normal file
Binary file not shown.
24
core/cli.c
24
core/cli.c
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "../include/cli.h"
|
||||||
|
|
||||||
|
int cli_run(int argc, char *argv[]){
|
||||||
|
for(int i = 1; i != argc; i++){
|
||||||
|
if (argc < 2){
|
||||||
|
printf("List of commands/keys:\ncpm -h/--help\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (strcmp(argv[i], "-h") == 0){
|
||||||
|
// Комментарий для Маши
|
||||||
|
//
|
||||||
|
// Тут должен быть код, который вызывает реализацию ключа -h ИЛИ --help
|
||||||
|
// Реализация должа предусмотреть что вызов любой версии команды равнозначен
|
||||||
|
// Реализация должна быть в папке modules, для обеспечения модульности программы
|
||||||
|
// Когда будешь кодить, удали этот комментарий пожалуйста
|
||||||
|
}
|
||||||
|
if (strcmp(argv[i], "-v") == 0){
|
||||||
|
printf("CPM Version: Alfa Build 0.1\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "../include/cli.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]){
|
||||||
|
return cli_run(argc, argv);
|
||||||
|
}
|
||||||
6
include/cli.h
Normal file
6
include/cli.h
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef CLI_H
|
||||||
|
#define CLI_H
|
||||||
|
|
||||||
|
int cli_run(int argc, char *argv[]);
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue