From 82456e77c9af157ee04a0aabeb96c81b76786af7 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Sun, 3 Aug 2025 00:02:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .clang-format | 11 +++++++++++ .clangd | 4 ++++ .editorconfig | 20 ++++++++++++++++++++ .gitignore | 4 ++++ Makefile | 43 +++++++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 20 ++++++++++++++++++++ src/main.c | 1 + 7 files changed, 103 insertions(+) create mode 100644 .clang-format create mode 100644 .clangd create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 src/CMakeLists.txt create mode 100644 src/main.c diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..9a1855c --- /dev/null +++ b/.clang-format @@ -0,0 +1,11 @@ +# -*- mode: yaml; -*- + +--- +BasedOnStyle: Google +IndentWidth: 2 +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +--- +Language: Cpp +PointerAlignment: Right +--- diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..d525566 --- /dev/null +++ b/.clangd @@ -0,0 +1,4 @@ +# -*- mode: yaml; -*- + +Completion: + ArgumentLists: None diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..baf0da6 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a01b0bf --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/.cache/ +/build/ +/compile_commands.json +/zswm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e71960d --- /dev/null +++ b/Makefile @@ -0,0 +1,43 @@ +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 := zswm +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 &) + +wm: $(TARGET_NAME) + DISPLAY=:3 $(TARGET) + +prepare: + @cmake -S $(SRC_DIR) -B $(BUILD_DIR) + @cp $(BUILD_DIR)/compile_commands.json $(MAKEFILE_DIR) + +build: prepare + @cmake --build $(BUILD_DIR) + @cp $(BUILD_DIR)/$(TARGET_NAME) $(TARGET) + +install: $(TARGET_NAME) + @cp $(BUILD_DIR)/$(TARGET_NAME) ~/.local/bin/$(TARGET_NAME) + +uninstall: + ${RM} -r ~/.local/bin/$(TARGET_NAME) + +reinstall: uninstall install + +.PHONY: clean run wm prepare build install uninstall reinstall diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..091ab8b --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.24) + +set(APP_NAME "zswm") + +# generate compile_commands.json for clangd +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# compile flags +add_compile_options(-g) +add_compile_options(-Wall) + +project(${APP_NAME} + VERSION 0.0.1 + LANGUAGES C +) + +add_executable(${APP_NAME} main.c) + +# use C17 +set_property(TARGET ${APP_NAME} PROPERTY C_STANDARD 17) diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..44e82e2 --- /dev/null +++ b/src/main.c @@ -0,0 +1 @@ +int main(int argc, char *argv[]) { return 0; }