Compare commits
No commits in common. "e58ff492334c510b5dd78af340bd6c6360947295" and "3f732880c9d47c705d07dbce883f741489651578" have entirely different histories.
e58ff49233
...
3f732880c9
|
|
@ -1 +1,2 @@
|
||||||
|
.ccls-cache
|
||||||
build
|
build
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Clean",
|
"label": "Clean",
|
||||||
"detail": "Clean build directory",
|
"detail": "Clean build directory and executable",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "make",
|
"command": "make",
|
||||||
"args": [
|
"args": [
|
||||||
|
|
@ -37,25 +37,6 @@
|
||||||
"clear": true
|
"clear": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"label": "Run",
|
|
||||||
"detail": "Build project and run",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "make",
|
|
||||||
"args": [
|
|
||||||
"-j$(nproc)",
|
|
||||||
"run"
|
|
||||||
],
|
|
||||||
"group": "build",
|
|
||||||
"presentation": {
|
|
||||||
"echo": true,
|
|
||||||
"reveal": "always",
|
|
||||||
"focus": true,
|
|
||||||
"panel": "shared",
|
|
||||||
"showReuseMessage": true,
|
|
||||||
"clear": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label": "Build Verbose",
|
"label": "Build Verbose",
|
||||||
"detail": "Build project with verbosity on",
|
"detail": "Build project with verbosity on",
|
||||||
|
|
@ -75,32 +56,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Build Debug",
|
"label": "Run",
|
||||||
"detail": "Build project in debug mode",
|
"detail": "Run executable",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "make",
|
"command": "make",
|
||||||
"args": [
|
"args": [
|
||||||
"-j$(nproc)",
|
|
||||||
"DEBUG=2"
|
|
||||||
],
|
|
||||||
"group": "build",
|
|
||||||
"presentation": {
|
|
||||||
"echo": true,
|
|
||||||
"reveal": "always",
|
|
||||||
"focus": true,
|
|
||||||
"panel": "shared",
|
|
||||||
"showReuseMessage": true,
|
|
||||||
"clear": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Run Debug",
|
|
||||||
"detail": "Build project in debug mode and run",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "make",
|
|
||||||
"args": [
|
|
||||||
"-j$(nproc)",
|
|
||||||
"DEBUG=2",
|
|
||||||
"run"
|
"run"
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
|
|
|
||||||
93
C/Makefile
93
C/Makefile
|
|
@ -1,47 +1,32 @@
|
||||||
export
|
# Build folder
|
||||||
|
|
||||||
SHELL = /usr/bin/env bash
|
|
||||||
|
|
||||||
ROOT := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
|
||||||
|
|
||||||
#
|
|
||||||
# User settings
|
|
||||||
#
|
|
||||||
|
|
||||||
BUILD_DIR = build
|
BUILD_DIR = build
|
||||||
|
|
||||||
SOURCE_DIR = src
|
# Source files
|
||||||
|
SOURCES := \
|
||||||
|
src/main.c
|
||||||
|
|
||||||
OUTPUT = C_Executable
|
# Output target name
|
||||||
|
OUTPUT := C
|
||||||
|
|
||||||
|
# Compiler and flags
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = --std=c17 -Os
|
CCFLAGS = -Wall -Wextra -std=c17
|
||||||
LD_FLAGS =
|
LDFLAGS =
|
||||||
|
|
||||||
ifneq ($(DEBUG),)
|
# Include directories
|
||||||
CFLAGS += -O1 -g -DDEBUG=$(DEBUG) -Wextra -Wall --pedantic -Wno-missing-braces \
|
INCLUDE_DIRS =
|
||||||
-Wno-missing-field-initializers -Wformat=2 -Wswitch-default -Wswitch \
|
|
||||||
-Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 \
|
|
||||||
-Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual \
|
|
||||||
-Wshadow -Wunreachable-code -Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 \
|
|
||||||
-Wredundant-decls -Wold-style-definition
|
|
||||||
endif
|
|
||||||
|
|
||||||
#
|
|
||||||
# End
|
|
||||||
#
|
|
||||||
|
|
||||||
# Relocate vars
|
|
||||||
BUILD_DIR := $(ROOT)/$(BUILD_DIR)
|
|
||||||
|
|
||||||
SOURCE_DIR := $(ROOT)/$(SOURCE_DIR)
|
|
||||||
|
|
||||||
|
# Change output location
|
||||||
OUTPUT := $(BUILD_DIR)/$(OUTPUT)
|
OUTPUT := $(BUILD_DIR)/$(OUTPUT)
|
||||||
|
|
||||||
# Verbosity
|
# Deduce objects
|
||||||
export Q := @
|
OBJECTS = $(SOURCES:%.c=$(BUILD_DIR)/%.o)
|
||||||
|
|
||||||
|
# Verbose mode
|
||||||
ifeq ($(VERBOSE), 1)
|
ifeq ($(VERBOSE), 1)
|
||||||
Q :=
|
Q :=
|
||||||
|
else
|
||||||
|
Q := @
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
|
|
@ -49,20 +34,44 @@ GREEN := \033[32m
|
||||||
YELLOW := \033[33m
|
YELLOW := \033[33m
|
||||||
RESET := \033[m
|
RESET := \033[m
|
||||||
|
|
||||||
|
# Current file nb to process
|
||||||
|
CURRENT_FILE := 0
|
||||||
|
|
||||||
# Default targets
|
# Default targets
|
||||||
all: $(OUTPUT)
|
all: count_build build_dir end
|
||||||
|
|
||||||
$(OUTPUT): FORCE
|
# Create build directory
|
||||||
$(Q)cd $(SOURCE_DIR) && $(MAKE) $@
|
build_dir:
|
||||||
|
$(Q)mkdir -p $(dir $(OBJECTS))
|
||||||
|
|
||||||
FORCE:
|
# Link target
|
||||||
|
$(OUTPUT): $(OBJECTS)
|
||||||
|
@echo -e "[100%] $(YELLOW)Linking $(OUTPUT)$(RESET)"
|
||||||
|
$(Q)$(CC) $(LDFLAGS) -o $@ $(OBJECTS)
|
||||||
|
|
||||||
.PHONY: clean run print-var-%
|
# Build .o files from .c
|
||||||
|
$(BUILD_DIR)/%.o: %.c
|
||||||
|
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1))))
|
||||||
|
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE)*100/$(TOTAL_FILES)))))
|
||||||
|
@echo -e "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
|
||||||
|
$(Q)$(CC) $(CCFLAGS) $(INCLUDE_DIRS:%=-I%) -MMD -MP -c $< -o $@
|
||||||
|
|
||||||
|
# Source files dependencies
|
||||||
|
-include $(OBJECTS:.o=.d)
|
||||||
|
|
||||||
|
count_build:
|
||||||
|
$(eval export TOTAL_FILES := $(shell echo $$(($$(make -n $(OBJECTS) 2>/dev/null | grep -c "Building") + 1))))
|
||||||
|
|
||||||
|
# Print ending message
|
||||||
|
end: $(OUTPUT)
|
||||||
|
@echo "Built target $(OUTPUT)"
|
||||||
|
|
||||||
|
# Clean
|
||||||
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
$(Q)rm -rf $(BUILD_DIR)
|
$(Q)rm -rf $(BUILD_DIR)
|
||||||
|
|
||||||
|
# Run executable
|
||||||
|
.PHONY: run
|
||||||
run: all
|
run: all
|
||||||
$(Q)cd $(BUILD_DIR) && ./$(notdir $(OUTPUT))
|
$(Q)./$(OUTPUT)
|
||||||
|
|
||||||
print-var-% :
|
|
||||||
@echo $($*)
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
SOURCES += \
|
|
||||||
main.c
|
|
||||||
|
|
||||||
INCLUDES +=
|
|
||||||
|
|
||||||
OBJECTS := $(SOURCES:%=$(BUILD_DIR)/$(notdir $(SOURCE_DIR))/%.o)
|
|
||||||
|
|
||||||
ifeq ($(TOTAL_BUILD_FILES),)
|
|
||||||
TOTAL_BUILD_FILES := $(shell echo $$(($$($(MAKE) -n $(OBJECTS) TOTAL_BUILD_FILES=1 2>/dev/null | grep -c Building) + 1)))
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(OUTPUT): $(OBJECTS)
|
|
||||||
@echo "[100%] $(YELLOW)Linking $(notdir $(OUTPUT))$(RESET)"
|
|
||||||
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/$(notdir $(SOURCE_DIR))/%.o: $(SOURCE_DIR)/%
|
|
||||||
$(Q)mkdir -p $(dir $@)
|
|
||||||
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
|
|
||||||
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
|
|
||||||
@echo "[$(shell printf "%3d" $(PERCENTAGE))%] $(GREEN)Building C object $@$(RESET)"
|
|
||||||
$(Q)$(CC) $(CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@
|
|
||||||
|
|
||||||
-include $(OBJECTS:.o=.d)
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
build
|
build
|
||||||
|
.vscode/ccls-cache
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"intelliSenseMode": "linux-gcc-arm",
|
|
||||||
"browse": {
|
|
||||||
"path": [
|
|
||||||
"${workspaceFolder}"
|
|
||||||
],
|
|
||||||
"limitSymbolsToIncludedHeaders": true
|
|
||||||
},
|
|
||||||
"compileCommands": "build/compile_commands.json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
|
|
@ -1,62 +1,12 @@
|
||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
|
||||||
"label": "Configure",
|
|
||||||
"detail": "configure project",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "cmake",
|
|
||||||
"args": [
|
|
||||||
"-H.",
|
|
||||||
"-Bbuild",
|
|
||||||
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1"
|
|
||||||
],
|
|
||||||
"group": "build",
|
|
||||||
"presentation": {
|
|
||||||
"echo": true,
|
|
||||||
"reveal": "always",
|
|
||||||
"focus": true,
|
|
||||||
"panel": "shared",
|
|
||||||
"showReuseMessage": true,
|
|
||||||
"clear": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label": "Build",
|
"label": "Build",
|
||||||
"detail": "Build project",
|
"detail": "Build project",
|
||||||
"dependsOn": [
|
|
||||||
"Configure"
|
|
||||||
],
|
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "make",
|
"command": "cmake -H. -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=YES && make -j$(nproc) -C build",
|
||||||
"args": [
|
"args": [
|
||||||
"-C",
|
|
||||||
"build",
|
|
||||||
"-j$(nproc)"
|
|
||||||
],
|
|
||||||
"group": "build",
|
|
||||||
"presentation": {
|
|
||||||
"echo": true,
|
|
||||||
"reveal": "always",
|
|
||||||
"focus": true,
|
|
||||||
"panel": "shared",
|
|
||||||
"showReuseMessage": true,
|
|
||||||
"clear": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Flash",
|
|
||||||
"detail": "Build and flash",
|
|
||||||
"type": "shell",
|
|
||||||
"dependsOn": [
|
|
||||||
"Configure"
|
|
||||||
],
|
|
||||||
"command": "make",
|
|
||||||
"args": [
|
|
||||||
"-C",
|
|
||||||
"build",
|
|
||||||
"-j$(nproc)",
|
|
||||||
"Flash"
|
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"presentation": {
|
"presentation": {
|
||||||
|
|
@ -72,10 +22,8 @@
|
||||||
"label": "Clean",
|
"label": "Clean",
|
||||||
"detail": "Clean build directory and executable",
|
"detail": "Clean build directory and executable",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "rm",
|
"command": "rm -rf build",
|
||||||
"args": [
|
"args": [
|
||||||
"-rf",
|
|
||||||
"build"
|
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"presentation": {
|
"presentation": {
|
||||||
|
|
@ -86,6 +34,24 @@
|
||||||
"showReuseMessage": false,
|
"showReuseMessage": false,
|
||||||
"clear": true
|
"clear": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Flash",
|
||||||
|
"detail": "Flash executable",
|
||||||
|
"type": "shell",
|
||||||
|
"dependsOn": "Build",
|
||||||
|
"command": "cd build && make Flash",
|
||||||
|
"args": [
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"focus": true,
|
||||||
|
"panel": "shared",
|
||||||
|
"showReuseMessage": true,
|
||||||
|
"clear": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -15,22 +15,21 @@ set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
pico_sdk_init()
|
pico_sdk_init()
|
||||||
|
|
||||||
add_executable(PicoSDKExec)
|
add_executable(PicoSDKProject
|
||||||
target_sources(PicoSDKExec PUBLIC
|
|
||||||
src/main.c
|
src/main.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(PicoSDKExec
|
target_link_libraries(PicoSDKProject
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
)
|
)
|
||||||
|
|
||||||
# Stdio configuration
|
# Stdio configuration
|
||||||
pico_enable_stdio_usb(PicoSDKExec 1)
|
pico_enable_stdio_usb(PicoSDKProject 1)
|
||||||
pico_enable_stdio_uart(PicoSDKExec 1)
|
pico_enable_stdio_uart(PicoSDKProject 1)
|
||||||
|
|
||||||
pico_add_extra_outputs(PicoSDKExec)
|
pico_add_extra_outputs(PicoSDKProject)
|
||||||
|
|
||||||
add_custom_target(Flash
|
add_custom_target(Flash
|
||||||
DEPENDS PicoSDKExec
|
DEPENDS PicoSDKProject
|
||||||
COMMAND picotool load -f ${PROJECT_BINARY_DIR}/PicoSDKExec.uf2
|
COMMAND picotool load -f ${PROJECT_BINARY_DIR}/PicoSDKProject.uf2
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
build/compile_commands.json
|
||||||
Loading…
Reference in New Issue