Skip to content

Commit f2277fa

Browse files
Refactor/cleanup tech debt (#9)
* Cleanup tech debt * Update vs code config * Cleanup magic numbers * Update README.md * Remove redundant docs * Remove unneeded README * Rename build script name * Simplify makefiles and update help section * Add testing framework README * Remove outdated test README
1 parent a4975ec commit f2277fa

21 files changed

Lines changed: 1059 additions & 1607 deletions

.vscode/README.md

Lines changed: 0 additions & 133 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"name": "Debug Cisco CLI (Local)",
5+
"name": "Debug Cisco CLI",
66
"type": "cppdbg",
77
"request": "launch",
88
"program": "${workspaceFolder}/build/cisco-cli-interface",
@@ -31,40 +31,7 @@
3131
"ignoreFailures": true
3232
}
3333
],
34-
"preLaunchTask": "docker-build-debug",
35-
"miDebuggerPath": "/usr/bin/gdb",
36-
"logging": {
37-
"engineLogging": false,
38-
"trace": false,
39-
"traceResponse": false
40-
}
41-
},
42-
{
43-
"name": "Debug Cisco CLI (Docker)",
44-
"type": "cppdbg",
45-
"request": "launch",
46-
"program": "/app/build/cisco-cli-interface",
47-
"args": [
48-
"/dev/ttyUSB0"
49-
],
50-
"stopAtEntry": false,
51-
"cwd": "/app",
52-
"environment": [
53-
{
54-
"name": "TERM",
55-
"value": "xterm-256color"
56-
}
57-
],
58-
"externalConsole": false,
59-
"MIMode": "gdb",
60-
"setupCommands": [
61-
{
62-
"description": "Enable pretty-printing for gdb",
63-
"text": "-enable-pretty-printing",
64-
"ignoreFailures": true
65-
}
66-
],
67-
"preLaunchTask": "docker-build-debug",
34+
"preLaunchTask": "build-debug",
6835
"miDebuggerPath": "/usr/bin/gdb",
6936
"logging": {
7037
"engineLogging": false,

.vscode/settings.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
"-g",
2020
"-O0"
2121
],
22+
"C_Cpp.default.browse": {
23+
"path": [
24+
"${workspaceFolder}/include",
25+
"${workspaceFolder}/src"
26+
]
27+
},
2228
"files.associations": {
2329
"*.h": "c",
2430
"*.c": "c"
@@ -36,5 +42,7 @@
3642
"debug.console.lineHeight": 22,
3743
"debug.inlineValues": true,
3844
"debug.showBreakpointsInOverviewRuler": true,
39-
"debug.showInlineBreakpointCandidates": true
45+
"debug.showInlineBreakpointCandidates": true,
46+
"debug.allowBreakpointsEverywhere": true,
47+
"debug.openDebug": "openOnDebugBreak"
4048
}

.vscode/tasks.json

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
{
55
"label": "build-debug",
66
"type": "shell",
7-
"command": "make",
7+
"command": "./scripts/dev-setup.sh",
88
"args": [
99
"debug"
1010
],
11-
"group": "build",
11+
"group": {
12+
"kind": "build",
13+
"isDefault": true
14+
},
1215
"presentation": {
1316
"echo": true,
1417
"reveal": "always",
@@ -20,14 +23,14 @@
2023
"problemMatcher": [
2124
"$gcc"
2225
],
23-
"detail": "Build the Cisco CLI Interface with debug symbols"
26+
"detail": "Build the Cisco CLI Interface with debug symbols using dev-setup.sh"
2427
},
2528
{
2629
"label": "build-release",
2730
"type": "shell",
28-
"command": "make",
31+
"command": "./scripts/dev-setup.sh",
2932
"args": [
30-
"release"
33+
"compile"
3134
],
3235
"group": "build",
3336
"presentation": {
@@ -41,19 +44,16 @@
4144
"problemMatcher": [
4245
"$gcc"
4346
],
44-
"detail": "Build the Cisco CLI Interface for release"
47+
"detail": "Build the Cisco CLI Interface for release using dev-setup.sh"
4548
},
4649
{
47-
"label": "docker-build-debug",
50+
"label": "setup-environment",
4851
"type": "shell",
4952
"command": "./scripts/dev-setup.sh",
5053
"args": [
51-
"debug"
54+
"build"
5255
],
53-
"group": {
54-
"kind": "build",
55-
"isDefault": true
56-
},
56+
"group": "build",
5757
"presentation": {
5858
"echo": true,
5959
"reveal": "always",
@@ -62,15 +62,12 @@
6262
"showReuseMessage": true,
6363
"clear": false
6464
},
65-
"problemMatcher": [
66-
"$gcc"
67-
],
68-
"detail": "Build the Cisco CLI Interface with debug symbols in Docker"
65+
"detail": "Build the Docker development environment"
6966
},
7067
{
7168
"label": "clean",
7269
"type": "shell",
73-
"command": "make",
70+
"command": "./scripts/dev-setup.sh",
7471
"args": [
7572
"clean"
7673
],
@@ -83,7 +80,7 @@
8380
"showReuseMessage": true,
8481
"clear": false
8582
},
86-
"detail": "Clean build artifacts"
83+
"detail": "Clean Docker resources and build artifacts"
8784
},
8885
{
8986
"label": "run-tests",
@@ -104,7 +101,7 @@
104101
"detail": "Run unit tests in Docker"
105102
},
106103
{
107-
"label": "docker-shell",
104+
"label": "dev-shell",
108105
"type": "shell",
109106
"command": "./scripts/dev-setup.sh",
110107
"args": [

Makefile

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
CC = gcc
2-
CFLAGS = -Wall -Wextra -std=c99 -g -Iinclude
2+
CFLAGS = -Wall -Wextra -std=c99 -g -Iinclude -MMD -MP
33
LIBS = -lncurses -lpthread
44
TARGET = build/cisco-cli-interface
55
SOURCES = src/main.c src/serial.c src/ui.c src/cisco_commands.c src/file_tree.c
66
OBJECTS = $(SOURCES:src/%.c=build/%.o)
7+
DEPENDS = $(OBJECTS:.o=.d)
78

8-
# Debug and Release configurations
9-
DEBUG_CFLAGS = -Wall -Wextra -std=c99 -g -O0 -DDEBUG -Iinclude
10-
RELEASE_CFLAGS = -Wall -Wextra -std=c99 -O2 -DNDEBUG -Iinclude
9+
.PHONY: all clean release install-deps help
1110

12-
.PHONY: all clean debug release
11+
all: $(TARGET)
1312

14-
all: debug
15-
16-
debug: CFLAGS = $(DEBUG_CFLAGS)
17-
debug: $(TARGET)
18-
19-
release: CFLAGS = $(RELEASE_CFLAGS)
13+
release: CFLAGS = -Wall -Wextra -std=c99 -O2 -DNDEBUG -Iinclude -MMD -MP
2014
release: $(TARGET)
2115

2216
$(TARGET): $(OBJECTS)
@@ -27,9 +21,20 @@ build/%.o: src/%.c
2721
$(CC) $(CFLAGS) -c $< -o $@
2822

2923
clean:
30-
rm -f $(OBJECTS) $(TARGET)
24+
rm -f $(OBJECTS) $(TARGET) $(DEPENDS)
3125
rm -rf build
3226

3327
install-deps:
3428
sudo apt-get update
35-
sudo apt-get install -y libncurses5-dev libncursesw5-dev
29+
sudo apt-get install -y libncurses5-dev libncursesw5-dev build-essential
30+
31+
help:
32+
@echo "Available targets:"
33+
@echo " all - Build debug version (default)"
34+
@echo " release - Build optimized release version"
35+
@echo " clean - Remove build artifacts"
36+
@echo " install-deps- Install system dependencies"
37+
@echo " help - Show this help"
38+
39+
# Include dependency files
40+
-include $(DEPENDS)

0 commit comments

Comments
 (0)