初始化项目配置

This commit is contained in:
2025-10-08 07:44:37 +08:00
commit b8231b78ff
7 changed files with 106 additions and 0 deletions

11
.clang-format Normal file
View File

@@ -0,0 +1,11 @@
# -*- mode: yaml; -*-
---
BasedOnStyle: Google
IndentWidth: 2
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
---
Language: Cpp
PointerAlignment: Right
---

4
.clangd Normal file
View File

@@ -0,0 +1,4 @@
# -*- mode: yaml; -*-
Completion:
ArgumentLists: None

20
.editorconfig Normal file
View File

@@ -0,0 +1,20 @@
root = true
[*.{c,h}]
indent_style = space
indent_size = 2
[.clangd]
indent_style = space
indent_size = 2
[*.cmake]
indent_style = space
indent_size = 4
[CMakeLists.txt]
indent_style = space
indent_size = 4
[Makefile]
indent_style = tab

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
/compile_commands.json
/build/
/zdwm
/.cache/

42
Makefile Normal file
View File

@@ -0,0 +1,42 @@
MAKEFILE_ABS_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(dir $(MAKEFILE_ABS_PATH))
PWD_DIR := $(CURDIR)/
BUILD_DIR := $(addprefix $(MAKEFILE_DIR),build)
SRC_DIR := $(addprefix $(MAKEFILE_DIR),src/)
TARGET_NAME := zdwm
TARGET := $(addprefix $(MAKEFILE_DIR),$(TARGET_NAME))
ifneq ($(PWD_DIR),$(MAKEFILE_DIR))
TARGET := $(addprefix $(MAKEFILE_DIR),$(TARGET_NAME))
endif
$(TARGET_NAME): build
clean:
${RM} $(TARGET)
${RM} -r $(BUILD_DIR)
run:
-$(shell Xephyr :3 -screen 1920x1080 &)
run_multiple_screen:
-$(shell Xephyr :3 -screen 1920x1080 -screen 1920x1080 +xinerama &)
wm: $(TARGET_NAME)
DISPLAY=:3 $(TARGET)
debug: $(TARGET_NAME)
DISPLAY=:3 valgrind --leak-check=full $(TARGET)
prepare:
@cmake -S $(SRC_DIR) -B $(BUILD_DIR)
@cp $(BUILD_DIR)/compile_commands.json $(MAKEFILE_DIR)
build: prepare
${RM} -f $(TARGET)
@cmake --build $(BUILD_DIR)
@cp $(BUILD_DIR)/$(TARGET_NAME) $(TARGET)
.PHONY: clean run wm prepare build install uninstall reinstall

24
src/CMakeLists.txt Normal file
View File

@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.24)
set(APP_NAME "zdwm")
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
add_compile_definitions(LOG_FILE="$ENV{HOME}/zdwm-log.txt")
# generate compile_commands.json for clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# compile flags
add_compile_options(-g)
add_compile_options(-Wall)
# add_link_options(-fsanitize=address)
project(${APP_NAME}
VERSION 0.0.1
LANGUAGES C
)
add_executable(${APP_NAME} main.c)
# use C23
set_property(TARGET ${APP_NAME} PROPERTY C_STANDARD 23)

1
src/main.c Normal file
View File

@@ -0,0 +1 @@
int main(int argc, char *argv[]) { return 0; }