Skip to content

Commit

Permalink
Add description makefile and some suff
Browse files Browse the repository at this point in the history
  • Loading branch information
alumpish committed Jun 16, 2023
1 parent 93970ce commit 289abd4
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 0 deletions.
21 changes: 21 additions & 0 deletions CA4 - Congestion Control Algorithms/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
BasedOnStyle: Google
BreakBeforeBraces: Custom
BraceWrapping:
BeforeCatch: true
BeforeElse: true
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
IndentWidth: 4
AccessModifierOffset: -4
IndentCaseLabels: false
NamespaceIndentation: Inner
ColumnLimit: 0
AlignConsecutiveMacros: Consecutive
DerivePointerAlignment: false
SpacesBeforeTrailingComments: 1
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
...
8 changes: 8 additions & 0 deletions CA4 - Congestion Control Algorithms/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@
*.exe
*.out
*.app

# Output files
/debug
/obj

*.txt
*.gp
*.png
30 changes: 30 additions & 0 deletions CA4 - Congestion Control Algorithms/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "make&debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/debug/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Skip std namespace",
"text": "skip -rfunction ^std::"
}
],
"preLaunchTask": "make_debug"
}
]
}
36 changes: 36 additions & 0 deletions CA4 - Congestion Control Algorithms/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "make_debug",
"type": "shell",
"command": "make debug",
"args": [],
"problemMatcher": "$gcc",
"group": "build"
},
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
Binary file not shown.
68 changes: 68 additions & 0 deletions CA4 - Congestion Control Algorithms/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# tool macros
CXX ?= g++
CXXFLAGS :=
DBGFLAGS := -g
COBJFLAGS := $(CXXFLAGS) -c

# path macros
BIN_PATH := bin
OBJ_PATH := obj
SRC_PATH := src
DBG_PATH := debug

# compile macros
TARGET_NAME := main
ifeq ($(OS),Windows_NT)
TARGET_NAME := $(addsuffix .exe,$(TARGET_NAME))
endif
TARGET := $(BIN_PATH)/$(TARGET_NAME)
TARGET_DEBUG := $(DBG_PATH)/$(TARGET_NAME)

# src files & obj files
SRC := $(foreach x, $(SRC_PATH), $(wildcard $(addprefix $(x)/*,.c*)))
OBJ := $(addprefix $(OBJ_PATH)/, $(addsuffix .o, $(notdir $(basename $(SRC)))))
OBJ_DEBUG := $(addprefix $(DBG_PATH)/, $(addsuffix .o, $(notdir $(basename $(SRC)))))

# clean files list
DISTCLEAN_LIST := $(OBJ) \
$(OBJ_DEBUG)
CLEAN_LIST := $(TARGET) \
$(TARGET_DEBUG) \
$(DISTCLEAN_LIST)

# default rule
default: makedir all

# non-phony targets
$(TARGET): $(OBJ)
$(CXX) -o $@ $(OBJ) $(CXXFLAGS)

$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c*
$(CXX) $(COBJFLAGS) -o $@ $<

$(DBG_PATH)/%.o: $(SRC_PATH)/%.c*
$(CXX) $(COBJFLAGS) $(DBGFLAGS) -o $@ $<

$(TARGET_DEBUG): $(OBJ_DEBUG)
$(CXX) $(CXXFLAGS) $(DBGFLAGS) $(OBJ_DEBUG) -o $@

# phony rules
.PHONY: makedir
makedir:
@mkdir -p $(BIN_PATH) $(OBJ_PATH) $(DBG_PATH)

.PHONY: all
all: $(TARGET)

.PHONY: debug
debug: $(TARGET_DEBUG)

.PHONY: clean
clean:
@echo CLEAN $(CLEAN_LIST)
@rm -f $(CLEAN_LIST)

.PHONY: distclean
distclean:
@echo CLEAN $(DISTCLEAN_LIST)
@rm -f $(DISTCLEAN_LIST)

0 comments on commit 289abd4

Please sign in to comment.