commit f4e7319a449a425709a0a0e6b26d7b0be3c8b82b Author: dragonflylee Date: Thu Apr 13 15:21:21 2023 +0800 Initial commit diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..1e07f3f --- /dev/null +++ b/.clang-format @@ -0,0 +1,14 @@ +--- +BasedOnStyle: Google +ColumnLimit: 120 +AccessModifierOffset: -4 +AlignAfterOpenBracket: false +IndentWidth: 4 +BreakBeforeBraces: Attach +CommentPragmas: '^[^ ]' +IncludeBlocks: Regroup +PointerAlignment: Left +SortIncludes: Never +IndentCaseLabels : false +Standard: Cpp11 +... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0056ea3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.o +*.exe +/build +/cDrive.* diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..680d798 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "MinGW64", + "includePath": [ + "${workspaceFolder}/include", + "C:\\MinGW64\\include", + "C:\\MinGW64\\x86_64-w64-mingw32\\include" + ], + "compilerPath": "C:\\MinGW64\\bin\\gcc.exe", + "cStandard": "c11", + "cppStandard": "c++17" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..fd67371 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,33 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) 启动", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/cDrive.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "为 gdb 启用整齐打印", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "将反汇编风格设置为 Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + } + + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ee6e271 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.15) + +include(FetchContent) + +FetchContent_Declare(spdlog + URL https://github.com/gabime/spdlog/archive/v1.11.0.tar.gz + DOWNLOAD_EXTRACT_TIMESTAMP TRUE +) +FetchContent_MakeAvailable(spdlog) + +FetchContent_Declare(mbedtls + URL https://github.com/Mbed-TLS/mbedtls/archive/v2.28.3.tar.gz + DOWNLOAD_EXTRACT_TIMESTAMP TRUE +) +set(ENABLE_PROGRAMS OFF CACHE INTERNAL "" FORCE) +set(ENABLE_TESTING OFF CACHE INTERNAL "" FORCE) +FetchContent_MakeAvailable(mbedtls) + +find_package(CURL) +if (NOT CURL_FOUND) + FetchContent_Declare(curl + URL https://curl.se/download/curl-8.5.0.tar.xz + DOWNLOAD_EXTRACT_TIMESTAMP TRUE + ) + set(CURL_USE_MBEDTLS ON) + set(HTTP_ONLY ON) + set(BUILD_CURL_EXE OFF) + set(BUILD_TESTING OFF) + set(BUILD_SHARED_LIBS OFF) + set(CURL_DISABLE_PROGRESS_METER ON CACHE INTERNAL "" FORCE) + FetchContent_MakeAvailable(curl) +endif () + +find_library(qrcodegen_FOUND qrcodegen) +if (qrcodegen_FOUND) + message(STATUS "found qrcodegen") +endif () + +project(clist) +file(GLOB_RECURSE MAIN_SRC "${CMAKE_SOURCE_DIR}/src/*.cpp") +add_executable(${PROJECT_NAME} ${MAIN_SRC}) +target_include_directories(${PROJECT_NAME} PRIVATE include) +target_link_libraries(${PROJECT_NAME} PRIVATE spdlog mbedtls qrcodegen CURL::libcurl) \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4d43a8d --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +TARGET = cDrive + +SRCS := src src/drive + +VPATH := $(foreach dir,$(SRCS),$(CURDIR)/$(dir)) +CFILES := $(foreach dir,$(SRCS),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SRCS),$(notdir $(wildcard $(dir)/*.cpp))) +OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) + +INCLUDES := -I$(CURDIR)/include +CFLAGS := -g -Wall $(INCLUDES) `curl-config --cflags` +CXXFLAGS := $(CFLAGS) -fno-rtti -std=c++17 +LDFLAGS := `curl-config --libs` -lqrcodegen -lmbedcrypto + +.PHONY: all +all: $(TARGET) + +$(TARGET): $(OFILES) + $(CXX) -o $@ $^ $(LDFLAGS) + +run: all + @./$(TARGET) + +clean: + $(RM) -fr $(BUILD) $(TARGET) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..0bbcd38 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# clist +Cloud drive explorer for C/C++ + +## Build On Debian + +* Debian `apt-get install libcurl4-openssl-dev libspdlog-dev libqrcodegen-dev libmbedtls-dev` + +## Build On Windows + +```bash +cmake -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build +``` \ No newline at end of file